summaryrefslogtreecommitdiff
path: root/app/Controller/TaskFileController.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Controller/TaskFileController.php')
-rw-r--r--app/Controller/TaskFileController.php98
1 files changed, 98 insertions, 0 deletions
diff --git a/app/Controller/TaskFileController.php b/app/Controller/TaskFileController.php
new file mode 100644
index 00000000..77c0c026
--- /dev/null
+++ b/app/Controller/TaskFileController.php
@@ -0,0 +1,98 @@
+<?php
+
+namespace Kanboard\Controller;
+
+/**
+ * Task File Controller
+ *
+ * @package Kanboard\Controller
+ * @author Frederic Guillot
+ */
+class TaskFileController extends BaseController
+{
+ /**
+ * Screenshot
+ *
+ * @access public
+ */
+ public function screenshot()
+ {
+ $task = $this->getTask();
+
+ if ($this->request->isPost() && $this->taskFileModel->uploadScreenshot($task['id'], $this->request->getValue('screenshot')) !== false) {
+ $this->flash->success(t('Screenshot uploaded successfully.'));
+ return $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true);
+ }
+
+ return $this->response->html($this->template->render('task_file/screenshot', array(
+ 'task' => $task,
+ )));
+ }
+
+ /**
+ * File upload form
+ *
+ * @access public
+ */
+ public function create()
+ {
+ $task = $this->getTask();
+
+ $this->response->html($this->template->render('task_file/create', array(
+ 'task' => $task,
+ 'max_size' => $this->helper->text->phpToBytes(ini_get('upload_max_filesize')),
+ )));
+ }
+
+ /**
+ * File upload (save files)
+ *
+ * @access public
+ */
+ public function save()
+ {
+ $task = $this->getTask();
+
+ if (! $this->taskFileModel->uploadFiles($task['id'], $this->request->getFileInfo('files'))) {
+ $this->flash->failure(t('Unable to upload the file.'));
+ }
+
+ $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true);
+ }
+
+ /**
+ * Remove a file
+ *
+ * @access public
+ */
+ public function remove()
+ {
+ $this->checkCSRFParam();
+ $task = $this->getTask();
+ $file = $this->taskFileModel->getById($this->request->getIntegerParam('file_id'));
+
+ if ($file['task_id'] == $task['id'] && $this->taskFileModel->remove($file['id'])) {
+ $this->flash->success(t('File removed successfully.'));
+ } else {
+ $this->flash->failure(t('Unable to remove this file.'));
+ }
+
+ $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])));
+ }
+
+ /**
+ * Confirmation dialog before removing a file
+ *
+ * @access public
+ */
+ public function confirm()
+ {
+ $task = $this->getTask();
+ $file = $this->taskFileModel->getById($this->request->getIntegerParam('file_id'));
+
+ $this->response->html($this->template->render('task_file/remove', array(
+ 'task' => $task,
+ 'file' => $file,
+ )));
+ }
+}