AddUser( $userID, $userName, $password, $description ); // Create MgStringCollection with just one user to update group memberships. $usersToUpdate = new MgStringCollection(); $usersToUpdate->Add( $userID ); // Grant group memberships. if ( !empty( $groupsSelected ) ) { $groupMembershipsToGrant = new MgStringCollection(); foreach ( $groupsSelected as $groupToGrant ) { if ( $groupToGrant != MgGroup::Everyone ) $groupMembershipsToGrant->Add( $groupToGrant ); } if ( $groupMembershipsToGrant->GetCount() > 0 ) $site->GrantGroupMembershipsToUsers( $groupMembershipsToGrant, $usersToUpdate ); } // Everything is OK. $confirmationMsg = sprintf( $confSuccessfulAddition, $userID ); $selectedUser = $userID; SaveSessionVars(); header( 'Location: usermanagement.php?'.strip_tags(SID) ); exit(); } } catch ( MgException $e ) { CheckForFatalMgException( $e ); $errorMsg = $e->GetMessage(); } catch ( Exception $e ) { $errorMsg = $e->getMessage(); } ?>
User ID :
User name :
Description:
Password:
Confirm password:
leadInStr = 'Member of'; $control->col1Name = $groupsNotSelectedID.'[]'; $control->col3Name = $groupsSelectedID.'[]'; $control->col1Heading = 'Available groups'; $control->col3Heading = 'Member of these groups'; $control->col1List = $groupsNotSelected; $control->enabled = true; $control->size = 10; // SPECIAL HANDLING FOR EVERYONE GROUP: // If the Everyone group is in the $groupsSelected list (which it should be), it requires special handling. // Membership in this group cannot be revoked and, so, it should not be selected. The preferrable UI is to // disable this option in the select control; however, the disable parameter is not recognized by all browsers // for the OPTION tag and is not always recognized in JavaScript for this tag as well. Therefore, the OnChange // parameter of the select control is used. With this an alert box is popped up when Everyone is selected and // the selection is reversed. // In addition, to suggest that the Everyone group should not be selected at all, it's display name is changed // from "Everyone" to "Everyone (Built-in group)". if ( in_array( MgGroup::Everyone, $groupsSelected ) ) { $control->col3List = array(); $control->col3Vals = array(); foreach( $groupsSelected as $selectedGroup ) { if ( $selectedGroup == MgGroup::Everyone ) { $control->col3List[] = $everyoneGroupSelectorLabel; $control->col3Vals[] = MgGroup::Everyone; } else { $control->col3List[] = $selectedGroup; $control->col3Vals[] = $selectedGroup; } } $control->col3OnChange = "DisableOption( '".$groupsSelectedID."[]', '".MgGroup::Everyone."', 'The Everyone group is built-in and, so, membership in this group cannot be removed.');"; } else $control->col3List = $groupsSelected; DisplayAddRemoveControl( $control ); DisplaySaveCancelBar(); ?>