@@ -221,20 +221,24 @@ - (void)_initializeUsers
221
221
*/
222
222
- (void )_initializeTree : (NSArray *)items
223
223
{
224
-
225
224
// Retrieve all the user data in order to be able to initialise the schema privs for each child,
226
225
// copying into a dictionary keyed by user, each with all the host rows.
227
226
NSMutableDictionary *schemaPrivilegeData = [NSMutableDictionary dictionary ];
228
227
SPMySQLResult *queryResults = [connection queryString: @" SELECT * FROM mysql.db" ];
228
+
229
229
[queryResults setReturnDataAsStrings: YES ];
230
- for (NSDictionary *privRow in queryResults) {
230
+
231
+ for (NSDictionary *privRow in queryResults)
232
+ {
231
233
if (![schemaPrivilegeData objectForKey: [privRow objectForKey: @" User" ]]) {
232
234
[schemaPrivilegeData setObject: [NSMutableArray array ] forKey: [privRow objectForKey: @" User" ]];
233
235
}
236
+
234
237
[[schemaPrivilegeData objectForKey: [privRow objectForKey: @" User" ]] addObject: privRow];
235
238
236
239
// If "all database" values were found, add them to the schemas list if not already present
237
240
NSString *schemaName = [privRow objectForKey: @" Db" ];
241
+
238
242
if ([schemaName isEqualToString: @" " ] || [schemaName isEqualToString: @" %" ]) {
239
243
if (![schemas containsObject: schemaName]) {
240
244
[schemas addObject: schemaName];
@@ -269,11 +273,20 @@ - (void)_initializeTree:(NSArray *)items
269
273
// original values for comparison purposes
270
274
[parent setPrimitiveValue: username forKey: @" user" ];
271
275
[parent setPrimitiveValue: username forKey: @" originaluser" ];
272
- if (requiresPost576PasswordHandling) {
276
+
277
+ if (requiresPost576PasswordHandling) {
273
278
[parent setPrimitiveValue: [item objectForKey: @" plugin" ] forKey: @" plugin" ];
274
- NSString *pwHash = [item objectForKey: @" authentication_string" ];
275
- [parent setPrimitiveValue: pwHash forKey: @" authentication_string" ];
276
- if ([pwHash length ]) [parent setPrimitiveValue: @" sequelpro_dummy_password" forKey: @" password" ]; // for the UI dialog
279
+
280
+ NSString *passwordHash = [item objectForKey: @" authentication_string" ];
281
+
282
+ if (![passwordHash isNSNull ]) {
283
+ [parent setPrimitiveValue: passwordHash forKey: @" authentication_string" ];
284
+
285
+ // for the UI dialog
286
+ if ([passwordHash length ]) {
287
+ [parent setPrimitiveValue: @" sequelpro_dummy_password" forKey: @" password" ];
288
+ }
289
+ }
277
290
}
278
291
else {
279
292
[parent setPrimitiveValue: [item objectForKey: @" Password" ] forKey: @" password" ];
@@ -535,7 +548,6 @@ - (IBAction)doCancel:(id)sender
535
548
*/
536
549
- (IBAction )doApply : (id )sender
537
550
{
538
-
539
551
// If editing can't be committed, cancel the apply
540
552
if (![treeController commitEditing ]) {
541
553
return ;
@@ -953,6 +965,9 @@ - (void)contextDidChange:(NSNotification *)notification
953
965
if (!isInitializing) [outlineView reloadData ];
954
966
}
955
967
968
+ #pragma mark -
969
+ #pragma mark Core data notifications
970
+
956
971
- (BOOL )updateUser : (SPUserMO *)user
957
972
{
958
973
if (![user parent ]) {
@@ -1290,6 +1305,9 @@ - (BOOL)grantPrivilegesToUser:(SPUserMO *)user skippingRevoke:(BOOL)skipRevoke
1290
1305
return YES ;
1291
1306
}
1292
1307
1308
+ #pragma mark -
1309
+ #pragma mark Private API
1310
+
1293
1311
/* *
1294
1312
* Gets any NSManagedObject (SPUser) from the managedObjectContext that may
1295
1313
* already exist with the given username.
@@ -1446,9 +1464,6 @@ - (BOOL)_checkAndDisplayMySqlError
1446
1464
return YES ;
1447
1465
}
1448
1466
1449
- #pragma mark -
1450
- #pragma mark Private API
1451
-
1452
1467
/* *
1453
1468
* Renames a user account using the supplied parameters.
1454
1469
*
@@ -1511,7 +1526,6 @@ - (void)dealloc
1511
1526
{
1512
1527
[[NSNotificationCenter defaultCenter ] removeObserver: self ];
1513
1528
1514
-
1515
1529
SPClear (managedObjectContext);
1516
1530
SPClear (persistentStoreCoordinator);
1517
1531
SPClear (managedObjectModel);
0 commit comments