diff --git a/module/group/lang/resource.php b/module/group/lang/resource.php
index 9e771ff3c5..7aa9981f78 100644
--- a/module/group/lang/resource.php
+++ b/module/group/lang/resource.php
@@ -172,9 +172,10 @@ $lang->resource->story->activate = 'lblActivate';
$lang->resource->story->tasks = 'tasks';
$lang->resource->story->zeroCase = 'zeroCase';
$lang->resource->story->report = 'reportChart';
-$lang->resource->story->batchChangePlan = 'batchChangePlan';
-$lang->resource->story->batchChangeStage = 'batchChangeStage';
-$lang->resource->story->batchAssignTo = 'batchAssignTo';
+$lang->resource->story->batchChangePlan = 'batchChangePlan';
+$lang->resource->story->batchChangeBranch = 'batchChangeBranch';
+$lang->resource->story->batchChangeStage = 'batchChangeStage';
+$lang->resource->story->batchAssignTo = 'batchAssignTo';
$lang->story->methodOrder[5] = 'create';
$lang->story->methodOrder[10] = 'batchCreate';
@@ -194,6 +195,7 @@ $lang->story->methodOrder[75] = 'activate';
$lang->story->methodOrder[80] = 'tasks';
$lang->story->methodOrder[85] = 'zeroCase';
$lang->story->methodOrder[90] = 'report';
+$lang->story->methodOrder[95] = 'batchChangeBranch';
/* Product plan. */
$lang->resource->productplan = new stdclass();
@@ -1110,3 +1112,5 @@ $lang->changelog['7.4.beta'][] = 'user-unbind';
$lang->changelog['7.4.beta'][] = 'branch-manage';
$lang->changelog['7.4.beta'][] = 'branch-delete';
$lang->changelog['7.4.beta'][] = 'my-unbind';
+
+$lang->changelog['8.0'][] = 'story-batchChangeBranch';
diff --git a/module/product/view/browse.html.php b/module/product/view/browse.html.php
index 7fd3345e48..6591d00cee 100644
--- a/module/product/view/browse.html.php
+++ b/module/product/view/browse.html.php
@@ -200,6 +200,21 @@
echo '
' . html::a('javascript:;', $lang->story->review, '', $class) . '';
}
+ if(common::hasPriv('story', 'batchChangeBranch') and $this->session->currentProductType != 'normal')
+ {
+ $withSearch = count($branches) > 8;
+ echo "';
+ }
+
if(common::hasPriv('story', 'batchChangePlan'))
{
unset($plans['']);
diff --git a/module/story/control.php b/module/story/control.php
index 3d8191456a..bdbdc6cefb 100644
--- a/module/story/control.php
+++ b/module/story/control.php
@@ -794,6 +794,27 @@ class story extends control
die(js::reload('parent'));
}
+ /**
+ * Batch change branch.
+ *
+ * @param int $branchID
+ * @access public
+ * @return void
+ */
+ public function batchChangeBranch($branchID)
+ {
+ $storyIDList = !empty($_POST['storyIDList']) ? $this->post->storyIDList : die(js::locate($this->session->storyList, 'parent'));
+ $allChanges = $this->story->batchChangeBranch($storyIDList, $branchID);
+ if(dao::isError()) die(js::error(dao::getError()));
+ foreach($allChanges as $storyID => $changes)
+ {
+ $actionID = $this->action->create('story', $storyID, 'Edited');
+ $this->action->logHistory($actionID, $changes);
+ $this->sendmail($storyID, $actionID);
+ }
+ die(js::reload('parent'));
+ }
+
/**
* Batch change the stage of story.
*
diff --git a/module/story/lang/en.php b/module/story/lang/en.php
index f320623e36..39ec8f43c3 100644
--- a/module/story/lang/en.php
+++ b/module/story/lang/en.php
@@ -32,9 +32,10 @@ $lang->story->linkStory = 'Related story';
$lang->story->export = "Export data";
$lang->story->zeroCase = "Story of zero case";
$lang->story->reportChart = "Report";
-$lang->story->batchChangePlan = "Batch change plan";
-$lang->story->batchChangeStage = "Batch change stage";
-$lang->story->batchAssignTo = "Batch assignto";
+$lang->story->batchChangePlan = "Batch change plan";
+$lang->story->batchChangeBranch = "Batch change branch";
+$lang->story->batchChangeStage = "Batch change stage";
+$lang->story->batchAssignTo = "Batch assignto";
$lang->story->common = 'Story';
$lang->story->id = 'ID';
diff --git a/module/story/lang/zh-cn.php b/module/story/lang/zh-cn.php
index 3b71a88b52..51fbff6ca7 100644
--- a/module/story/lang/zh-cn.php
+++ b/module/story/lang/zh-cn.php
@@ -32,9 +32,10 @@ $lang->story->linkStory = '关联需求';
$lang->story->export = "导出数据";
$lang->story->zeroCase = "零用例需求";
$lang->story->reportChart = "统计报表";
-$lang->story->batchChangePlan = "批量修改计划";
-$lang->story->batchChangeStage = "批量修改阶段";
-$lang->story->batchAssignTo = "批量指派";
+$lang->story->batchChangePlan = "批量修改计划";
+$lang->story->batchChangeBranch = "批量修改分支";
+$lang->story->batchChangeStage = "批量修改阶段";
+$lang->story->batchAssignTo = "批量指派";
$lang->story->common = '需求';
$lang->story->id = '编号';
diff --git a/module/story/model.php b/module/story/model.php
index 5938ae499f..a8c5206aac 100644
--- a/module/story/model.php
+++ b/module/story/model.php
@@ -761,6 +761,34 @@ class storyModel extends model
return $allChanges;
}
+ /**
+ * Batch change branch.
+ *
+ * @param array $storyIDList
+ * @param int $branchID
+ * @access public
+ * @return void
+ */
+ public function batchChangeBranch($storyIDList, $branchID)
+ {
+ $now = helper::now();
+ $allChanges = array();
+ $oldStories = $this->getByList($storyIDList);
+ foreach($storyIDList as $storyID)
+ {
+ $oldStory = $oldStories[$storyID];
+
+ $story = new stdclass();
+ $story->lastEditedBy = $this->app->user->account;
+ $story->lastEditedDate = $now;
+ $story->branch = $branchID;
+
+ $this->dao->update(TABLE_STORY)->data($story)->autoCheck()->where('id')->eq((int)$storyID)->exec();
+ if(!dao::isError()) $allChanges[$storyID] = common::createChanges($oldStory, $story);
+ }
+ return $allChanges;
+ }
+
/**
* Batch change the stage of story.
*