diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPUserManager.h | 1 | ||||
-rw-r--r-- | Source/SPUserManager.m | 46 |
2 files changed, 32 insertions, 15 deletions
diff --git a/Source/SPUserManager.h b/Source/SPUserManager.h index 76a790e5..172fbdde 100644 --- a/Source/SPUserManager.h +++ b/Source/SPUserManager.h @@ -52,6 +52,7 @@ IBOutlet NSButton *addSchemaPrivButton; IBOutlet NSButton *removeSchemaPrivButton; + IBOutlet NSTextField *userNameTextField; NSMutableArray *schemas; NSMutableArray *grantedSchemaPrivs; diff --git a/Source/SPUserManager.m b/Source/SPUserManager.m index c5b621ef..a65de9ee 100644 --- a/Source/SPUserManager.m +++ b/Source/SPUserManager.m @@ -555,6 +555,10 @@ - (IBAction)doApply:(id)sender { NSError *error = nil; + + //Change the first responder to end editing in any field + [[self window] makeFirstResponder:self]; + [[self managedObjectContext] save:&error]; if (error != nil) { @@ -625,6 +629,7 @@ [treeController addObject:newItem]; [outlineView expandItem:[outlineView itemAtRow:[outlineView selectedRow]]]; + [[self window] makeFirstResponder:userNameTextField]; } - (IBAction)removeUser:(id)sender @@ -907,22 +912,33 @@ { if ([[[user entity] name] isEqualToString:@"Privileges"]) continue; - NSString *createStatement; - - if ([user parent] && [[user parent] valueForKey:@"user"] && [[user parent] valueForKey:@"password"]) { - - createStatement = [NSString stringWithFormat:@"CREATE USER %@@%@ IDENTIFIED BY %@;", - [[[user parent] valueForKey:@"user"] tickQuotedString], - [[user valueForKey:@"host"] tickQuotedString], - [[[user parent] valueForKey:@"password"] tickQuotedString]]; - - // Create user in database - [self.mySqlConnection queryString:createStatement]; - - if ([self checkAndDisplayMySqlError]) { - [self grantPrivilegesToUser:user]; - } + NSString *createStatement = nil; + + if ([user parent] && [[user parent] valueForKey:@"user"] && [[user parent] valueForKey:@"password"]) + { + createStatement = [NSString stringWithFormat:@"CREATE USER %@@%@ IDENTIFIED BY %@", + [[[user parent] valueForKey:@"user"] tickQuotedString], + [[user valueForKey:@"host"] tickQuotedString], + [[[user parent] valueForKey:@"password"] tickQuotedString]]; } + else + { + if ([user parent] && [[user parent] valueForKey:@"user"]) + { + createStatement = [NSString stringWithFormat:@"CREATE USER %@@%@", + [[[user parent] valueForKey:@"user"] tickQuotedString], + [[user valueForKey:@"host"] tickQuotedString]]; + } + } + + if (createStatement) + { + // Create user in database + [self.mySqlConnection queryString:createStatement]; + + if ([self checkAndDisplayMySqlError]) + [self grantPrivilegesToUser:user]; + } } return YES; |