diff --git a/module/product/view/browse.html.php b/module/product/view/browse.html.php
index 870e79b8f8..334c04cc43 100644
--- a/module/product/view/browse.html.php
+++ b/module/product/view/browse.html.php
@@ -153,7 +153,7 @@
createLink('story', 'batchClose', "productID=$productID&projectID=0");
$misc = $canBatchClose ? "onclick=setFormAction('$actionLink')" : $class;
echo "
" . html::a('#', $lang->close, '', $misc) . "";
diff --git a/module/story/control.php b/module/story/control.php
index 8d6438b5c9..ac7e221813 100644
--- a/module/story/control.php
+++ b/module/story/control.php
@@ -644,7 +644,7 @@ class story extends control
*/
public function batchClose($productID = 0, $projectID = 0)
{
- if($this->post->closedReasons)
+ if($this->post->comments)
{
$allChanges = $this->story->batchClose();
diff --git a/module/story/model.php b/module/story/model.php
index 79855d7c14..4e12fa005d 100644
--- a/module/story/model.php
+++ b/module/story/model.php
@@ -579,51 +579,49 @@ class storyModel extends model
/* Adjust whether the post data is complete, if not, remove the last element of $storyIDList. */
if($this->session->showSuhosinInfo) array_pop($storyIDList);
- if(!empty($storyIDList))
+ foreach($storyIDList as $storyID)
{
- foreach($storyIDList as $storyID)
+ $oldStory = $this->getById($storyID);
+ if(!$oldStory->status == 'closed') continue;
+
+ $story->lastEditedBy = $this->app->user->account;
+ $story->lastEditedDate = $now;
+ $story->closedBy = $this->app->user->account;
+ $story->closedDate = $now;
+ $story->assignedTo = 'closed';
+ $story->assignedDate = $now;
+ $story->status = 'closed';
+
+ $story->closedReason = $this->post->closedReasons[$storyID];
+ $story->duplicateStory = $this->post->duplicateStoryIDList[$storyID] ? $this->post->duplicateStoryIDList[$storyID] : $oldStory->duplicateStory;
+ $story->childStories = $this->post->childStoriesIDList[$storyID] ? $this->post->childStoriesIDList[$storyID] : $oldStory->childStories;
+
+ if($story->closedReason == 'done') $story->stage = 'released';
+ if($story->closedReason != 'done') $story->plan = 0;
+
+ $stories[$storyID] = $story;
+ unset($story);
+ }
+
+ foreach($stories as $storyID => $story)
+ {
+ if(!$story->closedReason) continue;
+
+ $oldStory = $this->getById($storyID);
+
+ $this->dao->update(TABLE_STORY)->data($story)
+ ->autoCheck()
+ ->checkIF($story->closedReason == 'duplicate', 'duplicateStory', 'notempty')
+ ->checkIF($story->closedReason == 'subdivided', 'childStories', 'notempty')
+ ->where('id')->eq($storyID)->exec();
+
+ if(!dao::isError())
{
- $oldStory = $this->getById($storyID);
-
- $story->lastEditedBy = $this->app->user->account;
- $story->lastEditedDate = $now;
- $story->closedBy = $this->app->user->account;
- $story->closedDate = $now;
- $story->assignedTo = 'closed';
- $story->assignedDate = $now;
- $story->status = 'closed';
-
- $story->closedReason = $this->post->closedReasons[$storyID];
- $story->duplicateStory = $this->post->duplicateStoryIDList[$storyID] ? $this->post->duplicateStoryIDList[$storyID] : $oldStory->duplicateStory;
- $story->childStories = $this->post->childStoriesIDList[$storyID] ? $this->post->childStoriesIDList[$storyID] : $oldStory->childStories;
-
- if($story->closedReason == 'done') $story->stage = 'released';
- if($story->closedReason != 'done') $story->plan = 0;
-
- $stories[$storyID] = $story;
- unset($story);
+ $allChanges[$storyID] = common::createChanges($oldStory, $story);
}
-
- foreach($stories as $storyID => $story)
+ else
{
- if(!$story->closedReason) continue;
-
- $oldStory = $this->getById($storyID);
-
- $this->dao->update(TABLE_STORY)->data($story)
- ->autoCheck()
- ->checkIF($story->closedReason == 'duplicate', 'duplicateStory', 'notempty')
- ->checkIF($story->closedReason == 'subdivided', 'childStories', 'notempty')
- ->where('id')->eq($storyID)->exec();
-
- if(!dao::isError())
- {
- $allChanges[$storyID] = common::createChanges($oldStory, $story);
- }
- else
- {
- die(js::error('story#' . $storyID . dao::getError(true)));
- }
+ die(js::error('story#' . $storyID . dao::getError(true)));
}
}