aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authormltownsend <mltownsend@gmail.com>2010-02-04 18:21:45 +0000
committermltownsend <mltownsend@gmail.com>2010-02-04 18:21:45 +0000
commit9903700d95e23ad908ba3b3185e6a56a1206f659 (patch)
tree35a735fb709b737354f4f20337e2c0968ca1603e /Source
parent2c5453a01eae97bf03f16cfd088f2f069bb0594d (diff)
downloadsequelpro-9903700d95e23ad908ba3b3185e6a56a1206f659.tar.gz
sequelpro-9903700d95e23ad908ba3b3185e6a56a1206f659.tar.bz2
sequelpro-9903700d95e23ad908ba3b3185e6a56a1206f659.zip
Fix for issue #560. Still needs validation on hitting Apply, but fixes the initial problem.
Diffstat (limited to 'Source')
-rw-r--r--Source/SPUserMO.m5
-rw-r--r--Source/SPUserManager.m58
2 files changed, 59 insertions, 4 deletions
diff --git a/Source/SPUserMO.m b/Source/SPUserMO.m
index 386e4831..c4980391 100644
--- a/Source/SPUserMO.m
+++ b/Source/SPUserMO.m
@@ -38,7 +38,10 @@
- (void)setDisplayName:(NSString *)value
{
- [self setValue:value forKey:@"host"];
+ if ([self valueForKey:@"parent"] == nil)
+ [self setValue:value forKey:@"user"];
+ else
+ [self setValue:value forKey:@"host"];
}
- (void)addChildrenObject:(NSManagedObject *)value
diff --git a/Source/SPUserManager.m b/Source/SPUserManager.m
index 09d26f1f..b91a019b 100644
--- a/Source/SPUserManager.m
+++ b/Source/SPUserManager.m
@@ -474,11 +474,60 @@
}
}
+ if ([selectedObject parent] != nil && [selectedObject host] == nil)
+ {
+ [selectedObject setValue:@"%" forKey:@"host"];
+ [outlineView reloadItem:selectedObject];
+ }
[schemasTableView deselectAll:nil];
[grantedTableView deselectAll:nil];
[availableTableView deselectAll:nil];
}
+-(BOOL)selectionShouldChangeInOutlineView:(NSOutlineView *)outlineView
+{
+ if ([[treeController selectedObjects] count] > 0)
+ {
+ id selectedObject = [[treeController selectedObjects] objectAtIndex:0];
+ // Check parents
+ if ([selectedObject valueForKey:@"parent"] == nil)
+ {
+ NSString *name = [selectedObject valueForKey:@"user"];
+ NSArray *results = [self _fetchUserWithUserName:name];
+ if ([results count] > 1)
+ {
+ NSAlert *alert = [NSAlert alertWithMessageText:@"Duplicate User"
+ defaultButton:NSLocalizedString(@"OK", @"OK button")
+ alternateButton:nil
+ otherButton:nil
+ informativeTextWithFormat:@"A user with that name already exists"];
+ [alert runModal];
+ return NO;
+ }
+ }
+ else
+ {
+ NSArray *children = [selectedObject valueForKeyPath:@"parent.children"];
+ NSString *host = [selectedObject valueForKey:@"host"];
+ for (NSManagedObject *child in children)
+ {
+ if (![selectedObject isEqual:child] && [[child valueForKey:@"host"] isEqualToString:host])
+ {
+ NSAlert *alert = [NSAlert alertWithMessageText:@"Duplicate Host"
+ defaultButton:NSLocalizedString(@"OK", @"OK button")
+ alternateButton:nil
+ otherButton:nil
+ informativeTextWithFormat:@"A user with that host already exists"];
+ [alert runModal];
+ return NO;
+ }
+ }
+ }
+
+ }
+ return YES;
+}
+
- (NSArray *)treeSortDescriptors
{
NSSortDescriptor *descriptor = [[[NSSortDescriptor alloc] initWithKey:@"displayName" ascending:YES] autorelease];
@@ -635,8 +684,7 @@
{
if ([self.managedObjectContext hasChanges])
{
- //NSAlert *alert = [[[NSAlert alloc] init] autorelease];
- NSAlert *alert = [NSAlert alertWithMessageText:@"Window has changes. All changes will be lost!"
+ NSAlert *alert = [NSAlert alertWithMessageText:@"Warning!"
defaultButton:NSLocalizedString(@"Continue", @"Continue")
alternateButton:NSLocalizedString(@"Cancel",@"Cancel")
otherButton:nil
@@ -1050,7 +1098,11 @@
- (BOOL)checkAndDisplayMySqlError
{
if (![[self.mySqlConnection getLastErrorMessage] isEqualToString:@""]) {
- NSAlert *alert = [NSAlert alertWithMessageText:@"MySQL Error" defaultButton:@"OK" alternateButton:nil otherButton:nil informativeTextWithFormat:[self.mySqlConnection getLastErrorMessage]];
+ NSAlert *alert = [NSAlert alertWithMessageText:@"MySQL Error"
+ defaultButton:NSLocalizedString(@"OK", @"OK button")
+ alternateButton:nil
+ otherButton:nil
+ informativeTextWithFormat:[self.mySqlConnection getLastErrorMessage]];
[alert runModal];
return NO;