From 2634006d60c81053beb10fbcf24ba74dcc8ae087 Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Tue, 9 May 2023 18:36:19 +0800 Subject: [PATCH 1/6] * Adjust codes. --- module/execution/model.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/module/execution/model.php b/module/execution/model.php index 04b0769123..aa6fb7029b 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -4863,9 +4863,19 @@ class executionModel extends model $chartData['baseLine'] = $baselineJSON; $execution = $this->getById($executionID); - if((strpos('closed,suspended', $execution->status) === false and helper::today() > $execution->end) - or ($execution->status == 'closed' and substr($execution->closedDate, 0, 10) > $execution->end) - or ($execution->status == 'suspended' and $execution->suspendedDate > $execution->end)) + $isClosed = strpos('closed,suspended', $execution->status) === false && helper::today() > $execution->end; + + /* + * 1. Execution status is not closed and suspended, end date less than today; + * 2. Execution status is closed, end date less than closed date; + * 3. Execution status is suspended, end date less than suspended date; + * Processing burn down chart Information. + */ + $endDate = helper::today(); + if($execution->status == 'closed') $endDate = substr($execution->closedDate, 0, 10); + if($execution->status == 'suspended') $endDate = $execution->suspendedDate; + + if($endDate > $execution->end) { $delaySets = $this->getBurnDataFlot($executionID, $burnBy, true, $dateList); $chartData['delayLine'] = $this->report->createSingleJSON($delaySets, $dateList); @@ -5599,6 +5609,9 @@ class executionModel extends model common::printIcon('execution', 'delete', "stageID=$execution->id&confirm=no", $execution, 'list', 'trash', 'hiddenwin' , $disabled, '', '', $this->lang->programplan->delete); } break; + default: + echo $execution->$id; + break; } echo ''; } From 83a700dba8a2ca0f2f02dc5a4129e9bd29eb5027 Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Tue, 9 May 2023 18:38:16 +0800 Subject: [PATCH 2/6] * Adjust code. --- module/execution/model.php | 1 - 1 file changed, 1 deletion(-) diff --git a/module/execution/model.php b/module/execution/model.php index aa6fb7029b..10f382fc91 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -4863,7 +4863,6 @@ class executionModel extends model $chartData['baseLine'] = $baselineJSON; $execution = $this->getById($executionID); - $isClosed = strpos('closed,suspended', $execution->status) === false && helper::today() > $execution->end; /* * 1. Execution status is not closed and suspended, end date less than today; From a3e66c569948b711a333c110c35596f746b22a64 Mon Sep 17 00:00:00 2001 From: liumengyi Date: Tue, 9 May 2023 18:42:28 +0800 Subject: [PATCH 3/6] * Change array_map to array_column. --- module/task/model.php | 6 +++--- module/task/tao.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/module/task/model.php b/module/task/model.php index 9156f892cf..537396c714 100755 --- a/module/task/model.php +++ b/module/task/model.php @@ -90,7 +90,7 @@ class taskModel extends model if(!empty($team)) { /* Get members, old team and current task. */ - $members = array_map(function($member){return $member->account;}, $team); + $members = array_column($team, 'account'); $oldTeam = zget($oldTask, 'team', array()); $currentTask = !empty($task) ? $task : new stdclass(); if(!isset($currentTask->status)) $currentTask->status = $oldTask->status; @@ -474,7 +474,7 @@ class taskModel extends model { /* Get old team member, and delete old task team. */ $oldTeams = $this->dao->select('*')->from(TABLE_TASKTEAM)->where('task')->eq($task->id)->fetchAll(); - $oldMembers = array_map(function($team){return $team->account;}, $oldTeams); + $oldMembers = array_column($oldTeams, 'account'); $this->dao->delete()->from(TABLE_TASKTEAM)->where('task')->eq($task->id)->exec(); /* If status of the task is doing, get the person who did not complete the task. */ @@ -2311,7 +2311,7 @@ class taskModel extends model /* Check for add effort. */ if(empty($effort)) { - $members = array_map(function($member){ return $member->account; }, $task->team); + $members = array_column($task->team, 'account'); if(!in_array($this->app->user->account, $members)) return false; if($task->mode == 'linear' and $this->app->user->account != $task->assignedTo) return false; return true; diff --git a/module/task/tao.php b/module/task/tao.php index 67cabbeea9..afed1d666c 100644 --- a/module/task/tao.php +++ b/module/task/tao.php @@ -451,7 +451,7 @@ class taskTao extends taskModel /* Format task team members. */ if(!is_array($members)) $members = explode(',', trim($members, ',')); $members = array_values($members); - if(is_object($members[0])) $members = array_map(function($member){return $member->account;}, $members); + if(is_object($members[0])) $members = array_column($members, 'account'); /* Get the member of the first unfinished task. */ $teamHours = array_values($task->team); From b35fc5e738e6e46c5c2fd0faef51b9c89863e8d3 Mon Sep 17 00:00:00 2001 From: zhaoke Date: Tue, 9 May 2023 18:42:54 +0800 Subject: [PATCH 4/6] * Fix get values error from three-dimensional array. --- test/lib/init.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/lib/init.php b/test/lib/init.php index d21ae08263..9cc1a6431b 100644 --- a/test/lib/init.php +++ b/test/lib/init.php @@ -395,7 +395,7 @@ function getValues($value, $keys, $delimiter) } $keys = explode($delimiter, $keys); - if($object) + if($object !== '') { if(is_array($value)) { From a405d9b222194491fb57907818d43686eaa329df Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Tue, 9 May 2023 18:33:30 +0800 Subject: [PATCH 5/6] * Fix code review problem. --- module/caselib/model.php | 2 +- module/caselib/test/model/create.php | 6 +++--- module/caselib/view/browse.html.php | 4 ++-- module/caselib/view/createcase.html.php | 2 +- module/caselib/zen.php | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/module/caselib/model.php b/module/caselib/model.php index c0befbfd22..cba16680af 100644 --- a/module/caselib/model.php +++ b/module/caselib/model.php @@ -181,7 +181,7 @@ class caselibModel extends model * @access public * @return int|false */ - public function create(object $lib, $uid = ''): int|false + public function create(object $lib, string $uid = ''): int|false { $this->lang->testsuite->name = $this->lang->caselib->name; $this->lang->testsuite->desc = $this->lang->caselib->desc; diff --git a/module/caselib/test/model/create.php b/module/caselib/test/model/create.php index cfe0266f5f..4121372d19 100755 --- a/module/caselib/test/model/create.php +++ b/module/caselib/test/model/create.php @@ -18,6 +18,6 @@ $lib_noname = array('name' => ''); $lib_normal = array('name' => 'lib name', 'desc' => 'lib desc'); $lib_repeat = array('name' => 'lib_name'); -r($caselib->createTest($lib_noname)) && p('name:0') && e('『名称』不能为空。'); //测试名称是空时候添加 -r($caselib->createTest($lib_normal)) && p('name') && e('lib name'); //测试添加的名称信息 -r($caselib->createTest($lib_repeat)) && p('name:0') && e('『名称』已经有『lib name』这条记录了。如果您确定该记录已删除,请到后台-系统-数据-回收站还原。'); //测试名称是空时候添加 +r($caselib->createTest($lib_noname)) && p('name:0') && e('『名称』不能为空。'); // 测试名称是空时候添加 +r($caselib->createTest($lib_normal)) && p('name') && e('lib name'); // 测试添加的名称信息 +r($caselib->createTest($lib_repeat)) && p('name:0') && e('『名称』已经有『lib name』这条记录了。如果您确定该记录已删除,请到后台-系统-数据-回收站还原。'); // 测试名称是空时候添加 diff --git a/module/caselib/view/browse.html.php b/module/caselib/view/browse.html.php index 56cfb8a918..ddbcd51e62 100644 --- a/module/caselib/view/browse.html.php +++ b/module/caselib/view/browse.html.php @@ -133,7 +133,7 @@ js::set('flow', $config->global->flow); openedByAB);?> caselib->getFlowExtendFields(); - foreach($extendFields as $extendField) {echo "{$extendField->name}"}; + foreach($extendFields as $extendField) echo "{$extendField->name}"; ?> actions;?> @@ -157,7 +157,7 @@ js::set('flow', $config->global->flow); testcase->typeList[$case->type];?> processStatus('testcase', $case);?> openedBy);?> - " . $this->loadModel('flow')->getFieldValue($extendField, $case) . "";}?> + " . $this->loadModel('flow')->getFieldValue($extendField, $case) . "";?> caselib->buildOperateMenu($case, 'browse');?> diff --git a/module/caselib/view/createcase.html.php b/module/caselib/view/createcase.html.php index 660a310234..cb75da108a 100644 --- a/module/caselib/view/createcase.html.php +++ b/module/caselib/view/createcase.html.php @@ -164,7 +164,7 @@ desc, "rows='1' class='form-control autosize step-steps'") ?> - type)) and $step->type = 'step';?> + type)) $step->type = 'step';?>
type === 'group') echo ' checked' ?>> diff --git a/module/caselib/zen.php b/module/caselib/zen.php index 82ea28010f..c1b0f159cd 100644 --- a/module/caselib/zen.php +++ b/module/caselib/zen.php @@ -9,7 +9,7 @@ class caselibZen extends caselib * @access protected * @return void */ - protected function setCreateMenu() + protected function setCreateMenu(): void { $libraries = $this->caselib->getLibraries(); $libID = $this->caselib->saveLibState(0, $libraries); @@ -23,7 +23,7 @@ class caselibZen extends caselib * @access protected * @return void */ - protected function buildCreateForm() + protected function buildCreateForm(): void { $this->view->title = $this->lang->caselib->common . $this->lang->colon . $this->lang->caselib->create; $this->display(); From 1ba7e6c0ee87c89d9e0776b19e3bc61f6e3b3a77 Mon Sep 17 00:00:00 2001 From: zenggang Date: Tue, 9 May 2023 10:46:06 +0000 Subject: [PATCH 6/6] * Adjust task code --- module/task/control.php | 81 +++++++---------- module/task/model.php | 8 +- module/task/test/model/assign.php | 61 ++++++------- module/task/test/model/updateteam.php | 18 ++-- module/task/test/task.class.php | 7 +- module/task/zen.php | 120 +++++++++++++++++--------- 6 files changed, 156 insertions(+), 139 deletions(-) diff --git a/module/task/control.php b/module/task/control.php index e4c59a3bac..c2e9e44d87 100755 --- a/module/task/control.php +++ b/module/task/control.php @@ -174,41 +174,38 @@ class task extends control } /** - * 编辑任务。 + * 编辑一个任务。 * Edit a task. * * @param string $taskID - * @param string $comment * @param string $from ''|taskkanban * @access public * @return void */ - public function edit(string $taskID, string $comment = '', string $from = '') + public function edit(string $taskID, string $from = '') { $taskID = (int)$taskID; $this->commonAction($taskID); if(!empty($_POST)) { - $this->loadModel('action'); - $changes = array(); - + $changes = array(); $postDataFixer = form::data($this->config->task->form->edit); $rawData = $postDataFixer->rawdata; + /* Prepare and check data. */ + $task = $this->taskZen->prepareEdit($postDataFixer, $taskID); + if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); + /* Update task. */ - if(empty($comment)) - { - $task = $this->taskZen->prepareEdit($postDataFixer, $taskID); - $changes = $this->task->update($task, $rawData); - if(dao::isError()) return print(js::error(dao::getError())); - } + $changes = $this->task->update($task, $rawData); + if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); /* Record log. */ if($rawData->comment != '' or !empty($changes)) { $action = !empty($changes) ? 'Edited' : 'Commented'; - $actionID = $this->action->create('task', $taskID, $action, $rawData->comment); + $actionID = $this->loadModel('action')->create('task', $taskID, $action, $rawData->comment); if(!empty($changes)) $this->action->logHistory($actionID, $changes); } @@ -216,8 +213,8 @@ class task extends control $this->executeHooks($taskID); if($task->status == 'doing') $this->loadModel('common')->syncPPEStatus($taskID); - $reponse = $this->taskZen->reponseAfterEdit($taskID, $from, $changes); - return is_array($reponse) ? $this->send($reponse) : $reponse; + $response = $this->taskZen->responseAfterEdit($taskID, $from, $changes); + return $this->send($response); } $this->taskZen->buildEditForm($taskID); @@ -384,12 +381,8 @@ class task extends control /* Assign task. */ $task = $this->taskZen->prepareAssignTo($postDataFixer, $taskID); - $changes = $this->task->assign($task, $this->post->uid); - if(dao::isError()) - { - if($this->viewType == 'json' or (defined('RUN_MODE') && RUN_MODE == 'api')) return $this->send(array('result' => 'fail', 'message' => dao::getError())); - return print(js::error(dao::getError())); - } + $changes = $this->task->assign($task); + if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); /* Record log. */ $actionID = $this->loadModel('action')->create('task', $taskID, 'Assigned', $this->post->comment, $task->assignedTo); @@ -397,8 +390,8 @@ class task extends control $this->executeHooks($taskID); - $reponse = $this->taskZen->reponseAfterAssignTo($taskID, $from); - return is_array($reponse) ? $this->send($reponse) : $reponse; + $response = $this->taskZen->responseAfterAssignTo($taskID, $from); + return $this->send($response); } $this->taskZen->buildAssignToForm($executionID, $taskID); @@ -432,37 +425,33 @@ class task extends control } /** + * 批量指派任务。 * Batch update assign of task. * - * @param int $execution + * @param string $execution * @access public * @return void */ - public function batchAssignTo($execution) + public function batchAssignTo(string $executionID) { if(!empty($_POST)) { - $this->loadModel('action'); - $taskIDList = $this->post->taskIDList; - $taskIDList = array_unique($taskIDList); - unset($_POST['taskIDList']); - if(!is_array($taskIDList)) return print(js::locate($this->createLink('execution', 'task', "executionID=$execution"), 'parent')); - $taskIDList = array_unique($taskIDList); + $executionID = (int)$executionID; + if(!is_array($this->post->taskIDList)) return print(js::locate($this->createLink('execution', 'task', "executionID={$executionID}"), 'parent')); - $muletipleTasks = $this->dao->select('task, account')->from(TABLE_TASKTEAM)->where('task')->in($taskIDList)->fetchGroup('task', 'account'); - $tasks = $this->task->getByList($taskIDList); $this->loadModel('action'); + $tasks = $this->taskZen->prepareBatchAssignedTasks($this->post->taskIDList, $this->post->assignedTo); foreach($tasks as $taskID => $task) { - if(isset($muletipleTasks[$taskID]) and $task->assignedTo != $this->app->user->account and $task->mode == 'linear') continue; - if(isset($muletipleTasks[$taskID]) and !isset($muletipleTasks[$taskID][$this->post->assignedTo])) continue; - if($task->status == 'closed') continue; - - $changes = $this->task->assign($taskID); + /* Assign task. */ + $changes = $this->task->assign($task); if(dao::isError()) return print(js::error(dao::getError())); + + /* Record log. */ $actionID = $this->action->create('task', $taskID, 'Assigned', $this->post->comment, $this->post->assignedTo); $this->action->logHistory($actionID, $changes); } + if(!dao::isError()) $this->loadModel('score')->create('ajax', 'batchOther'); return print(js::reload('parent')); } @@ -1921,32 +1910,26 @@ class task extends control if(!empty($_POST)) { - $this->loadModel('action'); - /* Update assign of multi task. */ $postData = form::data($this->config->task->form->manageTeam); $task = $this->taskZen->prepareManageTeam($postData, $taskID); $changes = $this->task->updateTeam($task, $this->post->team, $this->post->teamSouce, $this->post->teamEstimate, $this->post->teamConsumed, $this->post->teamLeft); - if(dao::isError()) - { - if($this->viewType == 'json' or (defined('RUN_MODE') && RUN_MODE == 'api')) return $this->send(array('result' => 'fail', 'message' => dao::getError())); - return print(js::error(dao::getError())); - } + if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); /* Record log. */ - $actionID = $this->action->create('task', $taskID, 'Edited'); + $actionID = $this->loadModel('action')->create('task', $taskID, 'Edited'); $this->action->logHistory($actionID, $changes); $this->executeHooks($taskID); - $reponse = $this->taskZen->reponseAfterAssignTo($taskID, $from); - return is_array($reponse) ? $this->send($reponse) : $reponse; + $response = $this->taskZen->responseAfterAssignTo($taskID, $from); + return $this->send($response); } $this->view->members = $this->loadModel('user')->getTeamMemberPairs($executionID, 'execution', 'nodeleted'); $this->view->users = $this->loadModel('user')->getPairs(); - $this->display('', 'editteam'); + $this->display(); } /** diff --git a/module/task/model.php b/module/task/model.php index 537396c714..50dd8788a6 100755 --- a/module/task/model.php +++ b/module/task/model.php @@ -1157,19 +1157,20 @@ class taskModel extends model * @access public * @return array|false */ - public function assign(object $task, string $uid): array|false + public function assign(object $task): array|false { $oldTask = $this->getById($task->id); + /* Check task left. */ if($oldTask->status != 'done' and $oldTask->status != 'closed' and isset($task->left) and $task->left == 0) { dao::$errors[] = sprintf($this->lang->error->notempty, $this->lang->task->left); return false; } + /* Update parent task status. */ if($oldTask->parent > 0) $this->updateParentStatus($task->id); - $task = $this->loadModel('file')->processImgURL($task, $this->config->task->editor->assignto['id'], $uid); $this->dao->update(TABLE_TASK) ->data($task) ->autoCheck() @@ -1216,6 +1217,7 @@ class taskModel extends model } if(empty($teams)) $task->mode = ''; + /* Update parent task status. */ if($oldTask->parent > 0) $this->updateParentStatus($taskID); $this->dao->update(TABLE_TASK) @@ -2707,6 +2709,7 @@ class taskModel extends model } /** + * 获取执行任务的报表数据。 * Get report data of tasks per execution. * * @access public @@ -2719,6 +2722,7 @@ class taskModel extends model $datas = $this->processData4Report($tasks, '', 'execution'); + /* Get execution names for these tasks. */ $executions = $this->loadModel('execution')->getPairs(0, 'all', 'all'); foreach($datas as $executionID => $data) $data->name = isset($executions[$executionID]) ? $executions[$executionID] : $this->lang->report->undefined; return $datas; diff --git a/module/task/test/model/assign.php b/module/task/test/model/assign.php index adf419aad5..9ceb8f43f9 100755 --- a/module/task/test/model/assign.php +++ b/module/task/test/model/assign.php @@ -2,7 +2,6 @@ id->range('1-6'); - $task->execution->range('2,3,3,4'); - $task->name->prefix("任务")->range('1-6'); - $task->left->range('0'); - $task->assignedTo->prefix("old")->range('1-6'); - $task->status->range("wait,doing,done,pause,cancel,closed"); +$task = zdTable('task'); +$task->id->range('1-6'); +$task->execution->range('2,3,3,4'); +$task->name->prefix("任务")->range('1-6'); +$task->left->range('0'); +$task->assignedTo->prefix("old")->range('1-6'); +$task->status->range("wait,doing,done,pause,cancel,closed"); +$task->gen(6); - $task->gen(6); +$user = zdTable('user'); +$user->id->range('1-100'); +$user->account->range('1-100')->prefix('user'); +$user->password->range('f8e41d6c31824c01e5d67c61a8ae49e9,e10adc3949ba59abbe56e057f20f883e'); +$user->realname->range('1-100')->prefix("开发"); +$user->gen(50); - $user = zdTable('user'); - $user->id->range('1-100'); - $user->account->range('1-100')->prefix('user'); - $user->password->range('f8e41d6c31824c01e5d67c61a8ae49e9,e10adc3949ba59abbe56e057f20f883e'); - $user->realname->range('1-100')->prefix("开发"); - $user->gen(50); -} - -initData(); $taskIDlist = array('1','2','3','4','5','6'); -$waitTask = array('assignedTo' => 'user92','status' => 'wait'); -$waitTaskLeft = array('assignedTo' => 'user91','status' => 'wait', 'left' => '1'); -$doingTask = array('assignedTo' => 'user93','status' => 'doing'); -$doneTask = array('assignedTo' => 'user94','status' => 'done'); -$pauseTask = array('assignedTo' => 'user95','status' => 'pause'); -$cancelTask = array('assignedTo' => 'user96','status' => 'cancel'); -$closedTask = array('assignedTo' => 'user97','status' => 'closed'); +$waitTask = array('assignedTo' => 'user92','status' => 'wait'); +$waitTaskLeft = array('assignedTo' => 'user91','status' => 'wait', 'left' => 1); +$doingTask = array('assignedTo' => 'user93','status' => 'doing'); +$doingTaskLeft = array('assignedTo' => 'user90','status' => 'doing', 'left' => 0); +$doneTask = array('assignedTo' => 'user94','status' => 'done'); +$pauseTask = array('assignedTo' => 'user95','status' => 'pause'); +$cancelTask = array('assignedTo' => 'user96','status' => 'cancel'); $task = new taskTest(); r($task->assignTest($taskIDlist[0],$waitTask)) && p('0:field,old,new') && e('assignedTo,old1,user92'); // wait状态任务指派 -r($task->assignTest($taskIDlist[0],$waitTaskLeft)) && p('1:field,old,new') && e('left,0,1'); // wait状态任务指派修改预计剩余 +r($task->assignTest($taskIDlist[0],$waitTaskLeft)) && p('1:field,old,new') && e('left,0,1'); // wait状态任务指派修改预计剩余 r($task->assignTest($taskIDlist[1],$doingTask)) && p('0:field,old,new') && e('assignedTo,old2,user93'); // doing状态任务指派 +r($task->assignTest($taskIDlist[1],$doingTaskLeft)) && p() && e('『预计剩余』不能为空。'); // doing状态任务指派,预计剩余为0 r($task->assignTest($taskIDlist[2],$doneTask)) && p('0:field,old,new') && e('assignedTo,old3,user94'); // done状态任务指派 r($task->assignTest($taskIDlist[3],$pauseTask)) && p('0:field,old,new') && e('assignedTo,old4,user95'); // pause状态任务指派 -r($task->assignTest($taskIDlist[4],$cancelTask)) && p('0:field,old,new') && e('assignedTo,old5,user96'); // cancel状态任务指派 -r($task->assignTest($taskIDlist[5],$closedTask)) && p('0:field,old,new') && e('assignedTo,old6,user97'); // closed状态任务指派 +r($task->assignTest($taskIDlist[4],$cancelTask)) && p('0:field,old,new') && e('assignedTo,old5,user96'); // cancel状态任务指派 \ No newline at end of file diff --git a/module/task/test/model/updateteam.php b/module/task/test/model/updateteam.php index 0c70c1d12b..5f3fa97530 100644 --- a/module/task/test/model/updateteam.php +++ b/module/task/test/model/updateteam.php @@ -2,7 +2,6 @@ mode->range('multi'); - $task->gen(6); +$task = zdTable('task'); +$task->mode->range('multi'); +$task->gen(6); - $user = zdTable('user')->gen(50); -} +$user = zdTable('user')->gen(50); -initData(); $taskIDList = array('1','2','3','4','5','6'); $taskStatusList = array('doing','wait','done'); $teamList = array('user1','user2','user3'); @@ -42,3 +39,4 @@ $task = new taskTest(); r($task->updateTeamTest($taskIDList[0], $taskStatusList[1], array($teamList[0], $teamList[1]), array($teamList[0], $teamList[1]), $teamEstimateList = array(1, 2.5), $teamConsumedList = array(0, 0), $teamLeftList = array(1, 0.5))) && p('1:field,old,new') && e('estimate,0,3.5'); //分配2个成员团队后任务 r($task->updateTeamTest($taskIDList[1], $taskStatusList[1], array($teamList[0]), array($teamList[0]), $teamEstimateList = array(1), $teamConsumedList = array(0), $teamLeftList = array(1))) && p('1:field,old,new') && e('mode,multi,~~'); //分配1个成员团队后任务 r($task->updateTeamTest($taskIDList[2], $taskStatusList[1], array($teamList[0], $teamList[1]), array($teamList[0], $teamList[1]), $teamEstimateList = array(1, 2.5), $teamConsumedList = array(0, 0), $teamLeftList = array(0, 0))) && p() && e('"总计消耗"和"预计剩余"不能同时为0'); //分配预计剩余为0工时团队后任务 +r($task->updateTeamTest($taskIDList[0], $taskStatusList[0], array($teamList[0], $teamList[2]), array($teamList[0], $teamList[1]), $teamEstimateList = array(1, 2.5), $teamConsumedList = array(0, 0), $teamLeftList = array(1, 0.5), true)) && p(1) && e('user3'); //改变团队第二个成员后任务 \ No newline at end of file diff --git a/module/task/test/task.class.php b/module/task/test/task.class.php index 27a18293c4..e3c27dd14c 100644 --- a/module/task/test/task.class.php +++ b/module/task/test/task.class.php @@ -316,7 +316,8 @@ class taskTest unset($_POST); if(dao::isError()) { - return dao::getError(); + $errors = dao::getError(); + return array_shift($errors); } else { @@ -336,7 +337,7 @@ class taskTest * @access public * @return object */ - public function updateTeamTest($taskID, $status, $team, $teamSource, $teamEstimate, $teamConsumed, $teamLeft) + public function updateTeamTest($taskID, $status, $team, $teamSource, $teamEstimate, $teamConsumed, $teamLeft, $getTeam = false) { global $tester; @@ -345,6 +346,8 @@ class taskTest $task->status = $status; $task->lastEditedBy = $tester->app->user->account; $object = $this->objectModel->updateTeam($task, $team, $teamSource, $teamEstimate, $teamConsumed, $teamLeft); + + if($getTeam) return $this->objectModel->getTeamMembers($taskID); if(dao::isError()) { $errors = dao::getError(); diff --git a/module/task/zen.php b/module/task/zen.php index d64b60bc57..55d9b3a094 100644 --- a/module/task/zen.php +++ b/module/task/zen.php @@ -28,38 +28,24 @@ class taskZen extends task * @param form $postDataFixer * @param int $taskID * @access protected - * @return object + * @return object|false */ - protected function prepareEdit(form $postDataFixer, int $taskID): object + protected function prepareEdit(form $postDataFixer, int $taskID): object|false { $now = helper::now(); $oldTask = $this->task->getByID($taskID); $postData = $postDataFixer->get(); - if($postData->estimate < 0 || $postData->left < 0 || $postData->consumed < 0) - { - dao::$errors[] = $this->lang->task->error->recordMinus; - return false; - } - - if(!empty($this->config->limitTaskDate)) - { - $this->task->checkEstStartedAndDeadline($oldTask->execution, $postData->estStarted, $postData->deadline); - return !dao::isError(); - } - - if(!empty($postData->lastEditedDate) && $oldTask->lastEditedDate != $postData->lastEditedDate) - { - dao::$errors[] = $this->lang->error->editedByOther; - return false; - } + /* Check that the data is reasonable. */ + if($postData->estimate < 0 or $postData->left < 0 or $postData->consumed < 0) dao::$errors[] = $this->lang->task->error->recordMinus; + if(!empty($this->config->limitTaskDate)) $this->task->checkEstStartedAndDeadline($oldTask->execution, $postData->estStarted, $postData->deadline); + if(!empty($postData->lastEditedDate) && $oldTask->lastEditedDate != $postData->lastEditedDate) dao::$errors[] = $this->lang->error->editedByOther; + if(dao::isError()) return false; $task = $postDataFixer->add('id', $taskID) ->setIF(!$postData->assignedTo && !empty($oldTask->team) && !empty($postDataFixer->rawdata->team), 'assignedTo', $this->task->getAssignedTo4Multi($postDataFixer->rawdata->team, $oldTask)) ->setIF(!$oldTask->mode && !$postData->assignedTo && !empty($postDataFixer->rawdata->team), 'assignedTo', $postDataFixer->rawdata->team[0]) - ->setIF(is_numeric($postData->estimate), 'estimate', (float)$postData->estimate) - ->setIF(is_numeric($postData->consumed), 'consumed', (float)$postData->consumed) - ->setIF(is_numeric($postData->left), 'left', (float)$postData->left) + ->setIF($oldTask->parent == 0 && $postData->parent == '', 'parent', 0) ->setIF($postData->story != false && $postData->story != $oldTask->story, 'storyVersion', $this->loadModel('story')->getVersion($postData->story)) @@ -91,7 +77,7 @@ class taskZen extends task ->join('mailto', ',') ->get(); - return $task; + return $this->loadModel('file')->processImgURL($task, $this->config->task->editor->edit['id'], $postDataFixer->rawData->uid); } /** @@ -102,10 +88,16 @@ class taskZen extends task * @param string $from ''|taskkanban * @param array[] $changes * @access protected - * @return array|int + * @return array */ - protected function reponseAfterEdit(int $taskID, string $from, array $changes): array|int + protected function responseAfterEdit(int $taskID, string $from, array $changes): array { + if(defined('RUN_MODE') && RUN_MODE == 'api') return array('status' => 'success', 'data' => $taskID); + + $response['result'] = 'success'; + $response['message'] = $this->lang->saveSuccess; + $response['closeModal'] = true; + $task = $this->task->getById($taskID); if($task->fromBug != 0) { @@ -113,17 +105,16 @@ class taskZen extends task { if($change['field'] == 'status') { - $confirmURL = $this->createLink('bug', 'view', "id={$task->fromBug}"); - $cancelURL = $this->server->HTTP_REFERER; - return print(js::confirm(sprintf($this->lang->task->remindBug, $task->fromBug), $confirmURL, $cancelURL, 'parent', 'parent')); + $response['callback'] = "parent.confirmBug('" . sprintf($this->lang->task->remindBug, $task->fromBug) . "', {$task->fromBug})"; + return $response; } } } - if(isonlybody()) return $this->reponseKanban($task, $from); + if(isonlybody()) return $this->responseKanban($task, $from); - if(defined('RUN_MODE') && RUN_MODE == 'api') return array('status' => 'success', 'data' => $taskID); - return print(js::locate($this->createLink('task', 'view', "{taskID=$taskID}"), 'parent')); + $response['locate'] = $this->createLink('task', 'view', "taskID=$taskID"); + return $response; } /** @@ -137,6 +128,8 @@ class taskZen extends task protected function buildEditForm(int $taskID): void { $task = $this->view->task; + + /* Get the task parent id,name pairs. */ $tasks = $this->task->getParentTaskPairs($this->view->execution->id, $task->parent); if(isset($tasks[$taskID])) unset($tasks[$taskID]); @@ -187,7 +180,6 @@ class taskZen extends task */ protected function prepareManageTeam(form $postData, int $taskID): object { - $now = helper::now(); $task = $postData->add('id', $taskID) ->add('lastEditedBy', $this->app->user->account) ->get(); @@ -219,16 +211,16 @@ class taskZen extends task * @param int $taskID * @param string $from ''|taskkanban * @access protected - * @return array|int + * @return array */ - protected function reponseAfterAssignTo(int $taskID, string $from): array|int + protected function responseAfterAssignTo(int $taskID, string $from): array { if($this->viewType == 'json' || (defined('RUN_MODE') && RUN_MODE == 'api')) return array('result' => 'success'); $task = $this->task->getById($taskID); - if(isonlybody()) return $this->reponseKanban($task, $from); + if(isonlybody()) return $this->responseKanban($task, $from); - return print(js::locate($this->createLink('task', 'view', "{taskID=$taskID}"), 'parent')); + return array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true, 'locate' => $this->createLink('task', 'view', "taskID=$taskID")); } /** @@ -271,10 +263,14 @@ class taskZen extends task * @param object $task * @param string $from ''|taskkanban * @access protected - * @return int + * @return array */ - protected function reponseKanban(object $task, string $from): int + protected function responseKanban(object $task, string $from): array { + $response['result'] = 'success'; + $response['message'] = $this->lang->saveSuccess; + $response['closeModal'] = true; + $execution = $this->execution->getByID($task->execution); $execLaneType = $this->session->execLaneType ? $this->session->execLaneType : 'all'; $execGroupBy = $this->session->execGroupBy ? $this->session->execGroupBy : 'default'; @@ -286,7 +282,8 @@ class taskZen extends task $kanbanData = $this->loadModel('kanban')->getRDKanban($task->execution, $execLaneType, 'id_desc', 0, $execGroupBy, $rdSearchValue); $kanbanData = json_encode($kanbanData); - return print(js::closeModal('parent.parent', '', "parent.parent.updateKanban({$kanbanData})")); + $response['callback'] = "parent.parent.updateKanban($kanbanData)"; + return $response; } if($from == 'taskkanban') { @@ -296,9 +293,50 @@ class taskZen extends task $kanbanData = $kanbanData[$kanbanType]; $kanbanData = json_encode($kanbanData); - return print(js::closeModal('parent.parent', '', "parent.parent.updateKanban(\"task\", {$kanbanData})")); + $response['callback'] = "parent.parent.updateKanban(\"task\", $kanbanData)"; + return $response; } - return print(js::closeModal('parent.parent', 'this')); + $response['locate'] = 'parent'; + return $response; + } + + /** + * 准备批量指派的任务数据。 + * Prepare batch assigned tasks. + * + * @param string[] $taskIdList + * @param string $assignedTo + * @access protected + * @return object[] + */ + protected function prepareBatchAssignedTasks(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'); + $tasks = $this->task->getByList($taskIdList); + /* Filter tasks. */ + foreach($tasks as $taskID => $task) + { + if(isset($muletipleTasks[$taskID]) && $task->assignedTo != $this->app->user->account && $task->mode == 'linear') unset($tasks[$taskID]); + if(isset($muletipleTasks[$taskID]) && !isset($muletipleTasks[$taskID][$this->post->assignedTo])) unset($tasks[$taskID]); + if($task->status == 'closed') unset($tasks[$taskID]); + } + + /* Prepare data. */ + $now = helper::now(); + $preTasks = array(); + foreach($tasks as $task) + { + $preTask = new stdclass(); + $preTask->id = $task->id; + $preTask->lastEditedBy = $this->app->user->account; + $preTask->lastEditedDate = $now; + $preTask->assignedDate = $now; + $preTask->assignedTo = $assignedTo; + + $preTasks[] = clone $preTask; + } + return $preTasks; } /**