diff --git a/module/story/model.php b/module/story/model.php index b9aa17d8fd..5be24f3135 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -941,7 +941,7 @@ class storyModel extends model ->join('linkStories', ',') ->join('linkRequirements', ',') ->join('childStories', ',') - ->remove('files,labels,comment,contactListMenu,stages,reviewer,needNotReview') + ->remove('files,labels,comment,contactListMenu,reviewer,needNotReview') ->get(); /* Relieve twins when change product. */ @@ -958,35 +958,6 @@ class storyModel extends model if(isset($story->plan) and is_array($story->plan)) $story->plan = trim(join(',', $story->plan), ','); if(isset($_POST['branch']) and $_POST['branch'] == 0) $story->branch = 0; - if(!empty($_POST['stages'])) - { - $oldStages = $this->dao->select('*')->from(TABLE_STORYSTAGE)->where('story')->eq($storyID)->fetchAll('branch'); - $this->dao->delete()->from(TABLE_STORYSTAGE)->where('story')->eq($storyID)->exec(); - - $stageList = join(',', array_keys($this->lang->story->stageList)); - $minStagePos = strlen($stageList); - $minStage = ''; - foreach($this->post->stages as $branch => $stage) - { - $newStage = new stdclass(); - $newStage->story = $storyID; - $newStage->branch = $branch; - $newStage->stage = $stage; - if(isset($oldStages[$branch])) - { - $oldStage = $oldStages[$branch]; - $newStage->stagedBy = $oldStage->stagedBy; - if($stage != $oldStage->stage) $newStage->stagedBy = (strpos('tested|verified|released|closed', $stage) !== false) ? $this->app->user->account : ''; - } - if($story->branch == 0) $this->dao->insert(TABLE_STORYSTAGE)->data($newStage)->exec(); - if(strpos($stageList, $stage) !== false and strpos($stageList, $stage) < $minStagePos) - { - $minStage = $stage; - $minStagePos = strpos($stageList, $stage); - } - } - $story->stage = $minStage; - } if(isset($story->stage) and $oldStory->stage != $story->stage) $story->stagedBy = (strpos('tested|verified|released|closed', $story->stage) !== false) ? $this->app->user->account : ''; $story = $this->loadModel('file')->processImgURL($story, $this->config->story->editor->edit['id'], $this->post->uid); @@ -5111,8 +5082,8 @@ class storyModel extends model $style .= 'overflow: visible;'; $maxStage = $story->stage; - $maxStagePos = 0; $stageList = join(',', array_keys($this->lang->story->stageList)); + $maxStagePos = strpos($stageList, $maxStage); if(isset($storyStages[$story->id])) { foreach($storyStages[$story->id] as $storyBranch => $storyStage) diff --git a/module/story/view/edit.html.php b/module/story/view/edit.html.php index c7b82a1194..061f968f48 100644 --- a/module/story/view/edit.html.php +++ b/module/story/view/edit.html.php @@ -227,17 +227,21 @@ story->stage;?> stage; + $stageList = join(',', array_keys($this->lang->story->stageList)); + $maxStagePos = strpos($stageList, $maxStage); if($story->stages and $branchTagOption) { foreach($story->stages as $branch => $stage) { - if(isset($branchTagOption[$branch])) echo '

' . $branchTagOption[$branch] . html::select("stages[$branch]", $lang->story->stageList, $stage, "class='form-control chosen'") . '

'; + if(strpos($stageList, $stage) !== false and strpos($stageList, $stage) > $maxStagePos) + { + $maxStage = $stage; + $maxStagePos = strpos($stageList, $stage); + } } } - else - { - echo html::select('stage', $lang->story->stageList, $story->stage, "class='form-control chosen'"); - } + echo html::select('stage', $lang->story->stageList, $maxStage, "class='form-control chosen'"); ?> diff --git a/module/story/view/view.html.php b/module/story/view/view.html.php index caf0d7ce21..5b46963ab0 100644 --- a/module/story/view/view.html.php +++ b/module/story/view/view.html.php @@ -303,8 +303,8 @@ stage; - $maxStagePos = 0; $stageList = join(',', array_keys($this->lang->story->stageList)); + $maxStagePos = strpos($stageList, $maxStage); if($story->stages and $branches) { foreach($story->stages as $branch => $stage)