diff options
author | Max Kamashev <kamashev@gollard.ru> | 2015-09-24 12:07:40 +0300 |
---|---|---|
committer | Max Kamashev <kamashev@gollard.ru> | 2015-09-24 12:07:40 +0300 |
commit | 3f5b636c998171837fc2265f760359b421d67b61 (patch) | |
tree | a505f4f1767efff50224b649e647a02ae3638e12 /app/Controller | |
parent | 5b2e49d2945ce2c1daaf4dd78746a910eab9c9c8 (diff) | |
parent | 1b0b69a43f7528fd5188d4b48216c6fa7e32eac3 (diff) |
Merge branch 'master' of https://github.com/ukko/kanboard into 1245_bug_with_subtask_timer
Diffstat (limited to 'app/Controller')
-rw-r--r-- | app/Controller/File.php | 62 |
1 files changed, 41 insertions, 21 deletions
diff --git a/app/Controller/File.php b/app/Controller/File.php index 7b7c75ee..ef90c55a 100644 --- a/app/Controller/File.php +++ b/app/Controller/File.php @@ -2,6 +2,8 @@ namespace Controller; +use Core\ObjectStorage\ObjectStorageException; + /** * File controller * @@ -74,15 +76,21 @@ class File extends Base */ public function download() { - $task = $this->getTask(); - $file = $this->file->getById($this->request->getIntegerParam('file_id')); + try { - if ($file['task_id'] != $task['id']) { - $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']))); - } + $task = $this->getTask(); + $file = $this->file->getById($this->request->getIntegerParam('file_id')); + + if ($file['task_id'] != $task['id']) { + $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']))); + } - $this->response->forceDownload($file['name']); - $this->objectStorage->passthru($file['path']); + $this->response->forceDownload($file['name']); + $this->objectStorage->output($file['path']); + } + catch (ObjectStorageException $e) { + $this->logger->error($e->getMessage()); + } } /** @@ -110,15 +118,21 @@ class File extends Base */ public function image() { - $task = $this->getTask(); - $file = $this->file->getById($this->request->getIntegerParam('file_id')); + try { - if ($file['task_id'] != $task['id']) { - $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']))); - } + $task = $this->getTask(); + $file = $this->file->getById($this->request->getIntegerParam('file_id')); - $this->response->contentType($this->file->getImageMimeType($file['name'])); - $this->objectStorage->passthru($file['path']); + if ($file['task_id'] != $task['id']) { + $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']))); + } + + $this->response->contentType($this->file->getImageMimeType($file['name'])); + $this->objectStorage->output($file['path']); + } + catch (ObjectStorageException $e) { + $this->logger->error($e->getMessage()); + } } /** @@ -128,15 +142,21 @@ class File extends Base */ public function thumbnail() { - $task = $this->getTask(); - $file = $this->file->getById($this->request->getIntegerParam('file_id')); + try { - if ($file['task_id'] != $task['id']) { - $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']))); - } + $task = $this->getTask(); + $file = $this->file->getById($this->request->getIntegerParam('file_id')); + + if ($file['task_id'] != $task['id']) { + $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']))); + } - $this->response->contentType('image/jpeg'); - $this->objectStorage->passthru($this->file->getThumbnailPath($file['path'])); + $this->response->contentType('image/jpeg'); + $this->objectStorage->output($this->file->getThumbnailPath($file['path'])); + } + catch (ObjectStorageException $e) { + $this->logger->error($e->getMessage()); + } } /** |