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 /Source/SPUserManager.m | |
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
Diffstat (limited to 'Source/SPUserManager.m')
-rw-r--r-- | Source/SPUserManager.m | 34 |
1 files changed, 28 insertions, 6 deletions
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]]; |