2013-08-29 03:01:47 +00:00
|
|
|
<?php
|
2013-09-13 22:39:03 +00:00
|
|
|
/**
|
|
|
|
* This function is beign used to load info that's needed for the dashboard page.
|
|
|
|
* check if the person who wants to view this page is a mod/admin, if this is not the case, he will be redirected to an error page.
|
|
|
|
* next it will fetch a lot of information regarding to the status of the ticket system (eg return the total amount of tickets) and return this information so
|
|
|
|
* it can be used by the template.
|
|
|
|
* @author Daan Janssens, mentored by Matthew Lagoe
|
|
|
|
*/
|
2013-08-29 03:01:47 +00:00
|
|
|
function dashboard(){
|
2014-09-03 05:06:43 +00:00
|
|
|
|
2013-09-09 01:47:32 +00:00
|
|
|
//if logged in
|
2013-08-29 03:01:47 +00:00
|
|
|
if(WebUsers::isLoggedIn()){
|
2014-09-03 05:06:43 +00:00
|
|
|
|
2013-08-29 03:01:47 +00:00
|
|
|
//is Mod
|
2013-09-09 01:47:32 +00:00
|
|
|
if(ticket_user::isMod(unserialize($_SESSION['ticket_user']))){
|
2013-09-13 22:39:03 +00:00
|
|
|
//return useful information about the status of the ticket system.
|
2013-09-09 01:47:32 +00:00
|
|
|
$result['user_id'] = unserialize($_SESSION['ticket_user'])->getTUserId();
|
|
|
|
$result['nrToDo'] = Ticket_Queue_Handler::getNrOfTicketsToDo(unserialize($_SESSION['ticket_user'])->getTUserId());
|
|
|
|
$result['nrAssignedWaiting'] = Ticket_Queue_Handler::getNrOfTicketsAssignedWaiting(unserialize($_SESSION['ticket_user'])->getTUserId());
|
2013-08-29 03:01:47 +00:00
|
|
|
$result['nrTotalTickets'] = Ticket_Queue_Handler::getNrOfTickets();
|
|
|
|
$ticket = Ticket_Queue_Handler::getNewestTicket();
|
|
|
|
$result['newestTicketId'] = $ticket->getTId();
|
|
|
|
$result['newestTicketTitle'] = $ticket->getTitle();
|
|
|
|
$result['newestTicketAuthor'] = Ticket_User::get_username_from_id($ticket->getAuthor());
|
2013-09-09 01:47:32 +00:00
|
|
|
global $INGAME_WEBPATH;
|
|
|
|
$result['ingame_webpath'] = $INGAME_WEBPATH;
|
2013-08-29 03:01:47 +00:00
|
|
|
return $result;
|
2014-09-03 05:06:43 +00:00
|
|
|
|
2013-08-29 03:01:47 +00:00
|
|
|
}else{
|
|
|
|
//ERROR: No access!
|
|
|
|
$_SESSION['error_code'] = "403";
|
2014-09-03 05:36:10 +00:00
|
|
|
header("Cache-Control: max-age=1");
|
2013-08-29 03:01:47 +00:00
|
|
|
header("Location: index.php?page=error");
|
2014-09-03 05:23:39 +00:00
|
|
|
throw new SystemExit();
|
2014-09-03 05:06:43 +00:00
|
|
|
|
2013-08-29 03:01:47 +00:00
|
|
|
}
|
2014-09-03 05:06:43 +00:00
|
|
|
|
2013-08-29 03:01:47 +00:00
|
|
|
}else{
|
|
|
|
//ERROR: not logged in!
|
2014-09-03 05:36:10 +00:00
|
|
|
header("Cache-Control: max-age=1");
|
2013-08-29 03:01:47 +00:00
|
|
|
header("Location: index.php");
|
2014-09-03 05:23:39 +00:00
|
|
|
throw new SystemExit();
|
2013-08-29 03:01:47 +00:00
|
|
|
}
|
2014-09-03 05:06:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
}
|