diff --git a/module/task/model.php b/module/task/model.php index bf73f5d434..6aee914ec9 100755 --- a/module/task/model.php +++ b/module/task/model.php @@ -62,12 +62,6 @@ class taskModel extends model if($task->left != $oldTask->left) $this->loadModel('program')->refreshProjectStats($oldTask->project); if($oldTask->parent > 0) $this->updateParentStatus($taskID); - if($oldTask->isParent) - { - unset($task->left); - unset($task->id); - $this->taskTao->updateChildrenByParent($taskID, $task, 'Activated', $comment); - } if($oldTask->story) $this->loadModel('story')->setStage($oldTask->story); $this->updateKanbanCell($taskID, $drag, $oldTask->execution); @@ -3299,6 +3293,8 @@ class taskModel extends model $this->dao->update(TABLE_TASK)->set('parent')->eq('0')->set('isParent')->eq(0)->set('path')->eq(",{$parentID},")->where('id')->eq($parentID)->exec(); continue; } + /* 只有子任务是进行中和已完成的时候才更新父任务的状态。*/ + /* Update parent task status only child status is 'doing' or 'done'. */ if(!in_array($status, array('doing', 'done'))) continue; if($parentTask->status == $status) continue; diff --git a/module/task/tao.php b/module/task/tao.php index 6c85b86e77..909f4bada2 100644 --- a/module/task/tao.php +++ b/module/task/tao.php @@ -939,8 +939,7 @@ class taskTao extends taskModel { foreach($members as $account) { - $this->dao->update(TABLE_EFFORT)->set('`left`')->eq(0) - ->where('account')->eq($account) + $this->dao->update(TABLE_EFFORT)->set('`left`')->eq(0)->where('account')->eq($account) ->andWhere('objectID')->eq($taskID) ->andWhere('objectType')->eq('task') ->orderBy('date_desc,id_desc') @@ -951,34 +950,6 @@ class taskTao extends taskModel return !dao::isError(); } - /** - * 通过父任务更新子任务。 - * Update children task by parent task. - * - * @param int $parentID - * @param object $data - * @param string $action Activated - * @param string $comment - * @access protected - * @return void - */ - protected function updateChildrenByParent(int $parentID, object $data, string $action, string $comment): void - { - $oldChildrenTasks = $this->dao->select('*')->from(TABLE_TASK)->where('parent')->eq($parentID)->fetchAll('id'); - $this->dao->update(TABLE_TASK)->data($data)->autoCheck()->where('parent')->eq($parentID)->exec(); - $this->computeWorkingHours($parentID); - - if(!dao::isError() && count($oldChildrenTasks) > 0) - { - $this->loadModel('action'); - foreach($oldChildrenTasks as $oldChildrenTask) - { - $actionID = $this->action->create('task', $oldChildrenTask->id, $action, $comment); - $this->action->logHistory($actionID, common::createChanges($oldChildrenTask, $data)); - } - } - } - /** * 根据子任务以及父任务的状态更新父任务。 * Update parent task status by child and parent status. diff --git a/module/task/test/lib/task.unittest.class.php b/module/task/test/lib/task.unittest.class.php index b095d0b74b..7c4e50d969 100755 --- a/module/task/test/lib/task.unittest.class.php +++ b/module/task/test/lib/task.unittest.class.php @@ -1945,31 +1945,6 @@ class taskTest return $this->objectModel->dao->select('action')->from(TABLE_ACTION)->where('objectType')->eq('task')->andWhere('objectID')->eq($oldParentTask->id)->orderBy('`id` desc')->fetch();; } - /** - * 通过父任务更新子任务。 - * Update children task by parent task. - * - * @param int $parentID - * @param string $action - * @param string $comment - * @access public - * @return object|false - */ - public function updateChildrenByParentTest(int $parentID, string $action, string $comment): object|false - { - $task = $this->objectModel->getByID($parentID); - - $data = new stdclass(); - $data->name = $task->name; - $data->pri = $task->pri; - $data->status = $task->status; - - $this->objectModel->updateChildrenByParent($parentID, $data, $action, $comment); - - $childID = $this->objectModel->dao->select('id')->from(TABLE_TASK)->where('parent')->eq($parentID)->fetch('id'); - return $this->objectModel->dao->select('action')->from(TABLE_ACTION)->where('objectType')->eq('task')->andWhere('objectID')->eq($childID)->orderBy('id_desc')->fetch(); - } - /** * 取消父任务更新子任务。。 * Update a child task when cancel its parent task. diff --git a/module/task/test/tao/updatechildrenbyparent.php b/module/task/test/tao/updatechildrenbyparent.php deleted file mode 100755 index 5a3f698a8a..0000000000 --- a/module/task/test/tao/updatechildrenbyparent.php +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env php -gen(0); -zenData('task')->loadYaml('task', true)->gen(10); - -/** - -title=taskModel->updateChildrenByParent(); -timeout=0 -cid=1 - -*/ - -$parentIdList = array(1, 6, 7); -$actionList = array('Started', 'Activated', 'Closed'); -$commentList = array('', '这是一条备注'); - -$taskTester = new taskTest(); - -r($taskTester->updateChildrenByParentTest($parentIdList[0], $actionList[0], $commentList[0])) && p() && e('0'); // 测试开始普通任务 -r($taskTester->updateChildrenByParentTest($parentIdList[0], $actionList[1], $commentList[0])) && p() && e('0'); // 测试激活普通任务 -r($taskTester->updateChildrenByParentTest($parentIdList[0], $actionList[2], $commentList[0])) && p() && e('0'); // 测试关闭普通任务 -r($taskTester->updateChildrenByParentTest($parentIdList[0], $actionList[0], $commentList[1])) && p() && e('0'); // 测试开始普通任务并留备注 - -r($taskTester->updateChildrenByParentTest($parentIdList[1], $actionList[0], $commentList[0])) && p('action') && e('started'); // 测试开始父任务 -r($taskTester->updateChildrenByParentTest($parentIdList[1], $actionList[1], $commentList[0])) && p('action') && e('activated'); // 测试激活父任务 -r($taskTester->updateChildrenByParentTest($parentIdList[1], $actionList[2], $commentList[0])) && p('action') && e('closed'); // 测试关闭父任务 -r($taskTester->updateChildrenByParentTest($parentIdList[1], $actionList[0], $commentList[1])) && p('action') && e('started'); // 测试开始父任务并留备注 - -r($taskTester->updateChildrenByParentTest($parentIdList[2], $actionList[0], $commentList[0])) && p() && e('0'); // 测试开始子任务 -r($taskTester->updateChildrenByParentTest($parentIdList[2], $actionList[1], $commentList[0])) && p() && e('0'); // 测试激活子任务 -r($taskTester->updateChildrenByParentTest($parentIdList[2], $actionList[2], $commentList[0])) && p() && e('0'); // 测试关闭子任务 -r($taskTester->updateChildrenByParentTest($parentIdList[2], $actionList[0], $commentList[1])) && p() && e('0'); // 测试开始子任务并留备注