Linux multi-monitor fullscreen support
[ryzomcore.git] / web / public_php / ams / inc / show_sgroup.php
blob0ec446e4ce305533c70e13a292258f543fa14651
1 <?php
2 /**
3 * This function is beign used to load info that's needed for the show_sgroup page.
4 * check if the person browsing this page is a mod/admin, if not he'll be redirected to an error page.
5 * if the $_GET['delete'] var is set and the user executing is an admin, an entry will be deleted out of the support group.
6 * A list of users that are member of the group will be returned, which can be used by the template.
7 * @author Daan Janssens, mentored by Matthew Lagoe
8 */
9 function show_sgroup(){
10 global $INGAME_WEBPATH;
11 global $WEBPATH;
12 //if logged in
13 if(WebUsers::isLoggedIn()){
14 if(Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){
15 if( isset($_GET['id'])){
16 //['target_id'] holds the id of the group!
17 $result['target_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
19 //if the $_GET['delete'] var is set and the user executing is an admin, an entry will be deleted out of the support group.
20 if(isset($_GET['delete']) && Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){
21 $delete_id = filter_var($_GET['delete'], FILTER_SANITIZE_NUMBER_INT);
22 $result['delete'] = Support_Group::deleteUserOfSupportGroup( $delete_id, $result['target_id'] );
23 header("Cache-Control: max-age=1");
24 if (Helpers::check_if_game_client()) {
25 header("Location: ".$INGAME_WEBPATH."?page=show_sgroup&id=" . $result['target_id']);
26 }else{
27 header("Location: ".$WEBPATH."?page=show_sgroup&id=" . $result['target_id']);
29 throw new SystemExit();
33 if(Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){
34 $result['isAdmin'] = "TRUE";
37 $group = Support_Group::getGroup($result['target_id']);
38 $result['groupsname'] = $group->getName();
39 $result['groupemail'] = $group->getGroupEmail();
40 $result['imap_mailserver'] = $group->getIMAP_MailServer();
41 $result['imap_username'] = $group->getIMAP_Username();
42 $result['userlist'] = Gui_Elements::make_table(Support_Group::getAllUsersOfSupportGroup($result['target_id']), Array("getTUserId","getPermission","getExternId"), Array("tUserId","permission","externId"));
43 $i = 0;
44 foreach( $result['userlist'] as $user){
45 $webuser = new Webusers($user['externId']);
46 $result['userlist'][$i]['name'] = $webuser->getUsername();
47 $i++;
49 global $INGAME_WEBPATH;
50 $result['ingame_webpath'] = $INGAME_WEBPATH;
51 $result['teamlist'] = Gui_Elements::make_table(Ticket_User::getModsAndAdmins(), Array("getTUserId","getExternId"), Array("tUserId","externId"));
52 $i = 0;
53 foreach( $result['teamlist'] as $member){
54 $web_teammember = new Webusers($member['externId']);
55 if (!In_Support_Group::userExistsInSGroup($member['externId'], $result['target_id'])) {
56 $result['users'][$i]['name'] = $web_teammember->getUsername();
58 $i++;
61 return $result;
64 }else{
66 //ERROR: No page specified!
67 $_SESSION['error_code'] = "404";
68 header("Cache-Control: max-age=1");
69 header("Location: ams?page=error");
70 throw new SystemExit();
73 }else{
74 //ERROR: No access!
75 $_SESSION['error_code'] = "403";
76 header("Cache-Control: max-age=1");
77 header("Location: index.php?page=error");
78 throw new SystemExit();
80 }else{
81 //ERROR: not logged in!
82 header("Cache-Control: max-age=1");
83 header("Location: index.php");
84 throw new SystemExit();