2013-07-08 15:14:03 +00:00
|
|
|
<?php
|
2013-09-13 22:39:03 +00:00
|
|
|
/**
|
|
|
|
* This function is beign used to load info that's needed for the show_user page.
|
|
|
|
* Users can only browse their own user page, while mods/admins can browse all user pages. The current settings of the user being browsed will be loaded, as also their created tickets
|
|
|
|
* and this info will be returned so it can be used by the template.
|
|
|
|
* @author Daan Janssens, mentored by Matthew Lagoe
|
|
|
|
*/
|
2013-07-08 15:14:03 +00:00
|
|
|
function show_user(){
|
|
|
|
//if logged in
|
|
|
|
if(WebUsers::isLoggedIn()){
|
2013-09-13 22:39:03 +00:00
|
|
|
|
|
|
|
//Users can only browse their own user page, while mods/admins can browse all user pages
|
2013-09-09 01:47:32 +00:00
|
|
|
if( !isset($_GET['id']) || Ticket_User::isMod(unserialize($_SESSION['ticket_user'])) || $_GET['id'] == $_SESSION['id'] ){
|
2013-07-08 15:14:03 +00:00
|
|
|
|
|
|
|
if(isset($_GET['id'])){
|
|
|
|
$result['target_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
|
|
|
|
}else{
|
|
|
|
$result['target_id'] = $_SESSION['id'];
|
|
|
|
}
|
2013-08-05 15:31:36 +00:00
|
|
|
$webUser = new WebUsers($result['target_id']);
|
|
|
|
$result['target_name'] = $webUser->getUsername();
|
|
|
|
$result['mail'] = $webUser->getEmail();
|
|
|
|
$info = $webUser->getInfo();
|
2013-07-08 15:14:03 +00:00
|
|
|
$result['firstName'] = $info['FirstName'];
|
|
|
|
$result['lastName'] = $info['LastName'];
|
|
|
|
$result['country'] = $info['Country'];
|
|
|
|
$result['gender'] = $info['Gender'];
|
|
|
|
|
2013-07-10 10:36:14 +00:00
|
|
|
$ticket_user = Ticket_User::constr_ExternId($result['target_id']);
|
2013-07-18 22:37:47 +00:00
|
|
|
$result['userPermission'] = $ticket_user->getPermission();
|
2013-09-09 01:47:32 +00:00
|
|
|
if(Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){
|
2013-07-19 01:05:12 +00:00
|
|
|
$result['isAdmin'] = "TRUE";
|
|
|
|
}
|
2013-07-10 10:36:14 +00:00
|
|
|
$ticketlist = Ticket::getTicketsOf($ticket_user->getTUserId());
|
2013-07-08 23:03:49 +00:00
|
|
|
|
2013-07-11 00:39:52 +00:00
|
|
|
$result['ticketlist'] = Gui_Elements::make_table($ticketlist, Array("getTId","getTimestamp","getTitle","getStatus","getStatusText","getStatusText","getCategoryName"), Array("tId","timestamp","title","status","statustext","statusText","category"));
|
2013-09-09 01:47:32 +00:00
|
|
|
global $INGAME_WEBPATH;
|
|
|
|
$result['ingame_webpath'] = $INGAME_WEBPATH;
|
2013-07-08 15:14:03 +00:00
|
|
|
return $result;
|
|
|
|
|
|
|
|
}else{
|
|
|
|
//ERROR: No access!
|
|
|
|
$_SESSION['error_code'] = "403";
|
|
|
|
header("Location: index.php?page=error");
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
//ERROR: not logged in!
|
|
|
|
header("Location: index.php");
|
|
|
|
exit;
|
|
|
|
}
|
2013-09-09 01:47:32 +00:00
|
|
|
}
|