From 3b403a1a4b33443ee853556e40d4fe89d3399387 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 12 Apr 2015 18:44:42 -0400 Subject: Add screenshot support for tasks (copy/paste images directly) --- app/Controller/Board.php | 15 +++++++++++++++ app/Controller/File.php | 38 +++++++++++++++++++++++++++++++------- 2 files changed, 46 insertions(+), 7 deletions(-) (limited to 'app/Controller') diff --git a/app/Controller/Board.php b/app/Controller/Board.php index 89272393..d9243633 100644 --- a/app/Controller/Board.php +++ b/app/Controller/Board.php @@ -335,4 +335,19 @@ class Board extends Base $this->response->redirect($this->helper->url('board', 'show', array('project_id' => $values['project_id']))); } + + /** + * Screenshot popover + * + * @access public + */ + public function screenshot() + { + $task = $this->getTask(); + + $this->response->html($this->template->render('file/screenshot', array( + 'task' => $task, + 'redirect' => 'board', + ))); + } } diff --git a/app/Controller/File.php b/app/Controller/File.php index cc326dcd..39032abc 100644 --- a/app/Controller/File.php +++ b/app/Controller/File.php @@ -10,6 +10,32 @@ namespace Controller; */ class File extends Base { + /** + * Screenshot + * + * @access public + */ + public function screenshot() + { + $task = $this->getTask(); + + if ($this->request->isPost() && $this->file->uploadScreenshot($task['project_id'], $task['id'], $this->request->getValue('screenshot'))) { + + $this->session->flash(t('Screenshot uploaded successfully.')); + + if ($this->request->getStringParam('redirect') === 'board') { + $this->response->redirect($this->helper->url('board', 'show', array('project_id' => $task['project_id']))); + } + + $this->response->redirect($this->helper->url('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']))); + } + + $this->response->html($this->taskLayout('file/screenshot', array( + 'task' => $task, + 'redirect' => 'task', + ))); + } + /** * File upload form * @@ -34,13 +60,11 @@ class File extends Base { $task = $this->getTask(); - if ($this->file->upload($task['project_id'], $task['id'], 'files') === true) { - $this->response->redirect('?controller=task&action=show&task_id='.$task['id'].'&project_id='.$task['project_id'].'#attachments'); - } - else { + if (! $this->file->upload($task['project_id'], $task['id'], 'files')) { $this->session->flashError(t('Unable to upload the file.')); - $this->response->redirect('?controller=file&action=create&task_id='.$task['id'].'&project_id='.$task['project_id']); } + + $this->response->redirect($this->helper->url('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']))); } /** @@ -59,7 +83,7 @@ class File extends Base $this->response->binary(file_get_contents($filename)); } - $this->response->redirect('?controller=task&action=show&task_id='.$task['id'].'&project_id='.$task['project_id']); + $this->response->redirect($this->helper->url('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']))); } /** @@ -140,7 +164,7 @@ class File extends Base $this->session->flashError(t('Unable to remove this file.')); } - $this->response->redirect('?controller=task&action=show&task_id='.$task['id'].'&project_id='.$task['project_id']); + $this->response->redirect($this->helper->url('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']))); } /** -- cgit v1.2.3