aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPUserManager.m
diff options
context:
space:
mode:
Diffstat (limited to 'Source/SPUserManager.m')
-rw-r--r--Source/SPUserManager.m46
1 files changed, 31 insertions, 15 deletions
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;