diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPUserManager.h | 1 | ||||
-rw-r--r-- | Source/SPUserManager.m | 33 | ||||
-rw-r--r-- | Source/SPUserManager.xcdatamodel/elements | bin | 131784 -> 132168 bytes | |||
-rw-r--r-- | Source/SPUserManager.xcdatamodel/layout | bin | 9663 -> 9663 bytes |
4 files changed, 30 insertions, 4 deletions
diff --git a/Source/SPUserManager.h b/Source/SPUserManager.h index e6eedf50..aa6cce76 100644 --- a/Source/SPUserManager.h +++ b/Source/SPUserManager.h @@ -101,6 +101,7 @@ - (BOOL)insertUsers:(NSArray *)insertedUsers; - (BOOL)deleteUsers:(NSArray *)deletedUsers; - (BOOL)updateUsers:(NSArray *)updatedUsers; +- (BOOL)updateResourcesForUser:(NSManagedObject *)user; - (BOOL)grantPrivilegesToUser:(NSManagedObject *)user; - (BOOL)grantDbPrivilegesWithPrivilege:(NSManagedObject *)user; 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 diff --git a/Source/SPUserManager.xcdatamodel/elements b/Source/SPUserManager.xcdatamodel/elements Binary files differindex 22c2c418..d9f1e943 100644 --- a/Source/SPUserManager.xcdatamodel/elements +++ b/Source/SPUserManager.xcdatamodel/elements diff --git a/Source/SPUserManager.xcdatamodel/layout b/Source/SPUserManager.xcdatamodel/layout Binary files differindex 60630b61..7e8fd9cf 100644 --- a/Source/SPUserManager.xcdatamodel/layout +++ b/Source/SPUserManager.xcdatamodel/layout |