當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Ticket_User::change_permission方法代碼示例

本文整理匯總了PHP中Ticket_User::change_permission方法的典型用法代碼示例。如果您正苦於以下問題:PHP Ticket_User::change_permission方法的具體用法?PHP Ticket_User::change_permission怎麽用?PHP Ticket_User::change_permission使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Ticket_User的用法示例。


在下文中一共展示了Ticket_User::change_permission方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: change_permission

/**
* This function is beign used to change the permission of a ticket_user.
* It will first check if the user who executed this function is an admin. If this is not the case the page will be redirected to an error page.
* in case the $_GET['value'] is smaller than 4 and the user whoes permission is being changed is different from the admin(id 1), the change will be executed and the page will
* redirect to the users profile page.
* @author Daan Janssens, mentored by Matthew Lagoe
*/
function change_permission()
{
    global $INGAME_WEBPATH;
    global $WEBPATH;
    //if logged in
    if (WebUsers::isLoggedIn()) {
        //check if user who executed this function is an admin
        if (ticket_user::isAdmin(unserialize($_SESSION['ticket_user']))) {
            //in case the $_GET['value'] is smaller than 4 and the user whoes permission is being changed is different from the admin(id 1)
            if (isset($_GET['user_id']) && isset($_GET['value']) && $_GET['user_id'] != 1 && $_GET['value'] < 4) {
                $user_id = filter_var($_GET['user_id'], FILTER_SANITIZE_NUMBER_INT);
                $value = filter_var($_GET['value'], FILTER_SANITIZE_NUMBER_INT);
                //execute change.
                Ticket_User::change_permission(Ticket_User::constr_ExternId($user_id)->getTUserId(), $value);
                header("Cache-Control: max-age=1");
                if (Helpers::check_if_game_client()) {
                    header("Location: " . $INGAME_WEBPATH . "?page=show_user&id=" . $user_id);
                } else {
                    header("Location: " . $WEBPATH . "?page=show_user&id=" . $user_id);
                }
                throw new SystemExit();
            } else {
                //ERROR: GET PARAMS not given or trying to change admin
                header("Cache-Control: max-age=1");
                if (Helpers::check_if_game_client()) {
                    header("Location: " . $INGAME_WEBPATH . "?page=show_user&id=" . $user_id);
                } else {
                    header("Location: " . $WEBPATH . "?page=show_user&id=" . $user_id);
                }
                throw new SystemExit();
            }
        } else {
            //ERROR: No access!
            $_SESSION['error_code'] = "403";
            header("Cache-Control: max-age=1");
            header("Location: index.php?page=error");
            throw new SystemExit();
        }
    } else {
        //ERROR: not logged in!
        header("Cache-Control: max-age=1");
        header("Location: index.php");
        throw new SystemExit();
    }
}
開發者ID:cls1991,項目名稱:ryzomcore,代碼行數:52,代碼來源:change_permission.php


注:本文中的Ticket_User::change_permission方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。