summaryrefslogtreecommitdiff
path: root/app/Controller/Task.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Controller/Task.php')
-rw-r--r--app/Controller/Task.php153
1 files changed, 63 insertions, 90 deletions
diff --git a/app/Controller/Task.php b/app/Controller/Task.php
index e905ef30..444065f0 100644
--- a/app/Controller/Task.php
+++ b/app/Controller/Task.php
@@ -233,26 +233,20 @@ class Task extends Base
*/
public function close()
{
- $this->checkCSRFParam();
$task = $this->getTask();
- if ($this->task->close($task['id'])) {
- $this->session->flash(t('Task closed successfully.'));
- } else {
- $this->session->flashError(t('Unable to close this task.'));
- }
+ if ($this->request->getStringParam('confirmation') === 'yes') {
- $this->response->redirect('?controller=task&action=show&task_id='.$task['id']);
- }
+ $this->checkCSRFParam();
- /**
- * Confirmation dialog before to close a task
- *
- * @access public
- */
- public function confirmClose()
- {
- $task = $this->getTask();
+ if ($this->task->close($task['id'])) {
+ $this->session->flash(t('Task closed successfully.'));
+ } else {
+ $this->session->flashError(t('Unable to close this task.'));
+ }
+
+ $this->response->redirect('?controller=task&action=show&task_id='.$task['id']);
+ }
$this->response->html($this->taskLayout('task_close', array(
'task' => $task,
@@ -268,26 +262,20 @@ class Task extends Base
*/
public function open()
{
- $this->checkCSRFParam();
$task = $this->getTask();
- if ($this->task->open($task['id'])) {
- $this->session->flash(t('Task opened successfully.'));
- } else {
- $this->session->flashError(t('Unable to open this task.'));
- }
+ if ($this->request->getStringParam('confirmation') === 'yes') {
- $this->response->redirect('?controller=task&action=show&task_id='.$task['id']);
- }
+ $this->checkCSRFParam();
- /**
- * Confirmation dialog before to open a task
- *
- * @access public
- */
- public function confirmOpen()
- {
- $task = $this->getTask();
+ if ($this->task->open($task['id'])) {
+ $this->session->flash(t('Task opened successfully.'));
+ } else {
+ $this->session->flashError(t('Unable to open this task.'));
+ }
+
+ $this->response->redirect('?controller=task&action=show&task_id='.$task['id']);
+ }
$this->response->html($this->taskLayout('task_open', array(
'task' => $task,
@@ -303,26 +291,20 @@ class Task extends Base
*/
public function remove()
{
- $this->checkCSRFParam();
$task = $this->getTask();
- if ($this->task->remove($task['id'])) {
- $this->session->flash(t('Task removed successfully.'));
- } else {
- $this->session->flashError(t('Unable to remove this task.'));
- }
+ if ($this->request->getStringParam('confirmation') === 'yes') {
- $this->response->redirect('?controller=board&action=show&project_id='.$task['project_id']);
- }
+ $this->checkCSRFParam();
- /**
- * Confirmation dialog before removing a task
- *
- * @access public
- */
- public function confirmRemove()
- {
- $task = $this->getTask();
+ if ($this->task->remove($task['id'])) {
+ $this->session->flash(t('Task removed successfully.'));
+ } else {
+ $this->session->flashError(t('Unable to remove this task.'));
+ }
+
+ $this->response->redirect('?controller=board&action=show&project_id='.$task['project_id']);
+ }
$this->response->html($this->taskLayout('task_remove', array(
'task' => $task,
@@ -366,63 +348,54 @@ class Task extends Base
*
* @access public
*/
- public function editDescription()
+ public function description()
{
$task = $this->getTask();
+ $ajax = $this->request->isAjax() || $this->request->getIntegerParam('ajax');
- $params = array(
- 'values' => $task,
- 'errors' => array(),
- 'task' => $task,
- 'ajax' => $this->request->isAjax(),
- 'menu' => 'tasks',
- 'title' => t('Edit the description'),
- );
-
- if ($this->request->isAjax()) {
- $this->response->html($this->template->load('task_edit_description', $params));
- }
- else {
- $this->response->html($this->taskLayout('task_edit_description', $params));
- }
- }
+ if ($this->request->isPost()) {
- /**
- * Save and validation the description
- *
- * @access public
- */
- public function saveDescription()
- {
- $task = $this->getTask();
- $values = $this->request->getValues();
+ $values = $this->request->getValues();
- list($valid, $errors) = $this->task->validateDescriptionCreation($values);
+ list($valid, $errors) = $this->task->validateDescriptionCreation($values);
- if ($valid) {
+ if ($valid) {
- if ($this->task->update($values)) {
- $this->session->flash(t('Task updated successfully.'));
- }
- else {
- $this->session->flashError(t('Unable to update your task.'));
- }
+ if ($this->task->update($values)) {
+ $this->session->flash(t('Task updated successfully.'));
+ }
+ else {
+ $this->session->flashError(t('Unable to update your task.'));
+ }
- if ($this->request->getIntegerParam('ajax')) {
- $this->response->redirect('?controller=board&action=show&project_id='.$task['project_id']);
- }
- else {
- $this->response->redirect('?controller=task&action=show&task_id='.$task['id']);
+ if ($ajax) {
+ $this->response->redirect('?controller=board&action=show&project_id='.$task['project_id']);
+ }
+ else {
+ $this->response->redirect('?controller=task&action=show&task_id='.$task['id']);
+ }
}
}
+ else {
+ $values = $task;
+ $errors = array();
+ }
- $this->response->html($this->taskLayout('task_edit_description', array(
+ $params = array(
'values' => $values,
'errors' => $errors,
'task' => $task,
+ 'ajax' => $ajax,
'menu' => 'tasks',
- 'title' => t('Edit the description')
- )));
+ 'title' => t('Edit the description'),
+ );
+
+ if ($ajax) {
+ $this->response->html($this->template->load('task_edit_description', $params));
+ }
+ else {
+ $this->response->html($this->taskLayout('task_edit_description', $params));
+ }
}
/**