diff --git a/module/story/control.php b/module/story/control.php index 8b737012d0..7efc42cd01 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -1515,7 +1515,7 @@ class story extends control if(!$this->post->storyIdList) return print(js::locate($this->session->storyList, 'parent')); $storyIdList = $this->post->storyIdList; $storyIdList = array_unique($storyIdList); - $actions = $this->story->batchReview($storyIdList, $result, $reason); + $this->story->batchReview($storyIdList, $result, $reason); if(dao::isError()) return print(js::error(dao::getError())); if(!dao::isError()) $this->loadModel('score')->create('ajax', 'batchOther'); diff --git a/module/story/model.php b/module/story/model.php index 0ea49d9ea0..f9dc8ee6ca 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -1675,9 +1675,10 @@ class storyModel extends model $actions = array(); $this->loadModel('action'); - $oldStories = $this->getByList($storyIdList); - $hasResult = $this->dao->select('story,version,result')->from(TABLE_STORYREVIEW)->where('story')->in($storyIdList)->andWhere('reviewer')->eq($this->app->user->account)->andWhere('result')->ne('')->orderBy('version')->fetchAll('story'); - $reviewerList = $this->dao->select('story,reviewer,result,version')->from(TABLE_STORYREVIEW)->where('story')->in($storyIdList)->orderBy('version')->fetchGroup('story', 'reviewer'); + $reviewedSiblings = array(); + $oldStories = $this->getByList($storyIdList); + $hasResult = $this->dao->select('story,version,result')->from(TABLE_STORYREVIEW)->where('story')->in($storyIdList)->andWhere('reviewer')->eq($this->app->user->account)->andWhere('result')->ne('')->orderBy('version')->fetchAll('story'); + $reviewerList = $this->dao->select('story,reviewer,result,version')->from(TABLE_STORYREVIEW)->where('story')->in($storyIdList)->orderBy('version')->fetchGroup('story', 'reviewer'); foreach($storyIdList as $storyID) { if(!$storyID) continue; @@ -1704,6 +1705,21 @@ class storyModel extends model $this->dao->update(TABLE_STORYREVIEW)->set('result')->eq($result)->set('reviewDate')->eq($now)->where('story')->eq($storyID)->andWhere('version')->eq($oldStory->version)->andWhere('reviewer')->eq($this->app->user->account)->exec(); + /* Sync siblings. */ + if(!empty($oldStory->siblings)) + { + foreach(explode(',', trim($oldStory->siblings, ',')) as $siblingID) + { + $this->dao->update(TABLE_STORYREVIEW) + ->set('result')->eq($result) + ->set('reviewDate')->eq($now) + ->where('story')->eq($siblingID) + ->andWhere('version')->eq($oldStory->version) + ->andWhere('reviewer')->eq($this->app->user->account) + ->exec(); + } + } + /* Update the story status by review rules. */ $reviewedBy = explode(',', trim($story->reviewedBy, ',')); if($isSuperReviewer !== false) @@ -1726,6 +1742,19 @@ class storyModel extends model $story->id = $storyID; $story->version = $oldStory->version; $actions[$storyID] = $this->recordReviewAction($story, $result, $reason); + + /* Sync siblings. */ + $changes = common::createChanges($oldStory, $story); + if(!empty($oldStory->siblings)) + { + $siblings = $oldStory->siblings; + foreach(explode(',', $siblings) as $siblingID) + { + if(in_array($siblingID, $storyIdList) or isset($reviewedSiblings[$siblingID])) $siblings = str_replace(",$siblingID,", ',', $siblings); + } + $this->syncSiblings($storyID, trim($siblings, ','), $changes, 'Reviewed'); + foreach(explode(',', trim($siblings, ',')) as $reviewedID) $reviewedSiblings[$reviewedID] = $reviewedID; + } } return $actions;