khanat-opennel-code/code/web/public_php/ams/inc/show_user.php

55 lines
2.4 KiB
PHP
Raw Normal View History

2014-08-18 23:57:20 +00:00
<?php
/**
* 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
*/
function show_user(){
//if logged in
if(WebUsers::isLoggedIn()){
2014-09-03 18:27:01 +00:00
2014-08-18 23:57:20 +00:00
//Users can only browse their own user page, while mods/admins can browse all user pages
if( !isset($_GET['id']) || Ticket_User::isMod(unserialize($_SESSION['ticket_user'])) || $_GET['id'] == $_SESSION['id'] ){
2014-09-03 18:27:01 +00:00
2014-08-18 23:57:20 +00:00
if(isset($_GET['id'])){
2014-09-03 18:27:01 +00:00
$result['target_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
2014-08-18 23:57:20 +00:00
}else{
2014-09-03 18:27:01 +00:00
$result['target_id'] = $_SESSION['id'];
2014-08-18 23:57:20 +00:00
}
$webUser = new WebUsers($result['target_id']);
$result['target_name'] = $webUser->getUsername();
$result['mail'] = $webUser->getEmail();
$info = $webUser->getInfo();
$result['firstName'] = $info['FirstName'];
$result['lastName'] = $info['LastName'];
$result['country'] = $info['Country'];
$result['gender'] = $info['Gender'];
2014-09-03 18:27:01 +00:00
2014-08-18 23:57:20 +00:00
$ticket_user = Ticket_User::constr_ExternId($result['target_id']);
$result['userPermission'] = $ticket_user->getPermission();
if(Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){
$result['isAdmin'] = "TRUE";
}
$ticketlist = Ticket::getTicketsOf($ticket_user->getTUserId());
2014-09-03 18:27:01 +00:00
2014-08-18 23:57:20 +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"));
global $INGAME_WEBPATH;
$result['ingame_webpath'] = $INGAME_WEBPATH;
return $result;
2014-09-03 18:27:01 +00:00
2014-08-18 23:57:20 +00:00
}else{
//ERROR: No access!
$_SESSION['error_code'] = "403";
2014-09-03 18:27:01 +00:00
header("Cache-Control: max-age=1");
2014-08-18 23:57:20 +00:00
header("Location: index.php?page=error");
2014-09-03 18:27:01 +00:00
throw new SystemExit();
2014-08-18 23:57:20 +00:00
}
}else{
//ERROR: not logged in!
2014-09-03 18:27:01 +00:00
header("Cache-Control: max-age=1");
2014-08-18 23:57:20 +00:00
header("Location: index.php");
2014-09-03 18:27:01 +00:00
throw new SystemExit();
2014-08-18 23:57:20 +00:00
}
2014-09-03 18:27:01 +00:00
}