diff --git a/module/project/control.php b/module/project/control.php index b95b6d502e..2f9cd23c93 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -1014,7 +1014,9 @@ class project extends control } } - $this->project->setMenu($this->projects, key($this->projects)); + $projectID = key($this->projects); + if($this->session->project) $projectID = $this->session->project; + $this->project->setMenu($this->projects, $projectID); $this->view->title = $this->lang->project->create; $this->view->position[] = $this->view->title; diff --git a/module/story/model.php b/module/story/model.php index 5d6c5cb632..70ac555163 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -495,11 +495,29 @@ class storyModel extends model ->join('mailto', ',') ->join('linkStories', ',') ->join('childStories', ',') - ->remove('files,labels,comment,contactListMenu') + ->remove('files,labels,comment,contactListMenu,stages') ->get(); if(isset($story->plan) and is_array($story->plan)) $story->plan = trim(join(',', $story->plan), ','); if(empty($_POST['product'])) $story->branch = $oldStory->branch; if(empty($_POST['branch'])) $story->branch = 0; + if(!empty($_POST['stages'])) + { + $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) + { + $this->dao->insert(TABLE_STORYSTAGE)->set('story')->eq($storyID)->set('branch')->eq($branch)->set('stage')->eq($stage)->exec(); + if(strpos($stageList, $stage) !== false and strpos($stageList, $stage) < $minStagePos) + { + $minStage = $stage; + $minStagePos = strpos($stageList, $stage); + } + } + $story->stage = $minStage; + } $this->dao->update(TABLE_STORY) ->data($story) diff --git a/module/story/view/edit.html.php b/module/story/view/edit.html.php index 7521b86081..97b8c8da69 100644 --- a/module/story/view/edit.html.php +++ b/module/story/view/edit.html.php @@ -126,7 +126,21 @@ status != 'draft'):?>
' . $branches[$branch] . html::select("stages[$branch]", $lang->story->stageList, $stage, "class='form-control chosen'") . '
'; + } + } + else + { + echo html::select('stage', $lang->story->stageList, $story->stage, "class='form-control chosen'"); + } + ?> +