From 82b5b491bec94cb3d40a5820fbef9959435309be Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Thu, 26 May 2016 22:23:12 -0400 Subject: Rename task view controller --- app/Controller/Comment.php | 8 +- app/Controller/SubtaskController.php | 6 +- app/Controller/SubtaskConverterController.php | 2 +- app/Controller/SubtaskRestrictionController.php | 2 +- app/Controller/SubtaskStatusController.php | 1 - app/Controller/Task.php | 176 ------------------------ app/Controller/TaskAjaxController.php | 49 +++++++ app/Controller/TaskExternalLink.php | 6 +- app/Controller/TaskFile.php | 6 +- app/Controller/TaskHelper.php | 49 ------- app/Controller/TaskInternalLinkController.php | 6 +- app/Controller/TaskModificationController.php | 6 +- app/Controller/TaskRecurrenceController.php | 2 +- app/Controller/TaskStatusController.php | 2 +- app/Controller/TaskViewController.php | 176 ++++++++++++++++++++++++ app/Controller/Taskduplication.php | 6 +- app/Controller/WebNotificationController.php | 4 +- 17 files changed, 253 insertions(+), 254 deletions(-) delete mode 100644 app/Controller/Task.php create mode 100644 app/Controller/TaskAjaxController.php delete mode 100644 app/Controller/TaskHelper.php create mode 100644 app/Controller/TaskViewController.php (limited to 'app/Controller') diff --git a/app/Controller/Comment.php b/app/Controller/Comment.php index 83a67b41..8d3b7862 100644 --- a/app/Controller/Comment.php +++ b/app/Controller/Comment.php @@ -82,7 +82,7 @@ class Comment extends BaseController $this->flash->failure(t('Unable to create your comment.')); } - return $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), 'comments'), true); + return $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), 'comments'), true); } return $this->create($values, $errors); @@ -131,7 +131,7 @@ class Comment extends BaseController $this->flash->failure(t('Unable to update your comment.')); } - return $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), false); + return $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), false); } return $this->edit($values, $errors); @@ -171,7 +171,7 @@ class Comment extends BaseController $this->flash->failure(t('Unable to remove this comment.')); } - $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), 'comments')); + $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), 'comments')); } /** @@ -186,6 +186,6 @@ class Comment extends BaseController $order = $this->userSession->getCommentSorting() === 'ASC' ? 'DESC' : 'ASC'; $this->userSession->setCommentSorting($order); - $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), 'comments')); + $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), 'comments')); } } diff --git a/app/Controller/SubtaskController.php b/app/Controller/SubtaskController.php index 830548da..26659fb4 100644 --- a/app/Controller/SubtaskController.php +++ b/app/Controller/SubtaskController.php @@ -64,7 +64,7 @@ class SubtaskController extends BaseController return $this->create(array('project_id' => $task['project_id'], 'task_id' => $task['id'], 'another_subtask' => 1)); } - return $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id']), 'subtasks'), true); + return $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id']), 'subtasks'), true); } return $this->create($values, $errors); @@ -114,7 +114,7 @@ class SubtaskController extends BaseController $this->flash->failure(t('Unable to update your sub-task.')); } - return $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true); + return $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true); } return $this->edit($values, $errors); @@ -153,7 +153,7 @@ class SubtaskController extends BaseController $this->flash->failure(t('Unable to remove this sub-task.')); } - $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true); + $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true); } /** diff --git a/app/Controller/SubtaskConverterController.php b/app/Controller/SubtaskConverterController.php index 829b937a..8a3021e2 100644 --- a/app/Controller/SubtaskConverterController.php +++ b/app/Controller/SubtaskConverterController.php @@ -34,6 +34,6 @@ class SubtaskConverterController extends BaseController $this->flash->failure(t('Unable to convert the subtask.')); } - $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $project['id'], 'task_id' => $task_id)), true); + $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('project_id' => $project['id'], 'task_id' => $task_id)), true); } } diff --git a/app/Controller/SubtaskRestrictionController.php b/app/Controller/SubtaskRestrictionController.php index 185371e7..77626ba9 100644 --- a/app/Controller/SubtaskRestrictionController.php +++ b/app/Controller/SubtaskRestrictionController.php @@ -56,6 +56,6 @@ class SubtaskRestrictionController extends BaseController 'status' => SubtaskModel::STATUS_INPROGRESS, )); - $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true); + $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true); } } diff --git a/app/Controller/SubtaskStatusController.php b/app/Controller/SubtaskStatusController.php index e24002dc..909123ec 100644 --- a/app/Controller/SubtaskStatusController.php +++ b/app/Controller/SubtaskStatusController.php @@ -66,7 +66,6 @@ class SubtaskStatusController extends BaseController 'task' => $task, 'subtasks' => $this->subtask->getAll($task['id']), 'editable' => true, - 'redirect' => 'task', )); } } diff --git a/app/Controller/Task.php b/app/Controller/Task.php deleted file mode 100644 index 1ce13f69..00000000 --- a/app/Controller/Task.php +++ /dev/null @@ -1,176 +0,0 @@ -project->getByToken($this->request->getStringParam('token')); - - // Token verification - if (empty($project)) { - throw AccessForbiddenException::getInstance()->withoutLayout(); - } - - $task = $this->taskFinder->getDetails($this->request->getIntegerParam('task_id')); - - if (empty($task)) { - throw PageNotFoundException::getInstance()->withoutLayout(); - } - - if ($task['project_id'] != $project['id']) { - throw AccessForbiddenException::getInstance()->withoutLayout(); - } - - $this->response->html($this->helper->layout->app('task/public', array( - 'project' => $project, - 'comments' => $this->comment->getAll($task['id']), - 'subtasks' => $this->subtask->getAll($task['id']), - 'links' => $this->taskLink->getAllGroupedByLabel($task['id']), - 'task' => $task, - 'columns_list' => $this->column->getList($task['project_id']), - 'colors_list' => $this->color->getList(), - 'title' => $task['title'], - 'no_layout' => true, - 'auto_refresh' => true, - 'not_editable' => true, - ))); - } - - /** - * Show a task - * - * @access public - */ - public function show() - { - $task = $this->getTask(); - $subtasks = $this->subtask->getAll($task['id']); - - $values = array( - 'id' => $task['id'], - 'date_started' => $task['date_started'], - 'time_estimated' => $task['time_estimated'] ?: '', - 'time_spent' => $task['time_spent'] ?: '', - ); - - $values = $this->dateParser->format($values, array('date_started'), $this->config->get('application_datetime_format', DateParser::DATE_TIME_FORMAT)); - - $this->response->html($this->helper->layout->task('task/show', array( - 'task' => $task, - 'project' => $this->project->getById($task['project_id']), - 'values' => $values, - 'files' => $this->taskFile->getAllDocuments($task['id']), - 'images' => $this->taskFile->getAllImages($task['id']), - 'comments' => $this->comment->getAll($task['id'], $this->userSession->getCommentSorting()), - 'subtasks' => $subtasks, - 'internal_links' => $this->taskLink->getAllGroupedByLabel($task['id']), - 'external_links' => $this->taskExternalLink->getAll($task['id']), - 'link_label_list' => $this->link->getList(0, false), - ))); - } - - /** - * Display task analytics - * - * @access public - */ - public function analytics() - { - $task = $this->getTask(); - - $this->response->html($this->helper->layout->task('task/analytics', array( - 'task' => $task, - 'project' => $this->project->getById($task['project_id']), - 'lead_time' => $this->taskAnalytic->getLeadTime($task), - 'cycle_time' => $this->taskAnalytic->getCycleTime($task), - 'time_spent_columns' => $this->taskAnalytic->getTimeSpentByColumn($task), - ))); - } - - /** - * Display the time tracking details - * - * @access public - */ - public function timetracking() - { - $task = $this->getTask(); - - $subtask_paginator = $this->paginator - ->setUrl('task', 'timetracking', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'pagination' => 'subtasks')) - ->setMax(15) - ->setOrder('start') - ->setDirection('DESC') - ->setQuery($this->subtaskTimeTracking->getTaskQuery($task['id'])) - ->calculateOnlyIf($this->request->getStringParam('pagination') === 'subtasks'); - - $this->response->html($this->helper->layout->task('task/time_tracking_details', array( - 'task' => $task, - 'project' => $this->project->getById($task['project_id']), - 'subtask_paginator' => $subtask_paginator, - ))); - } - - /** - * Display the task transitions - * - * @access public - */ - public function transitions() - { - $task = $this->getTask(); - - $this->response->html($this->helper->layout->task('task/transitions', array( - 'task' => $task, - 'project' => $this->project->getById($task['project_id']), - 'transitions' => $this->transition->getAllByTask($task['id']), - ))); - } - - /** - * Remove a task - * - * @access public - */ - public function remove() - { - $task = $this->getTask(); - - if (! $this->helper->user->canRemoveTask($task)) { - throw new AccessForbiddenException(); - } - - if ($this->request->getStringParam('confirmation') === 'yes') { - $this->checkCSRFParam(); - - if ($this->task->remove($task['id'])) { - $this->flash->success(t('Task removed successfully.')); - } else { - $this->flash->failure(t('Unable to remove this task.')); - } - - return $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id'])), true); - } - - return $this->response->html($this->template->render('task/remove', array( - 'task' => $task, - ))); - } -} diff --git a/app/Controller/TaskAjaxController.php b/app/Controller/TaskAjaxController.php new file mode 100644 index 00000000..d630b962 --- /dev/null +++ b/app/Controller/TaskAjaxController.php @@ -0,0 +1,49 @@ +request->getStringParam('term'); + $project_ids = $this->projectPermission->getActiveProjectIds($this->userSession->getId()); + $exclude_task_id = $this->request->getIntegerParam('exclude_task_id'); + + if (empty($project_ids)) { + $this->response->json(array()); + } else { + + $filter = $this->taskQuery->withFilter(new TaskProjectsFilter($project_ids)); + + if (! empty($exclude_task_id)) { + $filter->withFilter(new TaskIdExclusionFilter(array($exclude_task_id))); + } + + if (ctype_digit($search)) { + $filter->withFilter(new TaskIdFilter($search)); + } else { + $filter->withFilter(new TaskTitleFilter($search)); + } + + $this->response->json($filter->format(new TaskAutoCompleteFormatter($this->container))); + } + } +} diff --git a/app/Controller/TaskExternalLink.php b/app/Controller/TaskExternalLink.php index 9f040957..0bd55dba 100644 --- a/app/Controller/TaskExternalLink.php +++ b/app/Controller/TaskExternalLink.php @@ -78,7 +78,7 @@ class TaskExternalLink extends BaseController if ($valid && $this->taskExternalLink->create($values)) { $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); + return $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true); } return $this->edit($values, $errors); @@ -130,7 +130,7 @@ class TaskExternalLink extends BaseController if ($valid && $this->taskExternalLink->update($values)) { $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'])), true); + return $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true); } return $this->edit($values, $errors); @@ -173,6 +173,6 @@ class TaskExternalLink extends BaseController $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']))); + $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']))); } } diff --git a/app/Controller/TaskFile.php b/app/Controller/TaskFile.php index 0fcd2d69..544c1ea7 100644 --- a/app/Controller/TaskFile.php +++ b/app/Controller/TaskFile.php @@ -21,7 +21,7 @@ class TaskFile extends BaseController if ($this->request->isPost() && $this->taskFile->uploadScreenshot($task['id'], $this->request->getValue('screenshot')) !== false) { $this->flash->success(t('Screenshot uploaded successfully.')); - return $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true); + 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( @@ -57,7 +57,7 @@ class TaskFile extends BaseController $this->flash->failure(t('Unable to upload the file.')); } - $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true); + $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true); } /** @@ -77,7 +77,7 @@ class TaskFile extends BaseController $this->flash->failure(t('Unable to remove this file.')); } - $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']))); + $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']))); } /** diff --git a/app/Controller/TaskHelper.php b/app/Controller/TaskHelper.php deleted file mode 100644 index 2f14c0eb..00000000 --- a/app/Controller/TaskHelper.php +++ /dev/null @@ -1,49 +0,0 @@ -request->getStringParam('term'); - $project_ids = $this->projectPermission->getActiveProjectIds($this->userSession->getId()); - $exclude_task_id = $this->request->getIntegerParam('exclude_task_id'); - - if (empty($project_ids)) { - $this->response->json(array()); - } else { - - $filter = $this->taskQuery->withFilter(new TaskProjectsFilter($project_ids)); - - if (! empty($exclude_task_id)) { - $filter->withFilter(new TaskIdExclusionFilter(array($exclude_task_id))); - } - - if (ctype_digit($search)) { - $filter->withFilter(new TaskIdFilter($search)); - } else { - $filter->withFilter(new TaskTitleFilter($search)); - } - - $this->response->json($filter->format(new TaskAutoCompleteFormatter($this->container))); - } - } -} diff --git a/app/Controller/TaskInternalLinkController.php b/app/Controller/TaskInternalLinkController.php index f97426c6..4018c3a5 100644 --- a/app/Controller/TaskInternalLinkController.php +++ b/app/Controller/TaskInternalLinkController.php @@ -67,7 +67,7 @@ class TaskInternalLinkController extends BaseController 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); + return $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true); } $errors = array('title' => array(t('The exact same link already exists'))); @@ -121,7 +121,7 @@ class TaskInternalLinkController extends BaseController 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'); + return $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])).'#links'); } $this->flash->failure(t('Unable to update your link.')); @@ -162,6 +162,6 @@ class TaskInternalLinkController extends BaseController $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']))); + $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']))); } } diff --git a/app/Controller/TaskModificationController.php b/app/Controller/TaskModificationController.php index 47c07511..09a8fabe 100644 --- a/app/Controller/TaskModificationController.php +++ b/app/Controller/TaskModificationController.php @@ -21,7 +21,7 @@ class TaskModificationController extends BaseController { $task = $this->getTask(); $this->taskModification->update(array('id' => $task['id'], 'date_started' => time())); - $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id']))); + $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id']))); } /** @@ -67,7 +67,7 @@ class TaskModificationController extends BaseController $this->flash->failure(t('Unable to update your task.')); } - return $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true); + return $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true); } return $this->description($values, $errors); @@ -121,7 +121,7 @@ class TaskModificationController extends BaseController if ($valid && $this->taskModification->update($values)) { $this->flash->success(t('Task updated successfully.')); - $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true); + $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true); } else { $this->flash->failure(t('Unable to update your task.')); $this->edit($values, $errors); diff --git a/app/Controller/TaskRecurrenceController.php b/app/Controller/TaskRecurrenceController.php index 1acf4038..cd9a2c92 100644 --- a/app/Controller/TaskRecurrenceController.php +++ b/app/Controller/TaskRecurrenceController.php @@ -57,7 +57,7 @@ class TaskRecurrenceController extends BaseController $this->flash->failure(t('Unable to update your task.')); } - return $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true); + return $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true); } return $this->edit($values, $errors); diff --git a/app/Controller/TaskStatusController.php b/app/Controller/TaskStatusController.php index fca168ec..98ab4e1e 100644 --- a/app/Controller/TaskStatusController.php +++ b/app/Controller/TaskStatusController.php @@ -52,7 +52,7 @@ class TaskStatusController extends BaseController $this->flash->failure($failure_message); } - return $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true); + 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($template, array( diff --git a/app/Controller/TaskViewController.php b/app/Controller/TaskViewController.php new file mode 100644 index 00000000..833d42a4 --- /dev/null +++ b/app/Controller/TaskViewController.php @@ -0,0 +1,176 @@ +project->getByToken($this->request->getStringParam('token')); + + // Token verification + if (empty($project)) { + throw AccessForbiddenException::getInstance()->withoutLayout(); + } + + $task = $this->taskFinder->getDetails($this->request->getIntegerParam('task_id')); + + if (empty($task)) { + throw PageNotFoundException::getInstance()->withoutLayout(); + } + + if ($task['project_id'] != $project['id']) { + throw AccessForbiddenException::getInstance()->withoutLayout(); + } + + $this->response->html($this->helper->layout->app('task/public', array( + 'project' => $project, + 'comments' => $this->comment->getAll($task['id']), + 'subtasks' => $this->subtask->getAll($task['id']), + 'links' => $this->taskLink->getAllGroupedByLabel($task['id']), + 'task' => $task, + 'columns_list' => $this->column->getList($task['project_id']), + 'colors_list' => $this->color->getList(), + 'title' => $task['title'], + 'no_layout' => true, + 'auto_refresh' => true, + 'not_editable' => true, + ))); + } + + /** + * Show a task + * + * @access public + */ + public function show() + { + $task = $this->getTask(); + $subtasks = $this->subtask->getAll($task['id']); + + $values = array( + 'id' => $task['id'], + 'date_started' => $task['date_started'], + 'time_estimated' => $task['time_estimated'] ?: '', + 'time_spent' => $task['time_spent'] ?: '', + ); + + $values = $this->dateParser->format($values, array('date_started'), $this->config->get('application_datetime_format', DateParser::DATE_TIME_FORMAT)); + + $this->response->html($this->helper->layout->task('task/show', array( + 'task' => $task, + 'project' => $this->project->getById($task['project_id']), + 'values' => $values, + 'files' => $this->taskFile->getAllDocuments($task['id']), + 'images' => $this->taskFile->getAllImages($task['id']), + 'comments' => $this->comment->getAll($task['id'], $this->userSession->getCommentSorting()), + 'subtasks' => $subtasks, + 'internal_links' => $this->taskLink->getAllGroupedByLabel($task['id']), + 'external_links' => $this->taskExternalLink->getAll($task['id']), + 'link_label_list' => $this->link->getList(0, false), + ))); + } + + /** + * Display task analytics + * + * @access public + */ + public function analytics() + { + $task = $this->getTask(); + + $this->response->html($this->helper->layout->task('task/analytics', array( + 'task' => $task, + 'project' => $this->project->getById($task['project_id']), + 'lead_time' => $this->taskAnalytic->getLeadTime($task), + 'cycle_time' => $this->taskAnalytic->getCycleTime($task), + 'time_spent_columns' => $this->taskAnalytic->getTimeSpentByColumn($task), + ))); + } + + /** + * Display the time tracking details + * + * @access public + */ + public function timetracking() + { + $task = $this->getTask(); + + $subtask_paginator = $this->paginator + ->setUrl('TaskViewController', 'timetracking', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'pagination' => 'subtasks')) + ->setMax(15) + ->setOrder('start') + ->setDirection('DESC') + ->setQuery($this->subtaskTimeTracking->getTaskQuery($task['id'])) + ->calculateOnlyIf($this->request->getStringParam('pagination') === 'subtasks'); + + $this->response->html($this->helper->layout->task('task/time_tracking_details', array( + 'task' => $task, + 'project' => $this->project->getById($task['project_id']), + 'subtask_paginator' => $subtask_paginator, + ))); + } + + /** + * Display the task transitions + * + * @access public + */ + public function transitions() + { + $task = $this->getTask(); + + $this->response->html($this->helper->layout->task('task/transitions', array( + 'task' => $task, + 'project' => $this->project->getById($task['project_id']), + 'transitions' => $this->transition->getAllByTask($task['id']), + ))); + } + + /** + * Remove a task + * + * @access public + */ + public function remove() + { + $task = $this->getTask(); + + if (! $this->helper->user->canRemoveTask($task)) { + throw new AccessForbiddenException(); + } + + if ($this->request->getStringParam('confirmation') === 'yes') { + $this->checkCSRFParam(); + + if ($this->task->remove($task['id'])) { + $this->flash->success(t('Task removed successfully.')); + } else { + $this->flash->failure(t('Unable to remove this task.')); + } + + return $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id'])), true); + } + + return $this->response->html($this->template->render('task/remove', array( + 'task' => $task, + ))); + } +} diff --git a/app/Controller/Taskduplication.php b/app/Controller/Taskduplication.php index ff60228e..1ea3a3f9 100644 --- a/app/Controller/Taskduplication.php +++ b/app/Controller/Taskduplication.php @@ -25,7 +25,7 @@ class Taskduplication extends BaseController if ($task_id > 0) { $this->flash->success(t('Task created successfully.')); - return $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task_id))); + return $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('project_id' => $task['project_id'], 'task_id' => $task_id))); } else { $this->flash->failure(t('Unable to create this task.')); return $this->response->redirect($this->helper->url->to('taskduplication', 'duplicate', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true); @@ -57,7 +57,7 @@ class Taskduplication extends BaseController $values['category_id'], $values['owner_id'])) { $this->flash->success(t('Task updated successfully.')); - return $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $values['project_id'], 'task_id' => $task['id']))); + return $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('project_id' => $values['project_id'], 'task_id' => $task['id']))); } $this->flash->failure(t('Unable to update your task.')); @@ -87,7 +87,7 @@ class Taskduplication extends BaseController if ($task_id > 0) { $this->flash->success(t('Task created successfully.')); - return $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $values['project_id'], 'task_id' => $task_id))); + return $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('project_id' => $values['project_id'], 'task_id' => $task_id))); } } diff --git a/app/Controller/WebNotificationController.php b/app/Controller/WebNotificationController.php index c7b9c8ff..263d6d9e 100644 --- a/app/Controller/WebNotificationController.php +++ b/app/Controller/WebNotificationController.php @@ -52,14 +52,14 @@ class WebNotificationController extends BaseController $this->response->redirect($this->helper->url->to('DashboardController', 'notifications', array('user_id' => $user_id))); } elseif ($this->helper->text->contains($notification['event_name'], 'comment')) { $this->response->redirect($this->helper->url->to( - 'task', + 'TaskViewController', 'show', array('task_id' => $notification['event_data']['task']['id'], 'project_id' => $notification['event_data']['task']['project_id']), 'comment-'.$notification['event_data']['comment']['id'] )); } else { $this->response->redirect($this->helper->url->to( - 'task', + 'TaskViewController', 'show', array('task_id' => $notification['event_data']['task']['id'], 'project_id' => $notification['event_data']['task']['project_id']) )); -- cgit v1.2.3