aboutsummaryrefslogtreecommitdiffstats
path: root/Source
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
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')
-rw-r--r--Source/SPUserManager.h1
-rw-r--r--Source/SPUserManager.m33
-rw-r--r--Source/SPUserManager.xcdatamodel/elementsbin131784 -> 132168 bytes
-rw-r--r--Source/SPUserManager.xcdatamodel/layoutbin9663 -> 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
index 22c2c418..d9f1e943 100644
--- a/Source/SPUserManager.xcdatamodel/elements
+++ b/Source/SPUserManager.xcdatamodel/elements
Binary files differ
diff --git a/Source/SPUserManager.xcdatamodel/layout b/Source/SPUserManager.xcdatamodel/layout
index 60630b61..7e8fd9cf 100644
--- a/Source/SPUserManager.xcdatamodel/layout
+++ b/Source/SPUserManager.xcdatamodel/layout
Binary files differ