aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Interfaces/English.lproj/UserManagerView.xib12
-rw-r--r--Source/SPUserManager.h1
-rw-r--r--Source/SPUserManager.m46
3 files changed, 43 insertions, 16 deletions
diff --git a/Interfaces/English.lproj/UserManagerView.xib b/Interfaces/English.lproj/UserManagerView.xib
index 3b53174d..890d5dc7 100644
--- a/Interfaces/English.lproj/UserManagerView.xib
+++ b/Interfaces/English.lproj/UserManagerView.xib
@@ -3966,6 +3966,14 @@
</object>
<int key="connectionID">892</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">userNameTextField</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="1021720165"/>
+ </object>
+ <int key="connectionID">893</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -5521,7 +5529,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">892</int>
+ <int key="maxID">893</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -5658,6 +5666,7 @@
<string>schemasTableView</string>
<string>tabView</string>
<string>treeController</string>
+ <string>userNameTextField</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -5673,6 +5682,7 @@
<string>NSTableView</string>
<string>NSTabView</string>
<string>NSTreeController</string>
+ <string>NSTextField</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
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;