aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPUserManager.m
diff options
context:
space:
mode:
authormltownsend <mltownsend@gmail.com>2010-05-21 19:49:59 +0000
committermltownsend <mltownsend@gmail.com>2010-05-21 19:49:59 +0000
commitbd78aaeadb8dfd0eb83a896727e6376109c12e22 (patch)
tree102239e90299f131bb26ed51b14feb90b5d510cd /Source/SPUserManager.m
parente935c634e4691be05787c201caf9eaa1a9d99fe3 (diff)
downloadsequelpro-bd78aaeadb8dfd0eb83a896727e6376109c12e22.tar.gz
sequelpro-bd78aaeadb8dfd0eb83a896727e6376109c12e22.tar.bz2
sequelpro-bd78aaeadb8dfd0eb83a896727e6376109c12e22.zip
Fields in Resources tab of User Manager actually will persist now.
Diffstat (limited to 'Source/SPUserManager.m')
-rw-r--r--Source/SPUserManager.m33
1 files changed, 29 insertions, 4 deletions
diff --git a/Source/SPUserManager.m b/Source/SPUserManager.m
index f0117045..f666f01c 100644
--- a/Source/SPUserManager.m
+++ b/Source/SPUserManager.m
@@ -753,7 +753,8 @@
return;
}
}
-
+ // Remove any selections.
+ [treeController removeSelectionIndexPaths:[treeController selectionIndexPaths]];
[self.managedObjectContext reset];
[grantedSchemaPrivs removeAllObjects];
[grantedTableView reloadData];
@@ -964,8 +965,12 @@
[self checkAndDisplayMySqlError];
}
}
+
+
} else {
- [self grantPrivilegesToUser:user];
+ [self updateResourcesForUser:user];
+ [self grantPrivilegesToUser:user];
+
}
}
@@ -1027,8 +1032,10 @@
// Create user in database
[self.mySqlConnection queryString:createStatement];
- if ([self checkAndDisplayMySqlError])
- [self grantPrivilegesToUser:user];
+ if ([self checkAndDisplayMySqlError]) {
+ [self updateResourcesForUser:user];
+ [self grantPrivilegesToUser:user];
+ }
}
}
@@ -1107,6 +1114,24 @@
}
/**
+ * Update resource limites for given user
+ */
+- (BOOL)updateResourcesForUser:(NSManagedObject *)user
+{
+ if ([user valueForKey:@"parent"] != nil) {
+ NSString *updateResourcesStatement = [NSString stringWithFormat:
+ @"UPDATE mysql.user SET max_questions=%@,max_updates=%@,max_connections=%@ WHERE User=%@ AND Host=%@",
+ [user valueForKey:@"max_questions"],
+ [user valueForKey:@"max_updates"],
+ [user valueForKey:@"max_connections"],
+ [[[user valueForKey:@"parent"] valueForKey:@"user"] tickQuotedString],
+ [[user valueForKey:@"host"] tickQuotedString]];
+ [self.mySqlConnection queryString:updateResourcesStatement];
+ [self checkAndDisplayMySqlError];
+
+ }
+}
+/**
* Grant or revoke privileges for the supplied user.
*/
- (BOOL)grantPrivilegesToUser:(NSManagedObject *)user