Merge branch 'fixes' into main/rendor-staging
[ryzomcore.git] / web / public_php / ams / inc / dashboard.php
blob8309ee737a510e5d3f2299cc8f24710b648cbba8
1 <?php
2 /**
3 * This function is beign used to load info that's needed for the dashboard page.
4 * 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.
5 * 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
6 * it can be used by the template.
7 * @author Daan Janssens, mentored by Matthew Lagoe
8 */
9 function dashboard(){
11 //if logged in
12 if(WebUsers::isLoggedIn()){
14 //is Mod
15 if(ticket_user::isMod(unserialize($_SESSION['ticket_user']))){
16 //return useful information about the status of the ticket system.
17 $result['user_id'] = unserialize($_SESSION['ticket_user'])->getTUserId();
18 $result['nrToDo'] = Ticket_Queue_Handler::getNrOfTicketsToDo(unserialize($_SESSION['ticket_user'])->getTUserId());
19 $result['nrAssignedWaiting'] = Ticket_Queue_Handler::getNrOfTicketsAssignedWaiting(unserialize($_SESSION['ticket_user'])->getTUserId());
20 $result['nrTotalTickets'] = Ticket_Queue_Handler::getNrOfTickets();
21 $ticket = Ticket_Queue_Handler::getNewestTicket();
22 $result['newestTicketId'] = $ticket->getTId();
23 $result['newestTicketTitle'] = $ticket->getTitle();
24 $result['newestTicketAuthor'] = Ticket_User::get_username_from_id($ticket->getAuthor());
25 global $INGAME_WEBPATH;
26 $result['ingame_webpath'] = $INGAME_WEBPATH;
27 return $result;
29 }else{
30 //ERROR: No access!
31 $_SESSION['error_code'] = "403";
32 header("Cache-Control: max-age=1");
33 header("Location: index.php?page=error");
34 throw new SystemExit();
38 }else{
39 //ERROR: not logged in!
40 header("Cache-Control: max-age=1");
41 header("Location: index.php");
42 throw new SystemExit();