From 2aded07b568cba44ccbe2259fe6984c543ee2353 Mon Sep 17 00:00:00 2001 From: Guillermo Giuliana Date: Thu, 16 Apr 2020 10:07:28 -0300 Subject: [PATCH 1/2] fix image displaying --- server/controllers/ticket/comment.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/controllers/ticket/comment.php b/server/controllers/ticket/comment.php index fbef8fe8..cce4a87b 100755 --- a/server/controllers/ticket/comment.php +++ b/server/controllers/ticket/comment.php @@ -38,6 +38,7 @@ class CommentController extends Controller { private $ticket; private $content; private $session; + private $imagePaths; public function validations() { $this->session = Session::getInstance(); @@ -119,12 +120,12 @@ class CommentController extends Controller { private function storeComment() { $fileUploader = FileUploader::getInstance(); $fileUploader->setPermission(FileManager::PERMISSION_TICKET, $this->ticket->ticketNumber); - $imagePaths = $this->uploadImages(Controller::isStaffLogged()); + $this->imagePaths = $this->uploadImages(Controller::isStaffLogged()); $fileUploader = $this->uploadFile(Controller::isStaffLogged()); $comment = Ticketevent::getEvent(Ticketevent::COMMENT); $comment->setProperties(array( - 'content' => $this->replaceWithImagePaths($imagePaths, $this->content), + 'content' => $this->replaceWithImagePaths($this->imagePaths, $this->content), 'file' => ($fileUploader instanceof FileUploader) ? $fileUploader->getFileName() : null, 'date' => Date::getCurrentDate(), 'private' => (Controller::isStaffLogged() && Controller::request('private')) ? 1 : 0 @@ -164,7 +165,7 @@ class CommentController extends Controller { 'name' => $name, 'title' => $this->ticket->title, 'ticketNumber' => $this->ticket->ticketNumber, - 'content' => $this->content, + 'content' => $this->replaceWithImagePaths($this->imagePaths, $this->content), 'url' => $url ]); From 64cfd5a8f158a8938a6eb4c4121d2a1b291879c7 Mon Sep 17 00:00:00 2001 From: Guillermo Giuliana Date: Thu, 16 Apr 2020 10:52:33 -0300 Subject: [PATCH 2/2] create get-image-paths function --- server/controllers/ticket/comment.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/server/controllers/ticket/comment.php b/server/controllers/ticket/comment.php index cce4a87b..277d153b 100755 --- a/server/controllers/ticket/comment.php +++ b/server/controllers/ticket/comment.php @@ -120,12 +120,11 @@ class CommentController extends Controller { private function storeComment() { $fileUploader = FileUploader::getInstance(); $fileUploader->setPermission(FileManager::PERMISSION_TICKET, $this->ticket->ticketNumber); - $this->imagePaths = $this->uploadImages(Controller::isStaffLogged()); $fileUploader = $this->uploadFile(Controller::isStaffLogged()); $comment = Ticketevent::getEvent(Ticketevent::COMMENT); $comment->setProperties(array( - 'content' => $this->replaceWithImagePaths($this->imagePaths, $this->content), + 'content' => $this->replaceWithImagePaths($this->getImagePaths(), $this->content), 'file' => ($fileUploader instanceof FileUploader) ? $fileUploader->getFileName() : null, 'date' => Date::getCurrentDate(), 'private' => (Controller::isStaffLogged() && Controller::request('private')) ? 1 : 0 @@ -165,10 +164,18 @@ class CommentController extends Controller { 'name' => $name, 'title' => $this->ticket->title, 'ticketNumber' => $this->ticket->ticketNumber, - 'content' => $this->replaceWithImagePaths($this->imagePaths, $this->content), + 'content' => $this->replaceWithImagePaths($this->getImagePaths(), $this->content), 'url' => $url ]); $mailSender->send(); } + + private function getImagePaths() { + if(!$this->imagePaths){ + $this->imagePaths = $this->uploadImages(Controller::isStaffLogged()); + } + + return $this->imagePaths; + } }