diff --git a/module/product/view/storylist.html.php b/module/product/view/storylist.html.php index 29b93b4dbd..a7776ce062 100644 --- a/module/product/view/storylist.html.php +++ b/module/product/view/storylist.html.php @@ -66,7 +66,7 @@ if($canBatchEdit) { - $actionLink = $this->createLink('story', 'batchEdit', "from=productBrowse&productID=$productID&projectID=0&orderBy=$orderBy"); + $actionLink = $this->createLink('story', 'batchEdit', "productID=$productID&projectID=0"); echo html::commonButton($lang->edit, "onclick=\"changeAction('productStoryForm', 'batchEdit', '$actionLink')\""); } if($canBatchClose) diff --git a/module/project/view/story.html.php b/module/project/view/story.html.php index 3946013ee0..2e2fed21fb 100644 --- a/module/project/view/story.html.php +++ b/module/project/view/story.html.php @@ -101,7 +101,7 @@ if($canBatchEdit) { - $actionLink = $this->createLink('story', 'batchEdit', "from=projectStory&productID=0&projectID=$project->id&orderBy=$orderBy"); + $actionLink = $this->createLink('story', 'batchEdit', "productID=0&projectID=$project->id"); echo html::commonButton($lang->edit, "onclick=\"changeAction('projectStoryForm', 'batchEdit', '$actionLink')\""); } if($canBatchClose) diff --git a/module/story/config.php b/module/story/config.php index 8b5cd28289..1c503750a7 100644 --- a/module/story/config.php +++ b/module/story/config.php @@ -4,6 +4,9 @@ $config->story = new stdclass(); $config->story->batchCreate = 10; $config->story->affectedFixedNum = 7; +$config->story->batchEdit = new stdclass(); +$config->story->batchEdit->columns = 10; + $config->story->create = new stdclass(); $config->story->edit = new stdclass(); $config->story->change = new stdclass(); diff --git a/module/story/control.php b/module/story/control.php index df15b7ade3..f8309b3170 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -289,106 +289,80 @@ class story extends control /** * Batch edit story. * - * @param string $from productBrowse|projectStory|storyBatchEdit. * @param int $productID * @param int $projectID - * @param string $orderBy * @access public * @return void */ - public function batchEdit($from = '', $productID = 0, $projectID = 0, $orderBy = '') + public function batchEdit($productID = 0, $projectID = 0) { - /* Get post data for product-Browse or project-Story. */ - if($from == 'productBrowse' or $from == 'projectStory') + if($this->post->titles) { - /* Init vars. */ - $editedStories = array(); - $storyIDList = $this->post->storyIDList ? $this->post->storyIDList : array(); - $columns = 9; - $showSuhosinInfo = false; + $allChanges = $this->story->batchUpdate(); - /* Get all stories. */ - if(!$projectID) + if($allChanges) { - /* Set menu. */ - $this->product->setMenu($this->product->getPairs('nodeleted'), $productID); - $allStories = $this->dao->select('*')->from(TABLE_STORY)->where($this->session->storyQueryCondition)->orderBy($orderBy)->fetchAll('id'); - } - else - { - $this->lang->story->menu = $this->lang->project->menu; - $this->project->setMenu($this->project->getPairs('nodeleted'), $projectID); - $this->lang->set('menugroup.story', 'project'); - $this->lang->story->menuOrder = $this->lang->project->menuOrder; - $allStories = $this->story->getProjectStories($projectID, $orderBy); - } - if(!$allStories) $allStories = array(); - - /* Initialize the stories whose need to edited. */ - $moduleOptionMenus = array(); - $productPlans = array(); - $this->loadModel('productplan'); - foreach($allStories as $story) - { - if(in_array($story->id, $storyIDList)) + foreach($allChanges as $storyID => $changes) { - $editedStories[$story->id] = $story; - if(!isset($moduleOptionMenus[$story->product])) - { - $moduleOptionMenus[$story->product] = $this->tree->getOptionMenu($story->product, $viewType = 'story'); - $productPlans[$story->product] = $this->productplan->getPairs($story->product); - } - } - } - - /* Judge whether the editedStories is too large. */ - $showSuhosinInfo = $this->loadModel('common')->judgeSuhosinSetting(count($editedStories), $columns); - - /* Set the sessions. */ - $this->app->session->set('showSuhosinInfo', $showSuhosinInfo); - - /* Assign. */ - if(!$projectID) - { - $product = $this->product->getByID($productID); - $this->view->title = $product->name . $this->lang->colon . $this->lang->story->batchEdit; - } - else - { - $project = $this->project->getByID($projectID); - $this->view->title = $project->name . $this->lang->colon . $this->lang->story->batchEdit; - } - if($showSuhosinInfo) $this->view->suhosinInfo = $this->lang->suhosinInfo; - $this->view->position[] = $this->lang->story->common; - $this->view->position[] = $this->lang->story->batchEdit; - $this->view->users = $this->loadModel('user')->getPairs('nodeleted'); - $this->view->moduleOptionMenus = $moduleOptionMenus; - $this->view->productPlans = $productPlans; - $this->view->productID = $productID; - $this->view->editedStories = $editedStories; - - $this->display(); - } - /* Get post data for story-batchEdit. */ - elseif($from == 'storyBatchEdit') - { - if(!empty($_POST)) - { - - $allChanges = $this->story->batchUpdate(); - - if($allChanges) - { - foreach($allChanges as $storyID => $changes) - { - $actionID = $this->action->create('story', $storyID, 'Edited'); - $this->action->logHistory($actionID, $changes); - $this->sendMail($storyID, $actionID); - } + $actionID = $this->action->create('story', $storyID, 'Edited'); + $this->action->logHistory($actionID, $changes); + $this->sendMail($storyID, $actionID); } } die(js::locate($this->session->storyList, 'parent')); + } + + $storyIDList = $this->post->storyIDList ? $this->post->storyIDList : die(js::locate($this->session->storyList, 'parent')); + + /* Get edited stories. */ + $stories = $this->dao->select('*')->from(TABLE_STORY)->where('id')->in($storyIDList)->fetchAll('id'); + + /* The stories of a product. */ + if(!$projectID) + { + $this->product->setMenu($this->product->getPairs('nodeleted'), $productID); + $product = $this->product->getByID($productID); + $this->view->title = $product->name . $this->lang->colon . $this->lang->story->batchEdit; + + } + /* The stories of a project. */ + else + { + $this->lang->story->menu = $this->lang->project->menu; + $this->project->setMenu($this->project->getPairs('nodeleted'), $projectID); + $this->lang->set('menugroup.story', 'project'); + $this->lang->story->menuOrder = $this->lang->project->menuOrder; + $project = $this->project->getByID($projectID); + $this->view->title = $project->name . $this->lang->colon . $this->lang->story->batchEdit; + } + + /* Get the module and productplan of edited stories. */ + $moduleOptionMenus = array(); + $productPlans = array(); + $this->loadModel('productplan'); + foreach($stories as $story) + { + $moduleOptionMenus[$story->product] = $this->tree->getOptionMenu($story->product, $viewType = 'story'); + $productPlans[$story->product] = $this->productplan->getPairs($story->product); + } + + /* Judge whether the editedStories is too large and set session. */ + $showSuhosinInfo = false; + $showSuhosinInfo = $this->loadModel('common')->judgeSuhosinSetting(count($stories), $this->config->story->batchEdit->columns); + $this->app->session->set('showSuhosinInfo', $showSuhosinInfo); + if($showSuhosinInfo) $this->view->suhosinInfo = $this->lang->suhosinInfo; + + $this->view->position[] = $this->lang->story->common; + $this->view->position[] = $this->lang->story->batchEdit; + $this->view->users = $this->loadModel('user')->getPairs('nodeleted'); + $this->view->moduleOptionMenus = $moduleOptionMenus; + $this->view->productPlans = $productPlans; + $this->view->productID = $productID; + $this->view->storyIDList = $storyIDList; + $this->view->stories = $stories; + + $this->display(); } /** diff --git a/module/story/view/batchedit.html.php b/module/story/view/batchedit.html.php index 3685bc6643..fb0191e6ea 100644 --- a/module/story/view/batchedit.html.php +++ b/module/story/view/batchedit.html.php @@ -27,50 +27,50 @@ story->closedBy;?> story->closedReason;?> - + - id . html::hidden("storyIDList[$story->id]", $story->id);?> - id]", $moduleOptionMenus[$story->product], $story->module, 'class=select-1');?> - id]", $productPlans[$story->product], $story->plan, 'class=select-1');?> - id]", $story->title, 'class=text-1'); ?> - id]", $story->estimate, 'class=text-1'); ?> - id]", (array)$lang->story->priList, $story->pri, 'class=select-1');?> - id]", $lang->story->sourceList, $story->source, 'class=select-1');?> - story->statusList[$story->status];?> + + product], $stories[$storyID]->module, 'class=select-1');?> + product], $stories[$storyID]->plan, 'class=select-1');?> + title, 'class=text-1'); ?> + estimate, 'class=text-1'); ?> + story->priList, $stories[$storyID]->pri, 'class=select-1');?> + story->sourceList, $stories[$storyID]->source, 'class=select-1');?> + story->statusList[$stories[$storyID]->status];?> - status != 'draft'):?> - id]", $lang->story->stageList, $story->stage, 'class=select-1');?> + status != 'draft'):?> + story->stageList, $stories[$storyID]->stage, 'class=select-1');?> - id]", $lang->story->stageList, $story->stage, 'class="select-1" disabled="disabled"');?> + story->stageList, $stories[$storyID]->stage, 'class="select-1" disabled="disabled"');?> - status == 'closed'):?> - id]", $users, $story->closedBy, 'class="select-1"');?> + status == 'closed'):?> + closedBy, 'class="select-1"');?> - id]", $users, $story->closedBy, 'class="select-1" disabled="disabled"');?> + closedBy, 'class="select-1" disabled="disabled"');?> - status == 'closed'):?> + status == 'closed'):?> -
id]", $lang->story->reasonList, $story->closedReason, "class=w-60px onchange=setDuplicateAndChild(this.value,$story->id)");?>
+
story->reasonList, $stories[$storyID]->closedReason, "class=w-60px onchange=setDuplicateAndChild(this.value,$storyID)");?>
-
id;?>' closedReason != 'duplicate') echo "style='display:none'";?>> - id]", '', "class=w-30px placeholder='{$lang->idAB}'");?> +
' closedReason != 'duplicate') echo "style='display:none'";?>> + idAB}'");?>
-
id;?>' closedReason != 'subdivided') echo "style='display:none'";?>> - id]", '', "class=w-30px placeholder='{$lang->idAB}'");?> +
' closedReason != 'subdivided') echo "style='display:none'";?>> + idAB}'");?>
-
id]", $lang->story->reasonList, $story->closedReason, 'class="w-60px" disabled="disabled"');?>
+
story->reasonList, $stories[$storyID]->closedReason, 'class="w-60px" disabled="disabled"');?>
-
+
- +