* Finish task #41242.
This commit is contained in:
@@ -572,6 +572,9 @@ class story extends control
|
||||
$action = !empty($changes) ? 'Edited' : 'Commented';
|
||||
$actionID = $this->action->create('story', $storyID, $action, $this->post->comment);
|
||||
$this->action->logHistory($actionID, $changes);
|
||||
|
||||
$story = $this->dao->findById($storyID)->from(TABLE_STORY)->fetch();
|
||||
$this->story->recordReviewAction($story);
|
||||
}
|
||||
|
||||
$this->executeHooks($storyID);
|
||||
@@ -603,11 +606,11 @@ class story extends control
|
||||
/* Get users. */
|
||||
$users = $this->user->getPairs('pofirst|nodeleted|noclosed', "$story->assignedTo,$story->openedBy,$story->closedBy");
|
||||
|
||||
$isShowReviewer = true;
|
||||
$isShowReviewer = false;
|
||||
$reviewerList = $this->story->getReviewerPairs($story->id, $story->version);
|
||||
$reviewerList = array_keys($reviewerList);
|
||||
$reviewedBy = explode(',', trim($story->reviewedBy, ','));
|
||||
if(!array_diff($reviewerList, $reviewedBy)) $isShowReviewer = false;
|
||||
if(array_diff($reviewerList, $reviewedBy) and strpos('draft,changed', $story->status) !== false) $isShowReviewer = true;
|
||||
|
||||
$reviewedReviewer = array();
|
||||
foreach($reviewedBy as $reviewer) $reviewedReviewer[] = zget($users, $reviewer);
|
||||
|
||||
+41
-24
@@ -720,7 +720,7 @@ class storyModel extends model
|
||||
*
|
||||
* @param int $storyID
|
||||
* @access public
|
||||
* @return array the changes of the story.
|
||||
* @return array the changes of the story.
|
||||
*/
|
||||
public function update($storyID)
|
||||
{
|
||||
@@ -791,6 +791,44 @@ class storyModel extends model
|
||||
|
||||
if(isset($story->stage) and $oldStory->stage != $story->stage) $story->stagedBy = (strpos('tested|verified|released|closed', $story->stage) !== false) ? $this->app->user->account : '';
|
||||
|
||||
if(isset($_POST['reviewer']))
|
||||
{
|
||||
$_POST['reviewer'] = array_filter($_POST['reviewer']);
|
||||
$oldReviewer = $this->getReviewerPairs($storyID, $oldStory->version);
|
||||
|
||||
/* Update story reviewer. */
|
||||
$this->dao->delete()->from(TABLE_STORYREVIEW)->where('story')->eq($storyID)->andWhere('version')->eq($oldStory->version)->andWhere('reviewer')->notin(implode(',', $_POST['reviewer']))->exec();
|
||||
foreach($_POST['reviewer'] as $reviewer)
|
||||
{
|
||||
if(in_array($reviewer, array_keys($oldReviewer))) continue;
|
||||
|
||||
$reviewData = new stdclass();
|
||||
$reviewData->story = $storyID;
|
||||
$reviewData->version = $oldStory->version;
|
||||
$reviewData->reviewer = $reviewer;
|
||||
$this->dao->insert(TABLE_STORYREVIEW)->data($reviewData)->exec();
|
||||
}
|
||||
|
||||
/* Update the story status by review rules. */
|
||||
$reviewerList = $this->getReviewerPairs($storyID, $oldStory->version);
|
||||
$reviewedBy = explode(',', trim($oldStory->reviewedBy, ','));
|
||||
if(!array_diff(array_keys($reviewerList), $reviewedBy))
|
||||
{
|
||||
$status = $this->setStatusByReviewRules($reviewerList);
|
||||
$story->status = $status ? $status : $oldStory->status;
|
||||
if($story->status == 'closed')
|
||||
{
|
||||
$story->closedBy = $this->app->user->account;
|
||||
$story->closedDate = $now;
|
||||
$story->assignedTo = 'closed';
|
||||
$story->assignedDate = $now;
|
||||
$story->stage = 'closed';
|
||||
if($this->post->closedReason == 'done') $story->stage = 'released';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$this->dao->update(TABLE_STORY)
|
||||
->data($story)
|
||||
->autoCheck()
|
||||
@@ -869,27 +907,6 @@ class storyModel extends model
|
||||
if(empty($oldStory->plan) or empty($story->plan)) $this->setStage($storyID); // Set new stage for this story.
|
||||
}
|
||||
|
||||
if(isset($_POST['reviewer']))
|
||||
{
|
||||
$_POST['reviewer'] = array_filter($_POST['reviewer']);
|
||||
$oldReviewer = $this->getReviewerPairs($storyID, $oldStory->version);
|
||||
$oldStory->reviewers = implode(',', array_keys($oldReviewer));
|
||||
$story->reviewers = implode(',', $_POST['reviewer']);
|
||||
|
||||
/* Update story reviewer. */
|
||||
$this->dao->delete()->from(TABLE_STORYREVIEW)->where('story')->eq($storyID)->andWhere('version')->eq($oldStory->version)->andWhere('reviewer')->notin(implode(',', $_POST['reviewer']))->exec();
|
||||
foreach($_POST['reviewer'] as $reviewer)
|
||||
{
|
||||
if(in_array($reviewer, array_keys($oldReviewer))) continue;
|
||||
|
||||
$reviewData = new stdclass();
|
||||
$reviewData->story = $storyID;
|
||||
$reviewData->version = $oldStory->version;
|
||||
$reviewData->reviewer = $reviewer;
|
||||
$this->dao->insert(TABLE_STORYREVIEW)->data($reviewData)->exec();
|
||||
}
|
||||
}
|
||||
|
||||
unset($oldStory->parent);
|
||||
unset($story->parent);
|
||||
return common::createChanges($oldStory, $story);
|
||||
@@ -4467,14 +4484,14 @@ class storyModel extends model
|
||||
* @access public
|
||||
* @return int
|
||||
*/
|
||||
public function recordReviewAction($story, $result, $reason)
|
||||
public function recordReviewAction($story, $result = '', $reason = '')
|
||||
{
|
||||
$reasonParam = $result == 'reject' ? ',' . $reason : '';
|
||||
$reviewers = $this->getReviewerPairs($story->id, $story->version);
|
||||
$reviewedBy = explode(',', trim($story->reviewedBy, ','));
|
||||
|
||||
$comment = isset($_POST['comment']) ? $this->post->comment : '';
|
||||
$actionID = $this->loadModel('action')->create('story', $story->id, 'Reviewed', $comment, ucfirst($result) . $reasonParam);
|
||||
$actionID = !empty($result) ? $this->loadModel('action')->create('story', $story->id, 'Reviewed', $comment, ucfirst($result) . $reasonParam) : '';
|
||||
|
||||
if($story->status == 'closed') $this->action->create('story', $story->id, 'ReviewClosed');
|
||||
if($story->status == 'active') $this->action->create('story', $story->id, 'PassReviewed');
|
||||
|
||||
Reference in New Issue
Block a user