diff --git a/db/update12.3.3.sql b/db/update12.3.3.sql index 5978ebe38a..197a64dfee 100644 --- a/db/update12.3.3.sql +++ b/db/update12.3.3.sql @@ -1,3 +1,6 @@ ALTER TABLE `zt_doccontent` CHANGE `content` `content` longtext NOT NULL AFTER `digest`; +update zt_storystage as a, zt_story as b set a.stage = 'closed', b.stage = 'closed' where a.story = b.id and b.status = 'closed'; + update zt_story set stage = 'closed' where status = 'closed'; + diff --git a/module/story/model.php b/module/story/model.php index 1c35eb8054..b5ebeefb40 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -1114,7 +1114,7 @@ class storyModel extends model /* Update parent story status. */ if($oldStory->parent > 0) $this->updateParentStatus($storyID, $oldStory->parent); - + $this->setStage($storyID); if(!dao::isError()) $this->loadModel('score')->create('story', 'close', $storyID); return common::createChanges($oldStory, $story); } @@ -1183,7 +1183,7 @@ class storyModel extends model { /* Update parent story status. */ if($oldStory->parent > 0) $this->updateParentStatus($storyID, $oldStory->parent); - + $this->setStage($storyID); $allChanges[$storyID] = common::createChanges($oldStory, $story); } else @@ -1437,9 +1437,7 @@ class storyModel extends model $this->dao->delete()->from(TABLE_STORYSTAGE)->where('story')->eq($storyID)->exec(); $story = $this->dao->findById($storyID)->from(TABLE_STORY)->fetch(); - if(!empty($story->stagedBy)) return false; - if($story->status == 'closed') $this->dao->update(TABLE_STORY)->set('stage')->eq('closed')->where('id')->eq($storyID)->exec(); $product = $this->dao->findById($story->product)->from(TABLE_PRODUCT)->fetch(); $projects = $this->dao->select('t1.project,t3.branch')->from(TABLE_PROJECTSTORY)->alias('t1') @@ -1457,6 +1455,15 @@ class storyModel extends model foreach($plans as $branch) $stages[$branch] = 'planned'; } + /* When the status is closed, phase = is also changed to closed. */ + if($story->status == 'closed') + { + $this->dao->update(TABLE_STORY)->set('stage')->eq('closed')->where('id')->eq($storyID)->exec(); + foreach($stages as $branch => $stage) $this->dao->replace(TABLE_STORYSTAGE)->set('story')->eq($storyID)->set('branch')->eq($branch)->set('stage')->eq('closed')->exec(); + foreach($projects as $project => $branch) $this->dao->replace(TABLE_STORYSTAGE)->set('story')->eq($storyID)->set('branch')->eq($branch)->set('stage')->eq('closed')->exec(); + return false; + } + /* If no projects, in plan, stage is planned. No plan, wait. */ if(!$projects) {