diff --git a/module/story/model.php b/module/story/model.php index ebe6f6de23..f81f058cbc 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -2439,6 +2439,7 @@ class storyModel extends model { $now = helper::now(); $childIdList = $this->getAllChildId($storyID, false); + $childList = $this->getByList($childIdList); $this->dao->update(TABLE_STORY) ->set('status')->eq('closed') ->set('stage')->eq('closed') @@ -2453,7 +2454,13 @@ class storyModel extends model ->exec(); $this->loadModel('action'); - foreach($childIdList as $childID) $this->action->create('story', $childID, 'closedbyparent'); + foreach($childList as $child) + { + $preStatus = $child->status; + $isChanged = !empty($child->changedBy) ? true : false; + if($preStatus == 'reviewing') $preStatus = $isChanged ? 'changing' : 'draft'; + $this->loadModel('action')->create('story', $child->id, 'closedbyparent', '', ucfirst($closedReason) . "|$preStatus"); + } } /** @@ -4988,7 +4995,7 @@ class storyModel extends model public function getActivateStatus(int $storyID, bool $hasTwins = true): string { $status = 'active'; - $action = 'closed,reviewrejected,closedbysystem'; + $action = 'closed,reviewrejected,closedbysystem,closedbyparent'; $action = $hasTwins ? $action . ',synctwins' : $action; $lastRecord = $this->dao->select('action,extra')->from(TABLE_ACTION) ->where('objectType')->eq('story') @@ -5001,7 +5008,7 @@ class storyModel extends model /* Set the status of the story to previous status in latest action log. */ $lastAction = $lastRecord->action; - if(strpos(',closed,reviewrejected,', ",$lastAction,") !== false) + if(strpos(',closed,reviewrejected,closedbyparent,', ",$lastAction,") !== false) { $status = strpos($lastRecord->extra, '|') !== false ? substr($lastRecord->extra, strpos($lastRecord->extra, '|') + 1) : 'active'; if($status == 'closed') $status = 'active'; /* Set the status to active if last status before close it is closed as well. */