diff --git a/module/story/lang/de.php b/module/story/lang/de.php index 50deb33691..59d6c945eb 100644 --- a/module/story/lang/de.php +++ b/module/story/lang/de.php @@ -222,6 +222,7 @@ $lang->story->mustChoosePreVersion = 'Version wählen um es umzukhren.'; $lang->story->noStory = 'Keine Storys. '; $lang->story->ignoreChangeStage = 'Story %s is a draft. Please review it..'; $lang->story->cannotDeleteParent = "Can not delete parent {$lang->storyCommon}"; +$lang->story->moveChildrenTips = "Move child {$lang->storyCommon} to selected product when modified product property of parent {$lang->storyCommon}."; $lang->story->form = new stdclass(); $lang->story->form->area = 'Story Bereich'; diff --git a/module/story/lang/en.php b/module/story/lang/en.php index 5f35e81bf2..d877e5399e 100644 --- a/module/story/lang/en.php +++ b/module/story/lang/en.php @@ -225,6 +225,7 @@ $lang->story->mustChoosePreVersion = 'Select a version to revert to.'; $lang->story->noStory = 'No stories yet. '; $lang->story->ignoreChangeStage = 'Story %s is a draft. Please review it..'; $lang->story->cannotDeleteParent = "Can not delete parent {$lang->storyCommon}"; +$lang->story->moveChildrenTips = "Move child {$lang->storyCommon} to selected product when modified product property of parent {$lang->storyCommon}."; $lang->story->form = new stdclass(); $lang->story->form->area = 'Scope'; diff --git a/module/story/lang/fr.php b/module/story/lang/fr.php index 78e0d8bce2..095539eb91 100644 --- a/module/story/lang/fr.php +++ b/module/story/lang/fr.php @@ -222,6 +222,7 @@ $lang->story->mustChoosePreVersion = 'Sélect une version pour revenir en arri $lang->story->noStory = "Aucune story pour l'instant. "; $lang->story->ignoreChangeStage = "Story %s est à l'état brouillon et nécessite d'être complétée et validée..."; $lang->story->cannotDeleteParent = "Can not delete parent {$lang->storyCommon}"; +$lang->story->moveChildrenTips = "Move child {$lang->storyCommon} to selected product when modified product property of parent {$lang->storyCommon}."; $lang->story->form = new stdclass(); $lang->story->form->area = 'Périmètre'; diff --git a/module/story/lang/vi.php b/module/story/lang/vi.php index 0ea7d72142..2b192fcd13 100644 --- a/module/story/lang/vi.php +++ b/module/story/lang/vi.php @@ -222,6 +222,7 @@ $lang->story->mustChoosePreVersion = 'Chọn một phiên bản để chuyển t $lang->story->noStory = 'Không có câu chuyện nào'; $lang->story->ignoreChangeStage = 'Câu chuyện %s là bản nháp. Vui lòng xét duyệt nó..'; $lang->story->cannotDeleteParent = "Không thể xóa {$lang->storyCommon} mẹ"; +$lang->story->moveChildrenTips = "Move child {$lang->storyCommon} to selected product when modified product property of parent {$lang->storyCommon}."; $lang->story->form = new stdclass(); $lang->story->form->area = 'Phạm vi'; diff --git a/module/story/lang/zh-cn.php b/module/story/lang/zh-cn.php index cd9b6406ee..12e53e603a 100644 --- a/module/story/lang/zh-cn.php +++ b/module/story/lang/zh-cn.php @@ -225,6 +225,7 @@ $lang->story->mustChoosePreVersion = '必须选择回溯的版本'; $lang->story->noStory = "暂时没有{$lang->storyCommon}。"; $lang->story->ignoreChangeStage = "{$lang->storyCommon} %s 为草稿状态,没有修改其阶段。"; $lang->story->cannotDeleteParent = "不能删除父{$lang->storyCommon}"; +$lang->story->moveChildrenTips = "修改父{$lang->storyCommon}的所属产品会将其下的子{$lang->storyCommon}也移动到所选产品下。"; $lang->story->form = new stdclass(); $lang->story->form->area = "该{$lang->storyCommon}所属范围"; diff --git a/module/story/model.php b/module/story/model.php index 48b2c125d5..51f704693b 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -597,16 +597,11 @@ class storyModel extends model { if($story->product != $oldStory->product) { - $this->dao->update(TABLE_PROJECTSTORY)->set('product')->eq($story->product)->where('story')->eq($storyID)->exec(); - $storyProjects = $this->dao->select('project')->from(TABLE_PROJECTSTORY)->where('story')->eq($storyID)->orderBy('project')->fetchPairs('project', 'project'); - $linkedProjects = $this->dao->select('project')->from(TABLE_PROJECTPRODUCT)->where('project')->in($storyProjects)->andWhere('product')->eq($story->product)->orderBy('project')->fetchPairs('project','project'); - $unlinkedProjects = array_diff($storyProjects, $linkedProjects); - foreach($unlinkedProjects as $projectID) + $this->updateStoryProduct($storyID, $story->product); + if($oldStory->parent == '-1') { - $data = new stdclass(); - $data->project = $projectID; - $data->product = $story->product; - $this->dao->replace(TABLE_PROJECTPRODUCT)->data($data)->exec(); + $childStories = $this->dao->select('id')->from(TABLE_STORY)->where('parent')->eq($storyID)->andWhere('deleted')->eq(0)->fetchPairs('id'); + foreach($childStories as $childStoryID) $this->updateStoryProduct($childStoryID, $story->product); } } @@ -667,6 +662,30 @@ class storyModel extends model } } + /** + * Update story product. + * + * @param int $storyID + * @param int $productID + * @access public + * @return void + */ + public function updateStoryProduct($storyID, $productID) + { + $this->dao->update(TABLE_STORY)->set('product')->eq($productID)->where('id')->eq($storyID)->exec(); + $this->dao->update(TABLE_PROJECTSTORY)->set('product')->eq($productID)->where('story')->eq($storyID)->exec(); + $storyProjects = $this->dao->select('project')->from(TABLE_PROJECTSTORY)->where('story')->eq($storyID)->orderBy('project')->fetchPairs('project', 'project'); + $linkedProjects = $this->dao->select('project')->from(TABLE_PROJECTPRODUCT)->where('project')->in($storyProjects)->andWhere('product')->eq($productID)->orderBy('project')->fetchPairs('project','project'); + $unlinkedProjects = array_diff($storyProjects, $linkedProjects); + foreach($unlinkedProjects as $projectID) + { + $data = new stdclass(); + $data->project = $projectID; + $data->product = $productID; + $this->dao->replace(TABLE_PROJECTPRODUCT)->data($data)->exec(); + } + } + /** * Update parent status. * diff --git a/module/story/view/edit.html.php b/module/story/view/edit.html.php index 3f82c05ae4..a4b408d994 100644 --- a/module/story/view/edit.html.php +++ b/module/story/view/edit.html.php @@ -11,6 +11,8 @@ */ ?> +children));?> +story->moveChildrenTips);?>