aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/SPUserManager.m51
1 files changed, 41 insertions, 10 deletions
diff --git a/Source/SPUserManager.m b/Source/SPUserManager.m
index 6594d75f..cb49c084 100644
--- a/Source/SPUserManager.m
+++ b/Source/SPUserManager.m
@@ -1232,7 +1232,41 @@
#pragma mark -
#pragma mark Tab View Delegate methods
+- (BOOL)tabView:(NSTabView *)tabView shouldSelectTabViewItem:(NSTabViewItem *)tabViewItem
+{
+ BOOL retVal = YES;
+ // If there aren't any selected objects, then can't change tab view item
+ if ([[treeController selectedObjects] count] == 0) return NO;
+
+ // Currently selected object in tree
+ id selectedObject = [[treeController selectedObjects] objectAtIndex:0];
+
+ // If we are selecting a tab view that requires there be a child,
+ // make sure there is a child to select. If not, don't allow it.
+ if ([[tabViewItem identifier] isEqualToString:@"Global Privileges"]
+ || [[tabViewItem identifier] isEqualToString:@"Resources"]
+ || [[tabViewItem identifier] isEqualToString:@"Schema Privileges"]) {
+ id parent = [selectedObject parent];
+ if (parent) {
+ retVal = ([[parent children] count] > 0);
+ } else {
+ retVal = ([[selectedObject children] count] > 0);
+ }
+ if (retVal == NO) {
+ NSAlert *alert = [NSAlert alertWithMessageText:@"User doesn't have any hosts."
+ defaultButton:@"Add Host"
+ alternateButton:NSLocalizedString(@"Cancel", @"cancel button")
+ otherButton:nil
+ informativeTextWithFormat:@"This user doesn't have any hosts associated with it. User will be deleted unless one is added"];
+ NSInteger ret = [alert runModal];
+ if (ret == NSAlertDefaultReturn) {
+ [self addHost:nil];
+ }
+ }
+ }
+ return retVal;
+}
-(void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem
{
if ([[treeController selectedObjects] count] == 0) return;
@@ -1255,6 +1289,13 @@
}
}
+- (void)tabView:(NSTabView *)usersTabView willSelectTabViewItem:(NSTabViewItem *)tabViewItem
+{
+ if ([[tabViewItem identifier] isEqualToString:@"Schema Privileges"]) {
+ [self _initializeSchemaPrivs];
+ }
+}
+
#pragma mark -
#pragma mark SplitView delegate methods
@@ -1347,16 +1388,6 @@
}
#pragma mark -
-#pragma mark Tab view delegate methods
-
-- (void)tabView:(NSTabView *)usersTabView willSelectTabViewItem:(NSTabViewItem *)tabViewItem
-{
- if ([[tabViewItem identifier] isEqualToString:@"Schema Privileges"]) {
- [self _initializeSchemaPrivs];
- }
-}
-
-#pragma mark -
/**
* Dealloc. Get rid of everything.