exists() public method

Whether the user type exists or not
public exists ( ) : boolean
return boolean $this->m_exists TRUE on success, FALSE on failure
Ejemplo n.º 1
0
    /**
     * Set the user to the given user type.
     *
     * @param string $p_userType
     *
     * @return void
     */
    public function setUserType($p_userTypeId)
    {
        global $g_ado_db, $LiveUserAdmin;

        if (!$this->exists() || !is_numeric($p_userTypeId)) {
            return;
        }

        // if current user type is the same as p_userTypeId, do nothing
        if ($this->getUserType() == $p_userTypeId) {
            return;
        }

        // fetch the given user type
        $userType = new UserType($p_userTypeId);
        if ($userType->exists()) {
            // delete permissions at user level if any
            $queryStr = 'DELETE FROM liveuser_userrights '
                       .'WHERE perm_user_id = '.$this->getPermUserId();
            $g_ado_db->Execute($queryStr);
            // current user type is different than p_userTypeId
            if ($this->getUserType() != $p_userTypeId) {
                $filter = array('group_id' => $this->getUserType(),
                                'perm_user_id' => $this->getPermUserId());
                $LiveUserAdmin->perm->removeUserFromGroup($filter);
            }
            // add this user to the given user type
            $data = array('group_id' => $p_userTypeId,
                          'perm_user_id' => $this->getPermUserId());
            $LiveUserAdmin->perm->addUserToGroup($data);

            // update the user type in the user table
            $this->setProperty('fk_user_type', $p_userTypeId);
            $this->fetch();

            if (function_exists("camp_load_translation_strings")) {
                camp_load_translation_strings("api");
            }
            $logtext = getGS('User permissions for "$1" ($2) changed', $this->m_data['Name'], $this->m_data['UName']);
            Log::Message($logtext, null, 55);
        }
    } // fn setUserType
Ejemplo n.º 2
0
if (!SecurityToken::isValid()) {
    camp_html_display_error(getGS('Invalid security token!'));
    exit;
}

$canManage = $g_user->hasPermission('ManageUserTypes');
if (!$canManage) {
	$error = getGS("You do not have the right to delete user types.");
	camp_html_display_error($error);
	exit;
}

$uTypeId = Input::Get('UType', 'string', '');
if (is_numeric($uTypeId) && $uTypeId > 0) {
	$userType = new UserType($uTypeId);
	if (!$userType->exists()) {
		camp_html_display_error(getGS('No such user type.'));
		exit;
	}
	$userType->delete();
} else {
	camp_html_display_error(getGS('No such user type.'));
	exit;
}

$msg = getGS("User Type '$1' successfully deleted", $userType->getName());
camp_html_add_msg($msg, 'ok');
camp_html_goto_page("/$ADMIN/user_types/");

?>
Ejemplo n.º 3
0
 /**
  * Set the user to the given user type.
  *
  * @param string $p_userType
  *
  * @return void
  */
 public function setUserType($p_userTypeId)
 {
     global $g_ado_db, $LiveUserAdmin;
     if (!$this->exists() || !is_numeric($p_userTypeId)) {
         return;
     }
     // if current user type is the same as p_userTypeId, do nothing
     if ($this->getUserType() == $p_userTypeId) {
         return;
     }
     // fetch the given user type
     $userType = new UserType($p_userTypeId);
     if ($userType->exists()) {
         // delete permissions at user level if any
         $queryStr = 'DELETE FROM liveuser_userrights ' . 'WHERE perm_user_id = ' . $this->getPermUserId();
         $g_ado_db->Execute($queryStr);
         // current user type is different than p_userTypeId
         if ($this->getUserType() != $p_userTypeId) {
             $filter = array('group_id' => $this->getUserType(), 'perm_user_id' => $this->getPermUserId());
             $LiveUserAdmin->perm->removeUserFromGroup($filter);
         }
         // add this user to the given user type
         $data = array('group_id' => $p_userTypeId, 'perm_user_id' => $this->getPermUserId());
         $LiveUserAdmin->perm->addUserToGroup($data);
         // update the user type in the user table
         $this->setProperty('fk_user_type', $p_userTypeId);
         $this->fetch();
     }
 }