This commit is contained in:
botanic 2014-09-05 00:50:07 -07:00
parent 981e75dfdb
commit 37be03d51c
7 changed files with 78 additions and 9 deletions

View file

@ -203,7 +203,24 @@ class Ticket{
return $reply; return $reply;
} }
/**
* return the attachments list
* @param $ticket_id the id of the ticket.
* @return a ticket_reply object.
*/
public static function getAttachments( $ticket_id) {
$dbl = new DBLayer("lib");
$statement = $dbl->select("`ticket_attachments`",array('ticket_TId' => $ticket_id), "`ticket_TId` =:ticket_TId ORDER BY Timestamp DESC");
$fetchall = $statement->fetchall();
$base = 0;
foreach ($fetchall as &$value) {
$webUser = new WebUsers($value['Uploader']);
$fetchall[$base]['Username'] = $webUser->getUsername();
$base++;
}
return $fetchall;
}
/** /**
* create a new reply for a ticket. * create a new reply for a ticket.
* A reply will only be added if the content isn't empty and if the ticket isn't closed. * A reply will only be added if the content isn't empty and if the ticket isn't closed.
@ -571,4 +588,33 @@ class Ticket{
$this->priority = $p; $this->priority = $p;
} }
/**
* function that creates a ticket Attachment.
*/
public static function add_Attachment($TId,$filename,$author,$tempFile){
global $FILE_STORAGE_PATH;
$length = 20;
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_';
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, strlen($characters) - 1)];
}
$targetFile = $FILE_STORAGE_PATH . $randomString . "/" . $filename;
$ticket = new Ticket();
$ticket->load_With_TId($TId);
//create the attachment!
$dbl = new DBLayer("lib");
$dbl->insert("`ticket_attachments`", Array('ticket_TId' => $TId, 'Filename' => $filename, 'Filesize' => filesize($tempFile), 'Uploader' => $author, 'Path' => $randomString . "/" . $filename));
mkdir($FILE_STORAGE_PATH . $randomString);
move_uploaded_file($tempFile,$targetFile);
//write a log entry
Ticket_Log::createLogEntry( $TId, $author, 10);
return true;
}
} }

View file

@ -13,6 +13,7 @@
* -# assigned to the ticket * -# assigned to the ticket
* -# forwarded ticket to support group arg * -# forwarded ticket to support group arg
* -# unassigned to the ticket * -# unassigned to the ticket
* -# added attachment to the ticket
* *
* @author Daan Janssens, mentored by Matthew Lagoe * @author Daan Janssens, mentored by Matthew Lagoe
*/ */
@ -36,6 +37,7 @@ class Ticket_Log{
* 7: assigned to the ticket * 7: assigned to the ticket
* 8: Forwarded ticket to support group arg * 8: Forwarded ticket to support group arg
* 9: unassigned to the ticket * 9: unassigned to the ticket
*10: added attachment to the ticket
* *
****************************************/ ****************************************/

View file

@ -154,6 +154,7 @@ group_size_error = "The name has to be between 4-20 chars and the tag between 2-
7 = "assigned to the ticket" 7 = "assigned to the ticket"
8 = "forwarded the ticket to the support group: " 8 = "forwarded the ticket to the support group: "
9 = "unassigned from the ticket" 9 = "unassigned from the ticket"
10= "added attachment"
[error] [error]
title404 = "Not<br/>Found!" title404 = "Not<br/>Found!"

View file

@ -32,7 +32,8 @@ CREATE TABLE IF NOT EXISTS `ticket_attachments` (
`Filename` varchar(45) COLLATE utf8_unicode_ci NOT NULL, `Filename` varchar(45) COLLATE utf8_unicode_ci NOT NULL,
`Timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `Timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`Filesize` int(10) NOT NULL, `Filesize` int(10) NOT NULL,
`Uploader` int(10) unsigned NOT NULL `Uploader` int(10) unsigned NOT NULL,
`Path` VARCHAR(128) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --

View file

@ -6,8 +6,6 @@ $id = $_POST['PHPSESSID'];
session_id($id); session_id($id);
session_start(); session_start();
global $FILE_STORAGE_PATH;
// Set permission // Set permission
if ( isset( $_SESSION['ticket_user'] ) ) { if ( isset( $_SESSION['ticket_user'] ) ) {
$return['permission'] = unserialize( $_SESSION['ticket_user'] ) -> getPermission(); $return['permission'] = unserialize( $_SESSION['ticket_user'] ) -> getPermission();
@ -27,10 +25,9 @@ global $FILE_STORAGE_PATH;
if (!empty($_FILES)) { if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name']; $tempFile = $_FILES['Filedata']['tmp_name'];
$targetFile = $FILE_STORAGE_PATH . $_FILES['Filedata']['name'];
$fileParts = pathinfo($_FILES['Filedata']['name']); $fileParts = pathinfo($_FILES['Filedata']['name']);
move_uploaded_file($tempFile,$targetFile); Ticket::add_Attachment($_GET['id'],$_FILES['Filedata']['name'],$_SESSION['id'],$tempFile);
} }
} }
} }

