Linux multi-monitor fullscreen support
[ryzomcore.git] / web / public_php / ams / func / add_sgroup.php
blobca71417315fe2303ae959a07f30c41b05d71f059
1 <?php
2 /**
3 * This function is beign used to add a new Support Group to the database.
4 * What it will do is check if the user who executed the function is an Admin, if so then it will filter all POST'ed data and use it to create a new Support_Group entry.
5 * if not logged in or not an admin, an appropriate redirection to an error page will take place.
6 * @author Daan Janssens, mentored by Matthew Lagoe
7 */
8 function add_sgroup(){
9 global $INGAME_WEBPATH;
10 global $WEBPATH;
11 if(WebUsers::isLoggedIn()){
13 //check if admin
14 if( Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){
15 $name = filter_var($_POST['Name'],FILTER_SANITIZE_STRING);
16 $inner_tag = filter_var($_POST['Tag'], FILTER_SANITIZE_STRING);
17 $tag = "[" . $inner_tag . "]";
18 $inner_tag = filter_var($_POST['Tag'], FILTER_SANITIZE_STRING);
19 $groupemail = filter_var($_POST['GroupEmail'], FILTER_SANITIZE_STRING);
20 $imap_mailserver = filter_var($_POST['IMAP_MailServer'], FILTER_SANITIZE_STRING);
21 $imap_username = filter_var($_POST['IMAP_Username'], FILTER_SANITIZE_STRING);
22 $imap_password = filter_var($_POST['IMAP_Password'], FILTER_SANITIZE_STRING);
24 //create a new support group
25 $result['RESULT_OF_ADDING'] = Support_Group::createSupportGroup($name, $tag, $groupemail, $imap_mailserver, $imap_username, $imap_password);
26 $result['permission'] = unserialize($_SESSION['ticket_user'])->getPermission();
27 $result['no_visible_elements'] = 'FALSE';
28 $result['username'] = $_SESSION['user'];
29 global $SITEBASE;
30 require($SITEBASE . '/inc/sgroup_list.php');
31 $result= array_merge($result, sgroup_list());
32 return $result;
33 header("Cache-Control: max-age=1");
34 /*if (Helpers::check_if_game_client()) {
35 header("Location: ".$INGAME_WEBPATH."?page=sgroup_list");
36 }else{
37 header("Location: ".$WEBPATH."?page=sgroup_list");
39 exit;
41 }else{
42 //ERROR: No access!
43 $_SESSION['error_code'] = "403";
44 header("Cache-Control: max-age=1");
45 header("Location: index.php?page=error");
46 throw new SystemExit();
48 }else{
49 //ERROR: not logged in!
50 header("Cache-Control: max-age=1");
51 header("Location: index.php");
52 throw new SystemExit();