From abd0127b8f6340ff9e596993c2a126bb5e071e6c Mon Sep 17 00:00:00 2001 From: dingguodong Date: Mon, 4 Sep 2023 11:22:55 +0800 Subject: [PATCH] * Optimize action logging and fix typo. --- module/execution/control.php | 13 ++++--------- module/execution/model.php | 34 +++++++++++++++++++++------------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/module/execution/control.php b/module/execution/control.php index d28b116b21..c331e17c3b 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -2248,15 +2248,9 @@ class execution extends control { $this->loadModel('action'); $this->execution->computeBurn($executionID); - $changes = $this->execution->suspend($executionID); + $this->execution->suspend($executionID); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); - if($this->post->comment != '' or !empty($changes)) - { - $actionID = $this->action->create($this->objectType, $executionID, 'Suspended', $this->post->comment); - $this->action->logHistory($actionID, $changes); - } - $project = $this->loadModel('project')->getById($execution->project); if($project->model == 'waterfall' or $project->model == 'waterfallplus') $this->loadModel('programplan')->computeProgress($executionID, 'suspend'); @@ -2275,10 +2269,11 @@ class execution extends control } /** - * Activate execution. + * 激活一个执行。 + * Activate a execution. * * @param int $executionID - * @param string $frim + * @param string $from * @access public * @return void */ diff --git a/module/execution/model.php b/module/execution/model.php index 906d285b07..bd5da441fb 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -861,7 +861,7 @@ class executionModel extends model if($begin < $parentBegin) { - dao::$errors["begin$executionID"][] = sprintf($this->lang->execution->errorLetterParent, $parentBegin); + dao::$errors["begin$executionID"][] = sprintf($this->lang->execution->errorLesserParent, $parentBegin); } if($end > $parentEnd) @@ -886,12 +886,12 @@ class executionModel extends model { if($executions[$executionID]->begin > $executions[$executionID]->end) { - dao::$errors["end{$executionID}"][] = sprintf($this->lang->execution->errorLetterPlan, $executions[$executionID]->end, $executions[$executionID]->begin); + dao::$errors["end{$executionID}"][] = sprintf($this->lang->execution->errorLesserPlan, $executions[$executionID]->end, $executions[$executionID]->begin); } if($project and $executions[$executionID]->begin < $project->begin) { - dao::$errors["begin{$executionID}"][] = sprintf($this->lang->execution->errorLetterProject, $project->begin); + dao::$errors["begin{$executionID}"][] = sprintf($this->lang->execution->errorLesserProject, $project->begin); } if($project and $executions[$executionID]->end > $project->end) { @@ -1209,9 +1209,9 @@ class executionModel extends model * * @param int $executionID * @access public - * @return array + * @return array|false */ - public function suspend(int $executionID): array + public function suspend(int $executionID): array|false { $oldExecution = $this->getById($executionID); @@ -1232,27 +1232,35 @@ class executionModel extends model ->where('id')->eq($executionID) ->exec(); - if(!dao::isError()) return common::createChanges($oldExecution, $execution); + if(dao::isError()) return false; + + $changes = common::createChanges($oldExecution, $execution); + if(!empty($changes) || $this->post->comment != '') + { + $actionID = $this->action->create($this->objectType, $executionID, 'Suspended', $this->post->comment); + $this->action->logHistory($actionID, $changes); + } + return $changes; } /** - * Activate execution. + * 激活一个执行。 + * Activate a execution. * * @param int $executionID * @access public - * @return void + * @return array|false */ - public function activate($executionID) + public function activate(int $executionID): array|false { $oldExecution = $this->getById($executionID); - $now = helper::now(); $execution = fixer::input('post') ->add('id', $executionID) ->setDefault('realEnd', null) ->setDefault('status', 'doing') ->setDefault('lastEditedBy', $this->app->user->account) - ->setDefault('lastEditedDate', $now) + ->setDefault('lastEditedDate', helper::now()) ->setDefault('closedBy', '') ->setDefault('closedDate', null) ->stripTags($this->config->execution->editor->activate['id'], $this->config->allowedTags) @@ -1263,7 +1271,7 @@ class executionModel extends model $begin = $execution->begin; $end = $execution->end; - if($begin > $end) dao::$errors['end'] = sprintf($this->lang->execution->errorLetterPlan, $end, $begin); + if($begin > $end) dao::$errors['end'] = sprintf($this->lang->execution->errorLesserPlan, $end, $begin); if($oldExecution->grade > 1) { @@ -1274,7 +1282,7 @@ class executionModel extends model $parentEnd = $parent->end; if($begin < $parentBegin) { - dao::$errors['begin'] = sprintf($this->lang->execution->errorLetterParent, $parentBegin); + dao::$errors['begin'] = sprintf($this->lang->execution->errorLesserParent, $parentBegin); } if($end > $parentEnd)