diff --git a/module/product/control.php b/module/product/control.php
index d09f72accf..18b7274558 100644
--- a/module/product/control.php
+++ b/module/product/control.php
@@ -168,6 +168,7 @@ class product extends control
$this->view->users = $this->user->getPairs('nodeleted|noletter|pofirst');
$this->view->orderBy = $orderBy;
$this->view->browseType = $browseType;
+ $this->view->modules = $this->tree->getOptionMenu($productID, $viewType = 'story', 0, $branch);
$this->view->moduleID = $moduleID;
$this->view->moduleName = $moduleID ? $this->tree->getById($moduleID)->name : $this->lang->tree->all;
$this->view->branch = $branch;
diff --git a/module/product/view/browse.html.php b/module/product/view/browse.html.php
index f1112011f8..a27ee41e52 100644
--- a/module/product/view/browse.html.php
+++ b/module/product/view/browse.html.php
@@ -167,6 +167,25 @@
echo '';
}
+ if(common::hasPriv('story', 'batchChangeModule'))
+ {
+ $withSearch = count($modules) > 8;
+ echo "
';
+ }
+ else
+ {
+ echo '' . html::a('javascript:;', $lang->story->moduleAB, '', $class) . '';
+ }
+
if(common::hasPriv('story', 'batchChangePlan'))
{
unset($plans['']);
diff --git a/module/story/control.php b/module/story/control.php
index 72cd8d6718..40e94f2314 100644
--- a/module/story/control.php
+++ b/module/story/control.php
@@ -770,6 +770,27 @@ class story extends control
$this->display();
}
+ /**
+ * Batch change the module of story.
+ *
+ * @param int $moduleID
+ * @access public
+ * @return void
+ */
+ public function batchChangeModule($moduleID)
+ {
+ $storyIDList = !empty($_POST['storyIDList']) ? $this->post->storyIDList : die(js::locate($this->session->storyList, 'parent'));
+ $allChanges = $this->story->batchChangeModule($storyIDList, $moduleID);
+ 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 plan of story.
*
diff --git a/module/story/lang/en.php b/module/story/lang/en.php
index d578511301..7f0d94a9e4 100644
--- a/module/story/lang/en.php
+++ b/module/story/lang/en.php
@@ -38,6 +38,7 @@ $lang->story->common = 'Story';
$lang->story->id = 'ID';
$lang->story->product = $lang->productCommon;
$lang->story->module = 'Module';
+$lang->story->moduleAB = 'Module';
$lang->story->source = 'Source';
$lang->story->fromBug = 'From bug';
$lang->story->title = 'Title';
diff --git a/module/story/lang/zh-cn.php b/module/story/lang/zh-cn.php
index d0d1d105d8..999b9c4dfa 100644
--- a/module/story/lang/zh-cn.php
+++ b/module/story/lang/zh-cn.php
@@ -38,6 +38,7 @@ $lang->story->common = '需求';
$lang->story->id = '编号';
$lang->story->product = "所属{$lang->productCommon}";
$lang->story->module = '所属模块';
+$lang->story->moduleAB = '模块';
$lang->story->source = '需求来源';
$lang->story->fromBug = '来源Bug';
$lang->story->title = '需求名称';
diff --git a/module/story/model.php b/module/story/model.php
index b3d65a1ee2..5515ff09a1 100644
--- a/module/story/model.php
+++ b/module/story/model.php
@@ -739,6 +739,35 @@ class storyModel extends model
return $allChanges;
}
+ /**
+ * Batch change the module of story.
+ *
+ * @param array $storyIDList
+ * @param int $moduleID
+ * @access public
+ * @return array
+ */
+ public function batchChangeModule($storyIDList, $moduleID)
+ {
+ $now = helper::now();
+ $allChanges = array();
+ $oldStories = $this->getByList($storyIDList);
+ foreach($storyIDList as $storyID)
+ {
+ $oldStory = $oldStories[$storyID];
+ if($moduleID == $oldStory->module) continue;
+
+ $story = new stdclass();
+ $story->lastEditedBy = $this->app->user->account;
+ $story->lastEditedDate = $now;
+ $story->module = $moduleID;
+
+ $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 plan of story.
*