From 69f45681f44fd975bae17b96c6ade47df2c0090f Mon Sep 17 00:00:00 2001 From: tianshujie98 Date: Fri, 25 Sep 2020 16:18:47 +0800 Subject: [PATCH] * Fix bug #3529. --- module/story/model.php | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/module/story/model.php b/module/story/model.php index 2bb1cdf6cb..7c016483e2 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -1231,10 +1231,11 @@ class storyModel extends model */ public function batchChangePlan($storyIdList, $planID, $oldPlanID = 0) { - $now = helper::now(); - $allChanges = array(); - $oldStories = $this->getByList($storyIdList); - $plan = $this->loadModel('productplan')->getById($planID); + $now = helper::now(); + $allChanges = array(); + $oldStories = $this->getByList($storyIdList); + $plan = $this->loadModel('productplan')->getById($planID); + $oldStoryStages = $this->dao->select('*')->from(TABLE_STORYSTAGE)->where('story')->in($storyIdList)->fetchGroup('story', 'branch'); foreach($storyIdList as $storyID) { $oldStory = $oldStories[$storyID]; @@ -1248,16 +1249,27 @@ class storyModel extends model if($this->session->currentProductType == 'normal' or empty($oldPlanID) or $oldStory->branch) { $story->plan = $planID; + if($planID and $oldStory->stage == 'wait') $story->stage = 'planned'; } elseif($oldPlanID) { $story->plan = trim(str_replace(",$oldPlanID,", ',', ",$oldStory->plan,"), ','); if(empty($story->branch)) $story->plan .= ",$planID"; } - if($planID) $story->stage = 'planned'; + if($planID and $this->session->currentProductType != 'normal' and $oldStory->branch == 0) + { + if(!isset($oldStoryStages[$storyID][$plan->branch])) + { + $story->stage = 'planned'; + $newStoryStage = new stdclass(); + $newStoryStage->story = $storyID; + $newStoryStage->branch = $plan->branch; + $newStoryStage->stage = $story->stage; + $this->dao->insert(TABLE_STORYSTAGE)->data($newStoryStage)->autoCheck()->exec(); + } + } $this->dao->update(TABLE_STORY)->data($story)->autoCheck()->where('id')->eq((int)$storyID)->exec(); - $this->dao->update(TABLE_STORYSTAGE)->set('stage')->eq($story->stage)->autoCheck()->where('story')->eq((int)$storyID)->exec(); if(!$planID) $this->setStage($storyID); if(!dao::isError()) $allChanges[$storyID] = common::createChanges($oldStory, $story);