View file

@ -64,6 +64,10 @@ function show_ticket(){
$result['ticket_assignedTo'] = Assigned::getUserAssignedToTicket($result['ticket_tId']); $result['ticket_assignedTo'] = Assigned::getUserAssignedToTicket($result['ticket_tId']);
$result['ticket_replies'] = Gui_Elements::make_table($entire_ticket['reply_array'], Array("getTReplyId","getContent()->getContent","getTimestamp","getAuthor()->getExternId","getAuthor()->getPermission","getHidden"), Array("tReplyId","replyContent","timestamp","authorExtern","permission","hidden")); $result['ticket_replies'] = Gui_Elements::make_table($entire_ticket['reply_array'], Array("getTReplyId","getContent()->getContent","getTimestamp","getAuthor()->getExternId","getAuthor()->getPermission","getHidden"), Array("tReplyId","replyContent","timestamp","authorExtern","permission","hidden"));
$i = 0; $i = 0;
global $FILE_WEB_PATH;
$result['FILE_WEB_PATH'] = $FILE_WEB_PATH;
global $BASE_WEBPATH;
$result['BASE_WEBPATH'] = $BASE_WEBPATH;
foreach( $result['ticket_replies'] as $reply){ foreach( $result['ticket_replies'] as $reply){
$webReplyUser = new WebUsers($reply['authorExtern']); $webReplyUser = new WebUsers($reply['authorExtern']);
$result['ticket_replies'][$i]['author'] = $webReplyUser->getUsername(); $result['ticket_replies'][$i]['author'] = $webReplyUser->getUsername();
@ -77,6 +81,8 @@ function show_ticket(){
$result['hasInfo'] = $target_ticket->hasInfo(); $result['hasInfo'] = $target_ticket->hasInfo();
global $INGAME_WEBPATH; global $INGAME_WEBPATH;
$result['ingame_webpath'] = $INGAME_WEBPATH; $result['ingame_webpath'] = $INGAME_WEBPATH;
//get attachments
$result['ticket_attachments'] = Ticket::getAttachments($result['ticket_id']);
return $result; return $result;
}else{ }else{

View file

@ -30,11 +30,27 @@
</span> </span>
</td> </td>
</tr> </tr>
</table>
<table class="table table-bordered table-condensed ">
<tr> <tr>
<td><strong>Assigned To: </strong>{if $ticket_assignedTo neq ""} <a href="index.php?page=show_user&id={$ticket_assignedTo}">{$ticket_assignedToText}</a> {else}<i> {$not_assigned}</i> {/if}</td> <td><strong>Filename: </strong></td>
<td></td> <td><strong>Uploaded: </strong></td>
<td></td> <td><strong>Filesize: </strong></td>
<td><strong>Uploaded by: </strong></td>
</tr> </tr>
{foreach from=$ticket_attachments item=array}
<tr>
<td><a href="{$FILE_WEB_PATH}{$array['Path']}">{$array['Filename']}</a></td>
<td>{$array['Timestamp']}</td>
<td>{$array['Filesize']} Bytes</td>
<td>{if $permission > 1}
<a href="{$BASE_WEBPATH}index.php?page=show_user&id={$array['Uploader']}">{$array['Username']}</a>
{else}
{$array['Username']}
{/if}
</td>
</tr>
{/foreach}
</table> </table>