diff --git a/server/controllers/system/csv-import.php b/server/controllers/system/csv-import.php index e415c6f1..ea3093b8 100644 --- a/server/controllers/system/csv-import.php +++ b/server/controllers/system/csv-import.php @@ -13,6 +13,10 @@ class CSVImportController extends Controller { public function handler() { $fileUploader = $this->uploadFile(); + if(!$fileUploader instanceof FileUploader) { + throw new Exception(ERRORS::INVALID_FILE); + } + $file = fopen($fileUploader->getFullFilePath(),'r'); $errors = []; diff --git a/server/controllers/ticket/comment.php b/server/controllers/ticket/comment.php index 2b5c90b9..9c27dc17 100644 --- a/server/controllers/ticket/comment.php +++ b/server/controllers/ticket/comment.php @@ -47,10 +47,12 @@ class CommentController extends Controller { } private function storeComment() { + $fileUploader = $this->uploadFile(); + $comment = Ticketevent::getEvent(Ticketevent::COMMENT); $comment->setProperties(array( 'content' => $this->content, - 'file' => $this->uploadFile()->getFileName(), + 'file' => ($fileUploader instanceof FileUploader) ? $fileUploader->getFileName() : null, 'date' => Date::getCurrentDate() )); diff --git a/server/controllers/ticket/create.php b/server/controllers/ticket/create.php index 1a07a0cb..4b761dc5 100644 --- a/server/controllers/ticket/create.php +++ b/server/controllers/ticket/create.php @@ -53,6 +53,8 @@ class CreateController extends Controller { $department = Department::getDataStore($this->departmentId); $author = Controller::getLoggedUser(); + $fileUploader = $this->uploadFile(); + $ticket = new Ticket(); $ticket->setProperties(array( 'title' => $this->title, @@ -60,7 +62,7 @@ class CreateController extends Controller { 'language' => $this->language, 'author' => $author, 'department' => $department, - 'file' => $this->uploadFile()->getFileName(), + 'file' => ($fileUploader instanceof FileUploader) ? $fileUploader->getFileName() : null, 'date' => Date::getCurrentDate(), 'unread' => false, 'unreadStaff' => true, diff --git a/tests/init.rb b/tests/init.rb index 1ecc936f..dad08d9a 100644 --- a/tests/init.rb +++ b/tests/init.rb @@ -59,3 +59,4 @@ require './system/add-api-key.rb' require './system/delete-api-key.rb' require './system/get-all-keys.rb' require './system/file-upload-download.rb' +require './system/csv-import.rb'