diff options
author | mltownsend <mltownsend@gmail.com> | 2010-02-09 20:28:33 +0000 |
---|---|---|
committer | mltownsend <mltownsend@gmail.com> | 2010-02-09 20:28:33 +0000 |
commit | d0fb716108641d3a8c197ef12041bf46b14e7294 (patch) | |
tree | 42da9b83e516cbd153efc5e46035161110e060b8 | |
parent | da88e1ea6bac13e52b14e3510db56a18162b2c73 (diff) | |
download | sequelpro-d0fb716108641d3a8c197ef12041bf46b14e7294.tar.gz sequelpro-d0fb716108641d3a8c197ef12041bf46b14e7294.tar.bz2 sequelpro-d0fb716108641d3a8c197ef12041bf46b14e7294.zip |
Fixed some issues with the drop user/drop host commands in the user manager
-rw-r--r-- | Source/SPUserMO.m | 1 | ||||
-rw-r--r-- | Source/SPUserManager.m | 34 | ||||
-rw-r--r-- | Source/SPUserManager.xcdatamodel/elements | bin | 127988 -> 127762 bytes | |||
-rw-r--r-- | Source/SPUserManager.xcdatamodel/layout | bin | 9663 -> 9663 bytes |
4 files changed, 28 insertions, 7 deletions
diff --git a/Source/SPUserMO.m b/Source/SPUserMO.m index c4980391..061f4658 100644 --- a/Source/SPUserMO.m +++ b/Source/SPUserMO.m @@ -66,5 +66,4 @@ [changedObjects release]; } - @end diff --git a/Source/SPUserManager.m b/Source/SPUserManager.m index a65de9ee..e81ca2a2 100644 --- a/Source/SPUserManager.m +++ b/Source/SPUserManager.m @@ -497,7 +497,7 @@ if ([results count] > 1) { NSAlert *alert = [NSAlert alertWithMessageText:@"Duplicate User" - defaultButton:NSLocalizedString(@"OK", @"OK button") + defaultButton:NSLocalizedString(@"OK", @"OK") alternateButton:nil otherButton:nil informativeTextWithFormat:@"A user with that name already exists"]; @@ -514,7 +514,7 @@ if (![selectedObject isEqual:child] && [[child valueForKey:@"host"] isEqualToString:host]) { NSAlert *alert = [NSAlert alertWithMessageText:@"Duplicate Host" - defaultButton:NSLocalizedString(@"OK", @"OK button") + defaultButton:NSLocalizedString(@"OK", @"OK") alternateButton:nil otherButton:nil informativeTextWithFormat:@"A user with that host already exists"]; @@ -634,6 +634,14 @@ - (IBAction)removeUser:(id)sender { + NSString *username = [[[treeController selectedObjects] objectAtIndex:0] + valueForKey:@"user"]; + NSArray *children = [[[treeController selectedObjects] objectAtIndex:0] + valueForKey:@"children"]; + for(NSManagedObject *child in children) + { + [child setPrimitiveValue:username forKey:@"user"]; + } [treeController remove:sender]; } @@ -661,7 +669,21 @@ - (IBAction)removeHost:(id)sender { + // Set the username on the child so that it's accessabile when building + // the drop sql command + NSManagedObject *child = [[treeController selectedObjects] objectAtIndex:0]; + NSManagedObject *parent = [child valueForKey:@"parent"]; + [child setPrimitiveValue:[[child valueForKey:@"parent"] valueForKey:@"user"] forKey:@"user"]; [treeController remove:sender]; + if ([[parent valueForKey:@"children"] count] == 0) + { + NSAlert *alert = [NSAlert alertWithMessageText:@"User doesn't have any hosts." + defaultButton:NSLocalizedString(@"OK", @"OK") + alternateButton:nil + otherButton:nil + informativeTextWithFormat:@"This user doesn't have any hosts associated with it. User will be deleted unless one is added"]; + [alert runModal]; + } } - (IBAction)addSchemaPriv:(id)sender @@ -690,8 +712,8 @@ if ([self.managedObjectContext hasChanges]) { NSAlert *alert = [NSAlert alertWithMessageText:@"Warning!" - defaultButton:NSLocalizedString(@"Continue", @"continue button") - alternateButton:NSLocalizedString(@"Cancel",@"cancel button") + defaultButton:NSLocalizedString(@"Continue", @"Continue") + alternateButton:NSLocalizedString(@"Cancel",@"Cancel") otherButton:nil informativeTextWithFormat:@"Window has changes. All changes will be lost!"]; [alert setAlertStyle:NSWarningAlertStyle]; @@ -889,7 +911,7 @@ NSMutableString *droppedUsers = [NSMutableString string]; for (NSManagedObject *user in deletedUsers) { - if ([user host] != nil) + if (![[[user entity] name] isEqualToString:@"Privileges"] && [user valueForKey:@"host"] != nil) { [droppedUsers appendString:[NSString stringWithFormat:@"%@@%@, ", [[user valueForKey:@"user"] backtickQuotedString], @@ -1115,7 +1137,7 @@ { if (![[self.mySqlConnection getLastErrorMessage] isEqualToString:@""]) { NSAlert *alert = [NSAlert alertWithMessageText:@"MySQL Error" - defaultButton:NSLocalizedString(@"OK", @"OK button") + defaultButton:NSLocalizedString(@"OK", @"OK") alternateButton:nil otherButton:nil informativeTextWithFormat:[self.mySqlConnection getLastErrorMessage]]; diff --git a/Source/SPUserManager.xcdatamodel/elements b/Source/SPUserManager.xcdatamodel/elements Binary files differindex b651569a..66ebccfc 100644 --- a/Source/SPUserManager.xcdatamodel/elements +++ b/Source/SPUserManager.xcdatamodel/elements diff --git a/Source/SPUserManager.xcdatamodel/layout b/Source/SPUserManager.xcdatamodel/layout Binary files differindex f55e70d0..44b16b93 100644 --- a/Source/SPUserManager.xcdatamodel/layout +++ b/Source/SPUserManager.xcdatamodel/layout |