Ejemplo n.º 1
0
            throw new Exception($errPasswordConfirmationFailed);
        }
        // Add new user.
        $site->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->GetExceptionMessage();
} catch (Exception $e) {
    $errorMsg = $e->getMessage();
Ejemplo n.º 2
0
 function DeleteUser($userId, $userName)
 {
     $user = new MgUserInformation(MG_ADMIN_USER, MG_ADMIN_PASSWD);
     $siteConnection = new MgSiteConnection();
     $siteConnection->Open($user);
     $users = new MgStringCollection();
     $users->Add($userName);
     if (!$users->GetCount()) {
         throw new Exception("User was not removed from MapGuide.");
     }
     $siteConnection->GetSite()->DeleteUsers($users);
     $success = $this->db->queryExec('DELETE FROM users WHERE userid =' . $userId . ';' . 'DELETE FROM user_prefs WHERE userid =' . $userId . ';');
     if ($success) {
         $userId = $this->db->lastInsertRowid();
         return $userId;
     } else {
         //couldn't create the user - not unique
         return FALSE;
     }
 }