diff --git a/module/task/control.php b/module/task/control.php index b279ca2b61..2ff4c5102e 100755 --- a/module/task/control.php +++ b/module/task/control.php @@ -66,25 +66,25 @@ class task extends control if(!empty($_POST)) { /* Prepare the data information before create the task. */ - $result = $this->taskZen->buildForCreate($executionID, (float)$this->post->estimate, $this->post->estStarted, $this->post->deadline, (bool)$this->post->selectTestStory); + $result = $this->taskZen->buildDataForCreate($executionID, (float)$this->post->estimate, $this->post->estStarted, $this->post->deadline, (bool)$this->post->selectTestStory); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); - list($task, $testTasks, $duplicateTaskID) = $result; + list($taskData, $testTaskData, $duplicateTaskID) = $result; if($duplicateTaskID) return $this->send(array('result' => 'success', 'message' => sprintf($this->lang->duplicate, $this->lang->task->common), 'load' => $this->createLink('task', 'view', "taskID={$duplicateTaskID}"))); /* Create task. */ - $taskIdList = $this->task->create($task, $this->post->assignedTo, (int)$this->post->multiple, $this->post->team, (bool)$this->post->selectTestStory, $this->post->teamSource, $this->post->teamEstimate, $this->post->teamConsumed, $this->post->teamLeft); + $taskIdList = $this->task->create($taskData, $this->post->assignedTo, (int)$this->post->multiple, $this->post->team, (bool)$this->post->selectTestStory, $this->post->teamSource, $this->post->teamEstimate, $this->post->teamConsumed, $this->post->teamLeft); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); /* Update other data related to the task after it is created. */ - $task->id = current($taskIdList); + $taskData->id = current($taskIdList); $columnID = isset($output['columnID']) ? (int)$output['columnID'] : 0; - $this->task->afterCreate($task, $taskIdList, $bugID, $todoID, $testTasks); - $this->task->updateKanbanData($execution, $task, (int)$this->post->lane, $columnID); + $this->task->afterCreate($taskData, $taskIdList, $bugID, $todoID, $testTaskData); + $this->task->updateKanbanData($execution, $taskData, (int)$this->post->lane, $columnID); helper::setcookie('lastTaskModule', (int)$this->post->module); /* Get the information returned after a task is created. */ - $response = $this->taskZen->responseAfterCreate($task, $execution, $this->post->after); + $response = $this->taskZen->responseAfterCreate($taskData, $execution, $this->post->after); return $this->send($response); } @@ -122,10 +122,10 @@ class task extends control if(!empty($_POST)) { /* 批量创建任务。 Batch create tasks. */ - $tasks = $this->taskZen->buildTasksForBatchCreate($execution, $taskID); + $taskData = $this->taskZen->buildTasksForBatchCreate($execution, $taskID); if(dao::isError()) return print(js::error(dao::getError())); - $taskIdList = $this->task->batchCreate($execution, $tasks, $taskID, $output); + $taskIdList = $this->task->batchCreate($execution, $taskData, $taskID, $output); if(dao::isError()) return print(js::error(dao::getError())); /* 接口调用返回任务编号列表。 Return task id list when call the API. */ @@ -302,8 +302,8 @@ class task extends control if(!is_array($this->post->taskIDList)) return print(js::locate($this->createLink('execution', 'task', "executionID={$executionID}"), 'parent')); $this->loadModel('action'); - $tasks = $this->taskZen->prepareBatchAssignedTasks($this->post->taskIDList, $this->post->assignedTo); - foreach($tasks as $taskID => $task) + $taskData = $this->taskZen->buildTasksForBatchAssignTo($this->post->taskIDList, $this->post->assignedTo); + foreach($taskData as $taskID => $task) { /* Assign task. */ $changes = $this->task->assign($task); @@ -376,13 +376,7 @@ class task extends control $this->executeHooks($taskID); - $title = "TASK#$task->id $task->name / $execution->name"; - $position[] = html::a($this->createLink('execution', 'browse', "executionID=$task->execution"), $execution->name); - $position[] = $this->lang->task->common; - $position[] = $this->lang->task->view; - - $this->view->title = $title; - $this->view->position = $position; + $this->view->title = "TASK#$task->id $task->name / $execution->name"; $this->view->execution = $execution; $this->view->task = $task; $this->view->actions = $this->loadModel('action')->getList('task', $taskID); @@ -607,10 +601,9 @@ class task extends control return print(js::locate($url, 'parent')); } - $this->view->title = $this->lang->task->editEstimate; - $this->view->position[] = $this->lang->task->editEstimate; - $this->view->estimate = $estimate; - $this->view->task = $this->task->getById($estimate->objectID); + $this->view->title = $this->lang->task->editEstimate; + $this->view->estimate = $estimate; + $this->view->task = $this->task->getById($estimate->objectID); $this->display(); } @@ -753,11 +746,9 @@ class task extends control if($currentTeam) $task->myConsumed = $currentTeam->consumed; } - $this->view->title = $this->view->execution->name . $this->lang->colon .$this->lang->task->finish; - $this->view->position[] = $this->lang->task->finish; - $this->view->members = $members; - $this->view->users = $this->loadModel('user')->getPairs('noletter'); - + $this->view->title = $this->view->execution->name . $this->lang->colon .$this->lang->task->finish; + $this->view->members = $members; + $this->view->users = $this->loadModel('user')->getPairs('noletter'); $this->display(); } @@ -866,8 +857,6 @@ class task extends control } $this->view->title = $this->view->execution->name . $this->lang->colon .$this->lang->task->restart; - $this->view->position[] = $this->lang->task->restart; - $this->view->users = $this->loadModel('user')->getPairs('noletter'); $this->view->members = $this->loadModel('user')->getTeamMemberPairs($task->execution, 'execution', 'nodeleted'); $this->view->assignedTo = $task->assignedTo == '' ? $this->app->user->account : $task->assignedTo; @@ -955,10 +944,8 @@ class task extends control } } - $this->view->title = $this->view->execution->name . $this->lang->colon .$this->lang->task->finish; - $this->view->position[] = $this->lang->task->finish; - $this->view->users = $this->loadModel('user')->getPairs('noletter'); - + $this->view->title = $this->view->execution->name . $this->lang->colon .$this->lang->task->finish; + $this->view->users = $this->loadModel('user')->getPairs('noletter'); $this->display(); } @@ -1157,9 +1144,8 @@ class task extends control $this->view->teamMembers = $teamMembers; } - $this->view->title = $this->view->execution->name . $this->lang->colon . $this->lang->task->activate; - $this->view->position[] = $this->lang->task->activate; - $this->view->users = $this->loadModel('user')->getPairs('noletter'); + $this->view->title = $this->view->execution->name . $this->lang->colon . $this->lang->task->activate; + $this->view->users = $this->loadModel('user')->getPairs('noletter'); $this->display(); } @@ -1353,18 +1339,14 @@ class task extends control $execution = $this->loadModel('execution')->getByID($executionID); if(!$execution->multiple) unset($this->lang->task->report->charts['tasksPerExecution']); - $executions = $this->execution->getPairs(); $this->execution->setMenu($executionID); - $this->executions = $executions; + $this->executions = $this->execution->getPairs(); $this->view->title = $this->executions[$executionID] . $this->lang->colon . $this->lang->task->report->common; - $this->view->position[] = $this->executions[$executionID]; - $this->view->position[] = $this->lang->task->report->common; $this->view->executionID = $executionID; $this->view->browseType = $browseType; $this->view->chartType = $chartType; $this->view->checkedCharts = $this->post->charts ? implode(',', $this->post->charts) : ''; - $this->display(); } diff --git a/module/task/tao.php b/module/task/tao.php index dbb141e9a6..bd7394c4db 100644 --- a/module/task/tao.php +++ b/module/task/tao.php @@ -33,7 +33,7 @@ class taskTao extends taskModel if(dao::isError()) return false; /* Get task id. */ - $taskID = (int)$this->dao->lastInsertID(); + $taskID = $this->dao->lastInsertID(); /* Insert task desc data. */ $taskSpec = new stdclass(); diff --git a/module/task/zen.php b/module/task/zen.php index 423be4ff9a..9eaa1cb09c 100644 --- a/module/task/zen.php +++ b/module/task/zen.php @@ -439,15 +439,15 @@ class taskZen extends task } /** - * 准备批量指派的任务数据。 - * Prepare batch assigned tasks. + * 构造待批量指派的任务数据。 + * Build the task data to batch assign to. * * @param string[] $taskIdList * @param string $assignedTo * @access protected * @return object[] */ - protected function prepareBatchAssignedTasks(array $taskIdList, string $assignedTo): array + protected function buildTasksForBatchAssignTo(array $taskIdList, string $assignedTo): array { $taskIdList = array_unique($taskIdList); $muletipleTasks = $this->dao->select('task, account')->from(TABLE_TASKTEAM)->where('task')->in($taskIdList)->fetchGroup('task', 'account'); @@ -510,12 +510,12 @@ class taskZen extends task * Build the task data to create. * * @param int $executionID - * @param object $formData * @access protected * @return object */ - protected function buildTaskForCreate(int $executionID, object $formData): object + protected function buildTaskForCreate(int $executionID): object { + $formData = form::data($this->config->task->form->create); $postData = $formData->get(); $execution = $this->dao->findById($postData->execution)->from(TABLE_EXECUTION)->fetch(); $team = !empty($postData->team) ? array_filter($postData->team) : array(); @@ -717,7 +717,7 @@ class taskZen extends task * @access protected * @return bool */ - protected function checkCreate(int $executionID, float $estimate, string $estStarted, string $deadline): bool + protected function checkCreateTask(int $executionID, float $estimate, string $estStarted, string $deadline): bool { /* Check if the estimate is positive. */ if($estimate < 0) @@ -768,7 +768,7 @@ class taskZen extends task * @access protected * @return bool */ - protected function checkTestTasks(array $tasks): bool + protected function checkCreateTestTasks(array $tasks): bool { foreach($tasks as $task) { @@ -933,9 +933,9 @@ class taskZen extends task if(!$storyID && !isset($moduleOptionMenu[$task->module])) $task->module = 0; /* Display relevant variables. */ - $this->assignExecution4Create($execution); - $this->assignStory4Create($executionID); - if($execution->type == 'kanban') $this->assignKanban4Create($executionID, $output); + $this->assignExecutionForCreate($execution); + $this->assignStoryForCreate($executionID); + if($execution->type == 'kanban') $this->assignKanbanForCreate($executionID, $output); /* Set Custom fields. */ foreach(explode(',', $this->config->task->customCreateFields) as $field) $customFields[$field] = $this->lang->task->$field; @@ -1023,7 +1023,7 @@ class taskZen extends task * @access protected * @return void */ - protected function assignExecution4Create(object $execution): void + protected function assignExecutionForCreate(object $execution): void { $projectID = $execution ? $execution->project : 0; $lifetimeList = array(); @@ -1065,7 +1065,7 @@ class taskZen extends task * @access protected * @return void */ - protected function assignStory4Create(int $executionID): void + protected function assignStoryForCreate(int $executionID): void { $stories = $this->story->getExecutionStoryPairs($executionID, 0, 'all', '', '', 'active'); $testStoryIdList = $this->loadModel('story')->getTestStories(array_keys($stories), $executionID); @@ -1089,7 +1089,7 @@ class taskZen extends task * @access protected * @return void */ - protected function assignKanban4Create(int $executionID, array $output): void + protected function assignKanbanForCreate(int $executionID, array $output): void { $this->loadModel('kanban'); @@ -1118,22 +1118,21 @@ class taskZen extends task * @access protected * @return false|array */ - protected function buildForCreate(int $executionID, float $estimate, string $estStarted, string $deadline, bool $selectTestStory): false|array + protected function buildDataForCreate(int $executionID, float $estimate, string $estStarted, string $deadline, bool $selectTestStory): false|array { /* Check if the input post data meets the requirements. */ - $result = $this->checkCreate($executionID, $estimate, $estStarted, $deadline); + $result = $this->checkCreateTask($executionID, $estimate, $estStarted, $deadline); if(!$result) return false; /* Process the request data for the create task. */ - $formData = form::data($this->config->task->form->create); - $task = $this->buildTaskForCreate($executionID, $formData); + $task = $this->buildTaskForCreate($executionID); /* Prepare to create the data for the test subtask and to check the data format. */ $testTasks = array(); if($selectTestStory && $task->type == 'test') { - $testTasks = $this->buildTestTasksForCreate($executionID, $formData); - $result = $this->checkTestTasks($testTasks); + $testTasks = $this->buildTestTasksForCreate($executionID); + $result = $this->checkCreateTestTasks($testTasks); if(!$result) return false; } @@ -1148,11 +1147,10 @@ class taskZen extends task * Build subtask data for the test type to create. * * @param int $executionID - * @param object $formData * @access protected * @return array */ - protected function buildTestTasksForCreate(int $executionID, object $formData): array + protected function buildTestTasksForCreate(int $executionID): array { /* Set data for the type of test task that has linked stories. */ $testTasks = array(); @@ -1348,7 +1346,7 @@ class taskZen extends task { /* 获取区域和泳道下拉数据,并设置区域和泳道的默认值。 */ /* Get region and lane dropdown data and set default values for regions and lanes. */ - if($execution->type == 'kanban') $this->assignKanban4Create($execution->id, $output); + if($execution->type == 'kanban') $this->assignKanbanForCreate($execution->id, $output); if($taskID) {