summaryrefslogtreecommitdiff
path: root/app/Controller/TaskInternalLink.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-05-26 21:38:43 -0400
committerFrederic Guillot <fred@kanboard.net>2016-05-26 21:38:43 -0400
commit9ebbe3da56914c408327997cea4eb00db2f88e0c (patch)
tree92a40db64f958abff457add4aa643fc6154a05d3 /app/Controller/TaskInternalLink.php
parent33dea152fc6b0c061b1f61060cc75710dd0ec236 (diff)
Rename task controllers
Diffstat (limited to 'app/Controller/TaskInternalLink.php')
-rw-r--r--app/Controller/TaskInternalLink.php167
1 files changed, 0 insertions, 167 deletions
diff --git a/app/Controller/TaskInternalLink.php b/app/Controller/TaskInternalLink.php
deleted file mode 100644
index 6ff20252..00000000
--- a/app/Controller/TaskInternalLink.php
+++ /dev/null
@@ -1,167 +0,0 @@
-<?php
-
-namespace Kanboard\Controller;
-
-use Kanboard\Core\Controller\PageNotFoundException;
-
-/**
- * TaskInternalLink Controller
- *
- * @package controller
- * @author Olivier Maridat
- * @author Frederic Guillot
- */
-class TaskInternalLink extends BaseController
-{
- /**
- * Get the current link
- *
- * @access private
- * @return array
- * @throws PageNotFoundException
- */
- private function getTaskLink()
- {
- $link = $this->taskLink->getById($this->request->getIntegerParam('link_id'));
-
- if (empty($link)) {
- throw new PageNotFoundException();
- }
-
- return $link;
- }
-
- /**
- * Creation form
- *
- * @access public
- * @param array $values
- * @param array $errors
- * @throws PageNotFoundException
- * @throws \Kanboard\Core\Controller\AccessForbiddenException
- */
- public function create(array $values = array(), array $errors = array())
- {
- $task = $this->getTask();
-
- $this->response->html($this->template->render('task_internal_link/create', array(
- 'values' => $values,
- 'errors' => $errors,
- 'task' => $task,
- 'labels' => $this->link->getList(0, false),
- )));
- }
-
- /**
- * Validation and creation
- *
- * @access public
- */
- public function save()
- {
- $task = $this->getTask();
- $values = $this->request->getValues();
-
- list($valid, $errors) = $this->taskLinkValidator->validateCreation($values);
-
- if ($valid) {
- if ($this->taskLink->create($values['task_id'], $values['opposite_task_id'], $values['link_id'])) {
- $this->flash->success(t('Link added successfully.'));
- return $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true);
- }
-
- $errors = array('title' => array(t('The exact same link already exists')));
- $this->flash->failure(t('Unable to create your link.'));
- }
-
- return $this->create($values, $errors);
- }
-
- /**
- * Edit form
- *
- * @access public
- * @param array $values
- * @param array $errors
- * @throws PageNotFoundException
- * @throws \Kanboard\Core\Controller\AccessForbiddenException
- */
- public function edit(array $values = array(), array $errors = array())
- {
- $task = $this->getTask();
- $task_link = $this->getTaskLink();
-
- if (empty($values)) {
- $opposite_task = $this->taskFinder->getById($task_link['opposite_task_id']);
- $values = $task_link;
- $values['title'] = '#'.$opposite_task['id'].' - '.$opposite_task['title'];
- }
-
- $this->response->html($this->template->render('task_internal_link/edit', array(
- 'values' => $values,
- 'errors' => $errors,
- 'task_link' => $task_link,
- 'task' => $task,
- 'labels' => $this->link->getList(0, false)
- )));
- }
-
- /**
- * Validation and update
- *
- * @access public
- */
- public function update()
- {
- $task = $this->getTask();
- $values = $this->request->getValues();
-
- list($valid, $errors) = $this->taskLinkValidator->validateModification($values);
-
- if ($valid) {
- if ($this->taskLink->update($values['id'], $values['task_id'], $values['opposite_task_id'], $values['link_id'])) {
- $this->flash->success(t('Link updated successfully.'));
- return $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])).'#links');
- }
-
- $this->flash->failure(t('Unable to update your link.'));
- }
-
- return $this->edit($values, $errors);
- }
-
- /**
- * Confirmation dialog before removing a link
- *
- * @access public
- */
- public function confirm()
- {
- $task = $this->getTask();
- $link = $this->getTaskLink();
-
- $this->response->html($this->template->render('task_internal_link/remove', array(
- 'link' => $link,
- 'task' => $task,
- )));
- }
-
- /**
- * Remove a link
- *
- * @access public
- */
- public function remove()
- {
- $this->checkCSRFParam();
- $task = $this->getTask();
-
- if ($this->taskLink->remove($this->request->getIntegerParam('link_id'))) {
- $this->flash->success(t('Link removed successfully.'));
- } else {
- $this->flash->failure(t('Unable to remove this link.'));
- }
-
- $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])));
- }
-}