2013-07-06 17:12:55 +00:00
|
|
|
<?php
|
2013-09-13 22:39:03 +00:00
|
|
|
/**
|
|
|
|
* This function is beign used to load info that's needed for the createticket page.
|
|
|
|
* the $_GET['user_id'] identifies for which user you try to create a ticket. A normal user can only create a ticket for himself, a mod/admin however can also create tickets for other users.
|
|
|
|
* It will also load all categories and return these, they will be used by the template.
|
|
|
|
* @author Daan Janssens, mentored by Matthew Lagoe
|
|
|
|
*/
|
2013-07-06 17:12:55 +00:00
|
|
|
function createticket(){
|
2013-07-06 20:38:57 +00:00
|
|
|
|
|
|
|
//if logged in
|
|
|
|
if(WebUsers::isLoggedIn()){
|
|
|
|
//in case user_id-GET param set it's value as target_id, if no user_id-param is given, use the session id.
|
|
|
|
if(isset($_GET['user_id'])){
|
|
|
|
|
2013-09-13 22:39:03 +00:00
|
|
|
//check if you are a mod/admin or you try to create a ticket for your own, if this is not the case redirect to error page
|
2013-09-09 01:47:32 +00:00
|
|
|
if(($_GET['user_id'] != $_SESSION['id']) && ( ! ticket_user::isMod(unserialize($_SESSION['ticket_user']))) ){
|
2013-07-06 20:38:57 +00:00
|
|
|
|
|
|
|
//ERROR: No access!
|
|
|
|
$_SESSION['error_code'] = "403";
|
|
|
|
header("Location: index.php?page=error");
|
|
|
|
exit;
|
|
|
|
|
|
|
|
}else{
|
|
|
|
//if user_id is given, then set it as the target_id
|
|
|
|
$result['target_id'] = filter_var($_GET['user_id'], FILTER_SANITIZE_NUMBER_INT);
|
|
|
|
}
|
|
|
|
|
|
|
|
}else{
|
|
|
|
//set session_id as target_id
|
|
|
|
$result['target_id'] = $_SESSION['id'];
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2013-08-28 00:24:08 +00:00
|
|
|
if(Helpers::check_if_game_client()){
|
|
|
|
//get all additional info, which is needed for adding the extra info page
|
|
|
|
$result[] = $_GET;
|
|
|
|
$result['ingame'] = true;
|
|
|
|
}
|
2013-07-06 20:38:57 +00:00
|
|
|
|
2013-08-28 00:24:08 +00:00
|
|
|
|
2013-07-06 20:38:57 +00:00
|
|
|
//create array of category id & names
|
2013-07-10 10:36:14 +00:00
|
|
|
$catArray = Ticket_Category::getAllCategories();
|
2013-07-09 14:34:43 +00:00
|
|
|
$result['category'] = Gui_Elements::make_table_with_key_is_id($catArray, Array("getName"), "getTCategoryId" );
|
2013-09-09 01:47:32 +00:00
|
|
|
global $INGAME_WEBPATH;
|
|
|
|
$result['ingame_webpath'] = $INGAME_WEBPATH;
|
2013-07-06 20:38:57 +00:00
|
|
|
return $result;
|
2013-07-06 17:12:55 +00:00
|
|
|
|
2013-07-06 20:38:57 +00:00
|
|
|
}else{
|
|
|
|
//ERROR: not logged in!
|
|
|
|
header("Location: index.php");
|
|
|
|
exit;
|
2013-07-06 17:12:55 +00:00
|
|
|
}
|
2013-07-06 20:38:57 +00:00
|
|
|
|
2013-07-06 17:12:55 +00:00
|
|
|
}
|