getTask(); $this->checkCSRFParam(); $helper = new OrganonDoneHelper($this->container); $done = $helper->isDone($task); if ($helper->closesTask()) { if ($done) { $this->taskStatusModel->open($task['id']); } else { $this->taskStatusModel->close($task['id']); } } else { if ($done) { $this->taskMetadataModel->remove($task['id'], OrganonDoneHelper::DONE_KEY); } else { $this->taskMetadataModel->save($task['id'], array(OrganonDoneHelper::DONE_KEY => 'on')); } } if ($this->request->getStringParam('from') === 'board') { $this->response->redirect($this->helper->url->to('BoardViewController', 'show', array('project_id' => $task['project_id'])), true); } else { $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'])), true); } } /** * Open the "Mark all as Done/Todo" modal for a column: one modal that both confirms and lets the * user pick the direction (two buttons). No state is tracked -- the direction is chosen here. */ public function confirmColumn() { $project = $this->getProject(); $this->checkColumnWriteAccess($project['id']); $this->response->html($this->template->render('organonTweaks:board/mark_all_confirm', array( 'project_id' => $project['id'], 'column_id' => $this->request->getIntegerParam('column_id'), 'swimlane_id' => $this->request->getIntegerParam('swimlane_id'), ))); } /** * Set EVERY task in the column+swimlane to Done or Todo (direction param). Overwrites uniformly -- * already-done tasks are harmlessly re-set. Mode-aware, like the badge: close-mode closes/opens * all; marker-mode sets/clears the metadata on all. */ public function markColumn() { $project = $this->getProject(); $this->checkColumnWriteAccess($project['id']); $this->checkCSRFParam(); $column_id = $this->request->getIntegerParam('column_id'); $swimlane_id = $this->request->getIntegerParam('swimlane_id'); $done = $this->request->getStringParam('direction') === 'done'; $helper = new OrganonDoneHelper($this->container); $closes = $helper->closesTask(); $tasks = $this->db->table(TaskModel::TABLE) ->columns('id') ->eq('project_id', $project['id']) ->eq('column_id', $column_id) ->eq('swimlane_id', $swimlane_id) ->findAll(); foreach ($tasks as $task) { if ($closes) { $done ? $this->taskStatusModel->close($task['id']) : $this->taskStatusModel->open($task['id']); } elseif ($done) { $this->taskMetadataModel->save($task['id'], array(OrganonDoneHelper::DONE_KEY => 'on')); } else { $this->taskMetadataModel->remove($task['id'], OrganonDoneHelper::DONE_KEY); } } $this->flash->success(t('All tasks updated.')); $this->response->redirect($this->helper->url->to('BoardViewController', 'show', array('project_id' => $project['id'])), true); } /** * Guard the bulk action to users who may modify tasks on this board (the menu item is already * gated the same way; this backstops a direct request). */ private function checkColumnWriteAccess($project_id) { if (! $this->helper->user->hasProjectAccess('TaskModificationController', 'update', $project_id)) { throw new AccessForbiddenException(); } } }