コード例 #1
0
ファイル: support_group.php プロジェクト: ryzom/ryzomcore
 /**
  * wrapper for adding a user to a specified support group.
  * We will first check if the group really exists, if not than "GROUP_NOT_EXISING" will be returned.
  * Afterwards we will check if the user exists in the support group, if so "ALREADY_ADDED" will be returned.
  * Else the user will be added to the in_support_group table and "SUCCESS" will be returned.
  * @param $user_id the id of the user we want to add to the group.
  * @param $group_id the id of the group the user wants to be in
  * @return a string (SUCCESS, ALREADY_ADDED or GROUP_NOT_EXISTING)
  */
 public static function addUserToSupportGroup($user_id, $group_id)
 {
     //check if group id exists
     if (self::supportGroup_Exists($group_id)) {
         //check if user isn't in supportgroup yet
         //if not, create entry and return SUCCESS
         if (!In_Support_Group::userExistsInSGroup($user_id, $group_id)) {
             //create entry
             $inSGroup = new In_Support_Group();
             $inSGroup->setUser($user_id);
             $inSGroup->setGroup($group_id);
             $inSGroup->create();
             return "SUCCESS";
         } else {
             //else return ALREADY_ADDED
             return "ALREADY_ADDED";
         }
     } else {
         //return that group doesn't exist
         return "GROUP_NOT_EXISTING";
     }
 }
コード例 #2
0
ファイル: show_sgroup.php プロジェクト: cls1991/ryzomcore
/**
* This function is beign used to load info that's needed for the show_sgroup page.
* check if the person browsing this page is a mod/admin, if not he'll be redirected to an error page.
* if the $_GET['delete'] var is set and the user executing is an admin, an entry will be deleted out of the support group.
* A list of users that are member of the group will be returned, which can be used by the template.
* @author Daan Janssens, mentored by Matthew Lagoe
*/
function show_sgroup()
{
    global $INGAME_WEBPATH;
    global $WEBPATH;
    //if logged in
    if (WebUsers::isLoggedIn()) {
        if (Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) {
            if (isset($_GET['id'])) {
                //['target_id'] holds the id of the group!
                $result['target_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
                //if the $_GET['delete'] var is set and the user executing is an admin, an entry will be deleted out of the support group.
                if (isset($_GET['delete']) && Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))) {
                    $delete_id = filter_var($_GET['delete'], FILTER_SANITIZE_NUMBER_INT);
                    $result['delete'] = Support_Group::deleteUserOfSupportGroup($delete_id, $result['target_id']);
                    header("Cache-Control: max-age=1");
                    if (Helpers::check_if_game_client()) {
                        header("Location: " . $INGAME_WEBPATH . "?page=show_sgroup&id=" . $result['target_id']);
                    } else {
                        header("Location: " . $WEBPATH . "?page=show_sgroup&id=" . $result['target_id']);
                    }
                    throw new SystemExit();
                }
                if (Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))) {
                    $result['isAdmin'] = "TRUE";
                }
                $group = Support_Group::getGroup($result['target_id']);
                $result['groupsname'] = $group->getName();
                $result['groupemail'] = $group->getGroupEmail();
                $result['imap_mailserver'] = $group->getIMAP_MailServer();
                $result['imap_username'] = $group->getIMAP_Username();
                $result['userlist'] = Gui_Elements::make_table(Support_Group::getAllUsersOfSupportGroup($result['target_id']), array("getTUserId", "getPermission", "getExternId"), array("tUserId", "permission", "externId"));
                $i = 0;
                foreach ($result['userlist'] as $user) {
                    $webuser = new Webusers($user['externId']);
                    $result['userlist'][$i]['name'] = $webuser->getUsername();
                    $i++;
                }
                global $INGAME_WEBPATH;
                $result['ingame_webpath'] = $INGAME_WEBPATH;
                $result['teamlist'] = Gui_Elements::make_table(Ticket_User::getModsAndAdmins(), array("getTUserId", "getExternId"), array("tUserId", "externId"));
                $i = 0;
                foreach ($result['teamlist'] as $member) {
                    $web_teammember = new Webusers($member['externId']);
                    if (!In_Support_Group::userExistsInSGroup($member['externId'], $result['target_id'])) {
                        $result['users'][$i]['name'] = $web_teammember->getUsername();
                    }
                    $i++;
                }
                return $result;
            } else {
                //ERROR: No page specified!
                $_SESSION['error_code'] = "404";
                header("Cache-Control: max-age=1");
                header("Location: ams?page=error");
                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();
    }
}