コード例 #1
0
ファイル: edituser.php プロジェクト: kanbang/Colt
     $groupsNotSelected = $_POST[$groupsNotSelectedID];
 }
 // Validate inputs.
 if (empty($userName)) {
     throw new Exception($errUserNameMissing);
 }
 if ((!empty($password) || !empty($passwordConfirmation)) && $password != $passwordConfirmation) {
     throw new Exception($errPasswordConfirmationFailed);
 }
 // Update parameters of user.
 $site->UpdateUser($userID, "", $userName, $password, $description);
 // Create MgStringCollection with just one user to update group memberships.
 $userToUpdate = new MgStringCollection();
 $userToUpdate->Add($userID);
 // Get old list of groups for user
 $oldGroupMemberships = GetGroupMemberships($userID);
 // Find group memberships to revoke.
 $revokeList = array_diff($oldGroupMemberships, $groupsSelected);
 if ($revokeList != null && !empty($revokeList)) {
     $groupMembershipsToRevoke = new MgStringCollection();
     foreach ($revokeList as $groupToRevoke) {
         $groupMembershipsToRevoke->Add($groupToRevoke);
     }
     $site->RevokeGroupMembershipsFromUsers($groupMembershipsToRevoke, $userToUpdate);
 }
 // Find new group memberships to grant.
 $grantList = array_diff($groupsSelected, $oldGroupMemberships);
 if ($grantList != null && !empty($grantList)) {
     $groupMembershipsToGrant = new MgStringCollection();
     foreach ($grantList as $groupToGrant) {
         $groupMembershipsToGrant->Add($groupToGrant);
コード例 #2
0
ファイル: serverdatafunctions.php プロジェクト: kanbang/Colt
function GetDataForUser($userKey, $includeGroups)
{
    $users = GetUserData();
    if (!array_key_exists($userKey, $users)) {
        return NULL;
    }
    $userVal = $users[$userKey];
    if ($includeGroups) {
        $userVal->groups = GetGroupMemberships($userKey);
    }
    return $userVal;
}