2013-07-13 21:18:49 +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_reply page.
|
|
|
|
* check if the person is allowed to see the reply, if not he'll be redirected to an error page.
|
|
|
|
* data regarding to the reply will be returned by this function that will be used by the template.
|
|
|
|
* @author Daan Janssens, mentored by Matthew Lagoe
|
|
|
|
*/
|
2013-07-13 21:18:49 +00:00
|
|
|
function show_reply(){
|
|
|
|
//if logged in
|
|
|
|
if(WebUsers::isLoggedIn() && isset($_GET['id'])){
|
2014-09-03 05:06:43 +00:00
|
|
|
|
2013-07-13 21:18:49 +00:00
|
|
|
$result['reply_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
|
|
|
|
$reply = new Ticket_Reply();
|
|
|
|
$reply->load_With_TReplyId($result['reply_id']);
|
2014-09-03 05:06:43 +00:00
|
|
|
|
|
|
|
|
2013-07-13 21:18:49 +00:00
|
|
|
$ticket = new Ticket();
|
|
|
|
$ticket->load_With_TId($reply->getTicket());
|
2014-09-03 05:06:43 +00:00
|
|
|
|
2013-09-13 22:39:03 +00:00
|
|
|
//check if the user is allowed to see the reply
|
2013-09-09 01:47:32 +00:00
|
|
|
if(( $ticket->getAuthor() == unserialize($_SESSION['ticket_user'])->getTUserId() && ! $reply->getHidden()) || Ticket_User::isMod(unserialize($_SESSION['ticket_user']) )){
|
2013-07-13 21:18:49 +00:00
|
|
|
$content = new Ticket_Content();
|
|
|
|
$content->load_With_TContentId($reply->getContent());
|
2014-09-03 05:06:43 +00:00
|
|
|
|
2013-07-13 21:18:49 +00:00
|
|
|
$author = new Ticket_User();
|
|
|
|
$author->load_With_TUserId($reply->getAuthor());
|
2014-09-03 05:06:43 +00:00
|
|
|
|
2013-07-19 13:59:39 +00:00
|
|
|
$result['hidden'] = $reply->getHidden();
|
2013-07-13 21:18:49 +00:00
|
|
|
$result['ticket_id'] = $reply->getTicket();
|
|
|
|
$result['reply_timestamp'] = $reply->getTimestamp();
|
|
|
|
$result['author_permission'] = $author->getPermission();
|
|
|
|
$result['reply_content'] = $content->getContent();
|
|
|
|
$result['author'] = $author->getExternId();
|
2013-08-05 15:31:36 +00:00
|
|
|
$webUser = new WebUsers($author->getExternId());
|
|
|
|
$result['authorName'] = $webUser->getUsername();
|
2013-09-09 01:47:32 +00:00
|
|
|
if(Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){
|
2013-07-18 19:12:03 +00:00
|
|
|
$result['isMod'] = "TRUE";
|
2013-07-13 21:18:49 +00:00
|
|
|
}
|
2013-09-09 01:47:32 +00:00
|
|
|
global $INGAME_WEBPATH;
|
|
|
|
$result['ingame_webpath'] = $INGAME_WEBPATH;
|
2013-07-13 21:18:49 +00:00
|
|
|
return $result;
|
2014-09-03 05:06:43 +00:00
|
|
|
|
2013-07-13 21:18:49 +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-07-13 21:18:49 +00:00
|
|
|
header("Location: index.php?page=error");
|
2014-09-03 05:23:39 +00:00
|
|
|
throw new SystemExit();
|
2013-07-13 21:18:49 +00:00
|
|
|
}
|
|
|
|
}else{
|
|
|
|
//ERROR: not logged in!
|
2014-09-03 05:36:10 +00:00
|
|
|
header("Cache-Control: max-age=1");
|
2013-07-13 21:18:49 +00:00
|
|
|
header("Location: index.php");
|
2014-09-03 05:23:39 +00:00
|
|
|
throw new SystemExit();
|
2013-07-13 21:18:49 +00:00
|
|
|
}
|
2014-09-03 05:06:43 +00:00
|
|
|
}
|