summaryrefslogtreecommitdiff
path: root/app/Controller
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-04-12 18:44:42 -0400
committerFrederic Guillot <fred@kanboard.net>2015-04-12 18:44:42 -0400
commit3b403a1a4b33443ee853556e40d4fe89d3399387 (patch)
tree3b3105c3a83b00fd7bda76aeda4ddde788e9d663 /app/Controller
parent2a150dd3be96692a98c034233a9ae29ff6f219ac (diff)
Add screenshot support for tasks (copy/paste images directly)
Diffstat (limited to 'app/Controller')
-rw-r--r--app/Controller/Board.php15
-rw-r--r--app/Controller/File.php38
2 files changed, 46 insertions, 7 deletions
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
@@ -11,6 +11,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
*
* @access public
@@ -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'])));
}
/**