diff --git a/module/story/control.php b/module/story/control.php index 287aef6a30..38cf332d51 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -275,6 +275,7 @@ class story extends control $this->view->verify = $verify; $this->view->keywords = $keywords; $this->view->mailto = $mailto; + $this->view->URS = $type == 'story' ? $this->story->getRequierements($productID) : ''; $this->view->needReview = ($this->app->user->account == $product->PO || $projectID > 0 || $this->config->story->needReview == 0) ? "checked='checked'" : ""; $this->view->type = $type; diff --git a/module/story/model.php b/module/story/model.php index 4ef1eade74..ea0a6d624c 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -155,6 +155,23 @@ class storyModel extends model return $story; } + + /** + * Get requirements for story. + * + * @param int $productID + * @access public + * @return void + */ + public function getRequierements($productID) + { + return $this->dao->select('id,title')->from(TABLE_STORY) + ->where('deleted')->eq(0) + ->andWhere('status')->ne('draft') + ->andWhere('product')->eq($productID) + ->andWhere('type')->eq('requirement') + ->fetchPairs(); + } /** * Create a story. @@ -183,7 +200,7 @@ class storyModel extends model ->setIF($bugID > 0, 'fromBug', $bugID) ->join('mailto', ',') ->stripTags($this->config->story->editor->create['id'], $this->config->allowedTags) - ->remove('files,labels,needNotReview,newStory,uid,contactListMenu') + ->remove('files,labels,needNotReview,newStory,uid,contactListMenu,URS') ->get(); /* Check repeat story. */ @@ -232,6 +249,36 @@ class storyModel extends model ->exec(); } + if(is_array($this->post->URS)) + { + foreach($this->post->URS as $URID) + { + $requirement = $this->getByID($URID); + $data = new stdclass(); + $data->product = $story->product; + $data->AType = 'requirement'; + $data->relation = 'subdivideinto'; + $data->BType = 'story'; + $data->AID = $URID; + $data->BID = $storyID; + $data->AVersion = $requirement->version; + $data->BVersion = 1; + $data->extra = 1; + + $this->dao->insert(TABLE_RELATION)->data($data)->autoCheck()->exec(); + + $data->AType = 'story'; + $data->relation = 'subdividedfrom'; + $data->BType = 'requirement'; + $data->AID = $storyID; + $data->BID = $URID; + $data->AVersion = 1; + $data->BVersion = $requirement->version; + + $this->dao->insert(TABLE_RELATION)->data($data)->autoCheck()->exec(); + } + } + if($bugID > 0) { $bug = new stdclass(); diff --git a/module/story/view/create.html.php b/module/story/view/create.html.php index 897b62c958..ca824ac2c4 100644 --- a/module/story/view/create.html.php +++ b/module/story/view/create.html.php @@ -116,6 +116,12 @@ + +