2013-07-16 02:58:54 +00:00
|
|
|
<?php
|
2013-09-13 22:39:03 +00:00
|
|
|
/**
|
|
|
|
* This function is beign used to add a user to a support group.
|
|
|
|
* It will first check if the user who executed this function is an admin. If the user exists it will try to add it to the supportgroup, in case it's not a mod or admin it will not
|
|
|
|
* add it to the group. if the executing user is not an admin or not logged in, the page will be redirected to the error page.
|
|
|
|
* @author Daan Janssens, mentored by Matthew Lagoe
|
|
|
|
*/
|
2013-07-16 02:58:54 +00:00
|
|
|
function add_user_to_sgroup(){
|
2013-09-09 01:47:32 +00:00
|
|
|
global $INGAME_WEBPATH;
|
|
|
|
global $WEBPATH;
|
2013-07-16 02:58:54 +00:00
|
|
|
if(WebUsers::isLoggedIn()){
|
2014-09-03 05:06:43 +00:00
|
|
|
|
2013-09-13 22:39:03 +00:00
|
|
|
//check if the that executed the task is an admin.
|
2013-09-09 01:47:32 +00:00
|
|
|
if( Ticket_User::isAdmin(unserialize($_SESSION['ticket_user'])) && isset($_POST['target_id'])){
|
2013-07-16 02:58:54 +00:00
|
|
|
$name = filter_var($_POST['Name'],FILTER_SANITIZE_STRING);
|
|
|
|
$id = filter_var($_POST['target_id'],FILTER_SANITIZE_NUMBER_INT);
|
|
|
|
$user_id = WebUsers::getId($name);
|
|
|
|
if ($user_id != ""){
|
2013-09-13 22:39:03 +00:00
|
|
|
//if the target user is a mod/admin
|
2013-07-19 09:56:39 +00:00
|
|
|
if (Ticket_User::constr_ExternId($user_id)->getPermission()>1){
|
2013-09-13 22:39:03 +00:00
|
|
|
//add it to the support group
|
2013-07-19 09:56:39 +00:00
|
|
|
$result['RESULT_OF_ADDING'] = Support_Group::addUserToSupportGroup($user_id, $id);
|
|
|
|
}else{
|
2013-09-13 22:39:03 +00:00
|
|
|
//return error message.
|
2013-07-19 09:56:39 +00:00
|
|
|
$result['RESULT_OF_ADDING'] = "NOT_MOD_OR_ADMIN";
|
|
|
|
}
|
2014-09-03 05:06:43 +00:00
|
|
|
|
2013-07-16 02:58:54 +00:00
|
|
|
}else{
|
|
|
|
$result['RESULT_OF_ADDING'] = "USER_NOT_EXISTING";
|
|
|
|
}
|
2013-09-13 22:39:03 +00:00
|
|
|
//$result['permission'] = unserialize($_SESSION['ticket_user'])->getPermission();
|
|
|
|
//$result['no_visible_elements'] = 'FALSE';
|
|
|
|
//$result['username'] = $_SESSION['user'];
|
2013-09-09 01:47:32 +00:00
|
|
|
//global $SITEBASE;
|
|
|
|
//require_once($SITEBASE . 'inc/show_sgroup.php');
|
|
|
|
//$result= array_merge($result, show_sgroup());
|
|
|
|
//helpers :: loadtemplate( 'show_sgroup', $result);
|
|
|
|
if (Helpers::check_if_game_client()) {
|
|
|
|
header("Location: ".$INGAME_WEBPATH."?page=show_sgroup&id=".$id);
|
|
|
|
}else{
|
|
|
|
header("Location: ".$WEBPATH."?page=show_sgroup&id=".$id);
|
|
|
|
}
|
2014-09-03 05:06:43 +00:00
|
|
|
die();
|
|
|
|
|
2013-07-16 02:58:54 +00:00
|
|
|
}else{
|
|
|
|
//ERROR: No access!
|
|
|
|
$_SESSION['error_code'] = "403";
|
|
|
|
header("Location: index.php?page=error");
|
2014-09-03 05:06:43 +00:00
|
|
|
die();
|
2013-07-16 02:58:54 +00:00
|
|
|
}
|
|
|
|
}else{
|
|
|
|
//ERROR: not logged in!
|
|
|
|
header("Location: index.php");
|
2014-09-03 05:06:43 +00:00
|
|
|
die();
|
2013-07-16 02:58:54 +00:00
|
|
|
}
|
|
|
|
|
2014-09-03 05:06:43 +00:00
|
|
|
}
|