This commit is contained in:
kaetemi 2014-09-05 10:01:20 +02:00
commit e3a519fad8
16 changed files with 2206 additions and 16 deletions

View file

@ -250,3 +250,4 @@ code/nel/tools/build_gamedata/processes/rbank/build_rbank.cfg
code/nel/tools/build_gamedata/processes/zone/debug_zone_dependencies.cfg
code/web/public_php/config.php
code/web/public_php/is_installed
code/web/public_php/ams/files

View file

@ -80,6 +80,9 @@ class Helpers {
$smarty -> assign( $key, $value);
}
$id = session_id();
$smarty -> assign( "sessionid", $id );
// smarty inheritance for loading the matching wrapper layout (with the matching menu bar)
if ( isset( $vars['permission'] ) && $vars['permission'] == 3 ) {
$inherited = "extends:layout_admin.tpl|";

View file

@ -203,6 +203,23 @@ class Ticket{
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.
@ -571,4 +588,33 @@ class Ticket{
$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
* -# forwarded ticket to support group arg
* -# unassigned to the ticket
* -# added attachment to the ticket
*
* @author Daan Janssens, mentored by Matthew Lagoe
*/
@ -36,6 +37,7 @@ class Ticket_Log{
* 7: assigned to the ticket
* 8: Forwarded ticket to support group arg
* 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"
8 = "forwarded the ticket to the support group: "
9 = "unassigned from the ticket"
10= "added attachment"
[error]
title404 = "Not<br/>Found!"

View file

@ -122,7 +122,8 @@ $INGAME_LAYOUT = "basic";
$FORCE_INGAME = false;
//file storage path (must be a publicly accessible url for
$FILE_STORAGE_PATH = "/files/";
$FILE_STORAGE_PATH = $PUBLIC_PHP_PATH . '/ams/files/';
$FILE_WEB_PATH = $BASE_WEBPATH . 'files/';
// Setup password
$NEL_SETUP_PASSWORD = '%nelSetupPassword%';

View file

@ -0,0 +1,71 @@
-- phpMyAdmin SQL Dump
-- version 4.2.8
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Sep 04, 2014 at 09:28 PM
-- Server version: 5.6.17
-- PHP Version: 5.5.12
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `nel_ams_lib`
--
-- --------------------------------------------------------
--
-- Table structure for table `ticket_attachments`
--
CREATE TABLE IF NOT EXISTS `ticket_attachments` (
`idticket_attachments` int(10) unsigned NOT NULL,
`ticket_TId` int(10) unsigned NOT NULL,
`Filename` varchar(45) COLLATE utf8_unicode_ci NOT NULL,
`Timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`Filesize` int(10) NOT NULL,
`Uploader` int(10) unsigned NOT NULL,
`Path` VARCHAR(128) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `ticket_attachments`
--
ALTER TABLE `ticket_attachments`
ADD PRIMARY KEY (`idticket_attachments`), ADD UNIQUE KEY `idticket_attachments_UNIQUE` (`idticket_attachments`), ADD KEY `fk_ticket_attachments_ticket1_idx` (`ticket_TId`), ADD KEY `fk_ticket_attachments_ticket_user1_idx` (`Uploader`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `ticket_attachments`
--
ALTER TABLE `ticket_attachments`
MODIFY `idticket_attachments` int(10) unsigned NOT NULL AUTO_INCREMENT;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `ticket_attachments`
--
ALTER TABLE `ticket_attachments`
ADD CONSTRAINT `fk_ticket_attachments_ticket1` FOREIGN KEY (`ticket_TId`) REFERENCES `ticket` (`TId`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_ticket_attachments_ticket_user1` FOREIGN KEY (`Uploader`) REFERENCES `ticket_user` (`TUserId`) ON DELETE NO ACTION ON UPDATE NO ACTION;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

View file

@ -0,0 +1,34 @@
<?php
require( '../../config.php' );
require_once( $AMS_LIB . '/libinclude.php' );
$id = $_POST['PHPSESSID'];
session_id($id);
session_start();
// Set permission
if ( isset( $_SESSION['ticket_user'] ) ) {
$return['permission'] = unserialize( $_SESSION['ticket_user'] ) -> getPermission();
} else {
// default permission
$return['permission'] = 0;
}
if(WebUsers::isLoggedIn() && isset($_GET['id'])){
$ticket_id = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
$target_ticket = new Ticket();
$target_ticket->load_With_TId($ticket_id);
if(($target_ticket->getAuthor() == unserialize($_SESSION['ticket_user'])->getTUserId()) || Ticket_User::isMod(unserialize($_SESSION['ticket_user'])) ){
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$fileParts = pathinfo($_FILES['Filedata']['name']);
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_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;
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){
$webReplyUser = new WebUsers($reply['authorExtern']);
$result['ticket_replies'][$i]['author'] = $webReplyUser->getUsername();
@ -77,6 +81,8 @@ function show_ticket(){
$result['hasInfo'] = $target_ticket->hasInfo();
global $INGAME_WEBPATH;
$result['ingame_webpath'] = $INGAME_WEBPATH;
//get attachments
$result['ticket_attachments'] = Ticket::getAttachments($result['ticket_id']);
return $result;
}else{

View file

@ -28,6 +28,7 @@ require( '../config.php' );
require_once( $AMS_LIB . '/libinclude.php' );
session_start();
// Running Cron
if ( isset( $_GET["cron"] ) ) {
if ( $_GET["cron"] == "true" ) {

View file

@ -0,0 +1,13 @@
$(document).ready(function () {
//other things to do on document ready, separated for ajax calls
docReady();
});
function docReady() {
}

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

View file

@ -22,12 +22,6 @@
<link id="bs-css" href="css/bootstrap-cerulean.min.css" rel="stylesheet">
<link href="css/charisma-app.css" rel="stylesheet">
<link href='bower_components/fullcalendar/dist/fullcalendar.css' rel='stylesheet'>
<link href='bower_components/fullcalendar/dist/fullcalendar.print.css' rel='stylesheet' media='print'>
<link href='bower_components/chosen/chosen.min.css' rel='stylesheet'>
<link href='bower_components/colorbox/example3/colorbox.css' rel='stylesheet'>
<link href='bower_components/responsive-tables/responsive-tables.css' rel='stylesheet'>
<link href='bower_components/bootstrap-tour/build/css/bootstrap-tour.min.css' rel='stylesheet'>
<link href='css/jquery.noty.css' rel='stylesheet'>
<link href='css/noty_theme_default.css' rel='stylesheet'>
<link href='css/elfinder.min.css' rel='stylesheet'>
@ -36,6 +30,9 @@
<link href='css/uploadify.css' rel='stylesheet'>
<link href='css/animate.min.css' rel='stylesheet'>
<!-- jQuery -->
<script src="js/jquery.min.js"></script>
<!-- The HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
@ -165,8 +162,8 @@
</footer>
{/if}
</div><!--/.fluid-container-->
<!-- external javascript
</div>
<!-- external javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script>
@ -304,7 +301,8 @@
<!-- <script src="js/charisma.js"></script> -->
<!-- help script for page help -->
<script src="js/help.js"></script>
<!-- application script for Charisma demo -->
<script src="js/custom.js"></script>
</div>
</body>
</html>

View file

@ -30,11 +30,27 @@
</span>
</td>
</tr>
</table>
<table class="table table-bordered table-condensed ">
<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></td>
<td></td>
<td><strong>Filename: </strong></td>
<td><strong>Uploaded: </strong></td>
<td><strong>Filesize: </strong></td>
<td><strong>Uploaded by: </strong></td>
</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>
@ -112,6 +128,25 @@
{/if}
<input type="hidden" name="function" value="reply_on_ticket">
<input type="hidden" name="ticket_id" value="{$ticket_id}">
<h3>Upload Attachment</h3>
<input data-no-uniform="true" type="file" name="file_upload" id="file_upload">
{literal}
<script language='JavaScript'>
$(document).ready( function () {
$('#file_upload').uploadify({
'formData' : {'PHPSESSID': '{/literal}{$sessionid}{literal}'},
'auto' : true,
'multi' : true,
'method' : 'post',
'swf': 'misc/uploadify.swf',
'uploader': 'func/upload.php?id='+{/literal}{$ticket_id}{literal}
});
});
</script>
{/literal}
<div class="control-group">
<label class="control-label"></label>
<div class="controls">

View file

@ -106,6 +106,7 @@ include('header.php');
// Create AMS Library database
$continue = create_use_database($continue, $con, $_POST["amsLibDatabase"]);
$continue = update_database_structure($continue, $con, "nel_ams_lib_00001.sql");
$continue = update_database_structure($continue, $con, "nel_ams_lib_00002.sql");
if ($con) {
mysqli_close($con);