Merge branch 'master_xieqiyu_66957' into 'master'
* Code for task#68109. See merge request easycorp/zentaopms!5266
This commit is contained in:
@@ -50,7 +50,7 @@ class actionModel extends model
|
||||
$action->extra = $extra;
|
||||
if(!defined('IN_UPGRADE')) $action->vision = $this->config->vision;
|
||||
|
||||
if($objectType == 'story' and strpos(',reviewpassed,reviewrejected,reviewclarified,', ",$actionType,") !== false) $action->actor = $this->lang->action->system;
|
||||
if($objectType == 'story' and strpos(',reviewpassed,reviewrejected,reviewclarified,reviewreverted,', ",$actionType,") !== false) $action->actor = $this->lang->action->system;
|
||||
|
||||
/* Use purifier to process comment. Fix bug #2683. */
|
||||
$action->comment = fixer::stripDataTags($comment);
|
||||
|
||||
@@ -753,25 +753,9 @@ class story extends control
|
||||
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$deleteFiles = isset($_POST['deleteFiles']) ? $this->file->getPairs($_POST['deleteFiles'], 'title') : array();
|
||||
$changes = $this->story->update($storyID);
|
||||
$this->story->update($storyID);
|
||||
if(dao::isError()) return print(js::error(dao::getError()));
|
||||
|
||||
$files = $this->file->saveUpload($story->type, $storyID, ",$story->version,");
|
||||
if(empty($files) and $this->post->uid != '' and isset($_SESSION['album']['used'][$this->post->uid])) $files = $this->file->getPairs($_SESSION['album']['used'][$this->post->uid]);
|
||||
|
||||
if($this->post->comment != '' or !empty($changes) or !empty($files) or !empty($deleteFiles))
|
||||
{
|
||||
$action = (!empty($changes) or !empty($files)) ? 'Edited' : 'Commented';
|
||||
$fileAction = empty($files) ? '' : $this->lang->addFiles . join(',', $files) . "\n" ;
|
||||
$fileAction .= empty($deleteFiles) ? '' : $this->lang->deleteFiles . join(',', $deleteFiles) . "\n";
|
||||
$actionID = $this->action->create('story', $storyID, $action, $fileAction . $this->post->comment);
|
||||
$this->action->logHistory($actionID, $changes);
|
||||
|
||||
$editedStory = $this->dao->findById($storyID)->from(TABLE_STORY)->fetch();
|
||||
if(isset($_POST['reviewer']) and $story->status == 'reviewing') $this->story->recordReviewAction($editedStory);
|
||||
}
|
||||
|
||||
$this->executeHooks($storyID);
|
||||
|
||||
if(isonlybody())
|
||||
@@ -1406,16 +1390,9 @@ class story extends control
|
||||
{
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$changes = $this->story->review($storyID);
|
||||
$this->story->review($storyID);
|
||||
if(dao::isError()) return print(js::error(dao::getError()));
|
||||
|
||||
if($changes)
|
||||
{
|
||||
$story = $this->dao->findById($storyID)->from(TABLE_STORY)->fetch();
|
||||
$actionID = $this->story->recordReviewAction($story, $this->post->result, $this->post->closedReason);
|
||||
$this->action->logHistory($actionID, $changes);
|
||||
}
|
||||
|
||||
$this->executeHooks($storyID);
|
||||
|
||||
if(isonlybody())
|
||||
@@ -1480,11 +1457,11 @@ class story extends control
|
||||
$reviewers = $this->story->getReviewerPairs($storyID, $story->version);
|
||||
$this->lang->story->resultList = $this->lang->story->reviewResultList;
|
||||
|
||||
if($story->status == 'reviewing' and $story->version == 1) unset($this->lang->story->resultList['revert']);
|
||||
|
||||
if($story->status == 'changing') unset($this->lang->story->resultList['reject']);
|
||||
|
||||
if(count($reviewers) > 1) unset($this->lang->story->resultList['revert']);
|
||||
if($story->status == 'reviewing')
|
||||
{
|
||||
if($story->version == 1) unset($this->lang->story->resultList['revert']);
|
||||
if($story->version > 1) unset($this->lang->story->resultList['reject']);
|
||||
}
|
||||
|
||||
$this->view->title = $this->lang->story->review . "STORY" . $this->lang->colon . $story->title;
|
||||
$this->view->position[] = html::a($this->createLink('product', 'browse', "product=$product->id&branch=$story->branch"), $product->name);
|
||||
|
||||
@@ -39,8 +39,6 @@ function switchShow(result)
|
||||
$('#estimateBox').show();
|
||||
}
|
||||
}
|
||||
|
||||
getStatus('review', "storyID=" + storyID + ",result=" + result);
|
||||
}
|
||||
|
||||
function setStory(reason)
|
||||
|
||||
@@ -321,7 +321,8 @@ $lang->story->action->recalled = array('main' => '$date, recalled b
|
||||
$lang->story->action->closed = array('main' => '$date, geschlossen von <strong>$actor</strong>. Der Grund ist <strong>$extra</strong> $appendLink.', 'extra' => 'reasonList');
|
||||
$lang->story->action->reviewpassed = array('main' => '$date, determined by the <strong>System</strong>. The result is <strong>Pass</strong>.');
|
||||
$lang->story->action->reviewrejected = array('main' => '$date, closed by <strong>System</strong>. The reasion is <strong>Rejection</strong>.');
|
||||
$lang->story->action->reviewclarified = array('main' => '$date, determined by the <strong>System</strong>. The result is <strong>To Be Clarified</strong>. Please re-initiate the review after changing.');
|
||||
$lang->story->action->reviewclarified = array('main' => '$date, determined by the <strong>System</strong>. The result is <strong>To Be Clarified</strong>. Please re-initiate the review after edit.');
|
||||
$lang->story->action->reviewreverted = array('main' => '$date, determined by the <strong>System</strong>. The result is <strong>Undo Change</strong>.');
|
||||
$lang->story->action->linked2plan = array('main' => '$date, verknüpft von <strong>$actor</strong> mit Plan <strong>$extra</strong>');
|
||||
$lang->story->action->unlinkedfromplan = array('main' => '$date, Verknüpfung aufgelöst durch <strong>$actor</strong> von Plan <strong>$extra</strong>.');
|
||||
$lang->story->action->linked2execution = array('main' => '$date, verknüpft von <strong>$actor</strong> mit ' . $lang->executionCommon . ' <strong>$extra</strong>.');
|
||||
|
||||
@@ -321,7 +321,8 @@ $lang->story->action->recalled = array('main' => '$date, recalled b
|
||||
$lang->story->action->closed = array('main' => '$date, closed by <strong>$actor</strong>. The reasion is <strong>$extra</strong> $appendLink.', 'extra' => 'reasonList');
|
||||
$lang->story->action->reviewpassed = array('main' => '$date, determined by the <strong>System</strong>. The result is <strong>Pass</strong>.');
|
||||
$lang->story->action->reviewrejected = array('main' => '$date, closed by <strong>System</strong>. The reasion is <strong>Rejection</strong>.');
|
||||
$lang->story->action->reviewclarified = array('main' => '$date, determined by the <strong>System</strong>. The result is <strong>To Be Clarified</strong>. Please re-initiate the review after changing.');
|
||||
$lang->story->action->reviewclarified = array('main' => '$date, determined by the <strong>System</strong>. The result is <strong>To Be Clarified</strong>. Please re-initiate the review after edit.');
|
||||
$lang->story->action->reviewreverted = array('main' => '$date, determined by the <strong>System</strong>. The result is <strong>Undo Change</strong>.');
|
||||
$lang->story->action->linked2plan = array('main' => '$date, linked by <strong>$actor</strong> to Plan <strong>$extra</strong>');
|
||||
$lang->story->action->unlinkedfromplan = array('main' => '$date, unlinked by <strong>$actor</strong> from Plan <strong>$extra</strong>.');
|
||||
$lang->story->action->linked2execution = array('main' => '$date, linked by <strong>$actor</strong> to ' . $lang->executionCommon . ' <strong>$extra</strong>.');
|
||||
|
||||
@@ -321,7 +321,8 @@ $lang->story->action->recalled = array('main' => '$date, recalled b
|
||||
$lang->story->action->closed = array('main' => '$date, Fermée par <strong>$actor</strong>. La raison est <strong>$extra</strong> $appendLink.', 'extra' => 'reasonList');
|
||||
$lang->story->action->reviewpassed = array('main' => '$date, determined by the <strong>System</strong>. The result is <strong>Pass</strong>.');
|
||||
$lang->story->action->reviewrejected = array('main' => '$date, closed by <strong>System</strong>. The reasion is <strong>Rejection</strong>.');
|
||||
$lang->story->action->reviewclarified = array('main' => '$date, determined by the <strong>System</strong>. The result is <strong>To Be Clarified</strong>. Please re-initiate the review after changing.');
|
||||
$lang->story->action->reviewclarified = array('main' => '$date, determined by the <strong>System</strong>. The result is <strong>To Be Clarified</strong>. Please re-initiate the review after edit.');
|
||||
$lang->story->action->reviewreverted = array('main' => '$date, determined by the <strong>System</strong>. The result is <strong>Undo Change</strong>.');
|
||||
$lang->story->action->linked2plan = array('main' => '$date, planifiée par <strong>$actor</strong> au Plan <strong>$extra</strong>');
|
||||
$lang->story->action->unlinkedfromplan = array('main' => '$date, déplanifiée par <strong>$actor</strong> du Plan <strong>$extra</strong>.');
|
||||
$lang->story->action->linked2execution = array('main' => '$date, associée au ' . $lang->executionCommon . ' <strong>$extra</strong> par <strong>$actor</strong>.');
|
||||
|
||||
@@ -313,7 +313,8 @@ $lang->story->action->recalled = array('main' => '$date, recalled b
|
||||
$lang->story->action->closed = array('main' => '$date, được đóng bởi <strong>$actor</strong>. Lý do là <strong>$extra</strong> $appendLink.', 'extra' => 'reasonList');
|
||||
$lang->story->action->reviewpassed = array('main' => '$date, determined by the <strong>System</strong>. The result is <strong>Pass</strong>.');
|
||||
$lang->story->action->reviewrejected = array('main' => '$date, closed by <strong>System</strong>. The reasion is <strong>Rejection</strong>.');
|
||||
$lang->story->action->reviewclarified = array('main' => '$date, determined by the <strong>System</strong>. The result is <strong>To Be Clarified</strong>. Please re-initiate the review after changing.');
|
||||
$lang->story->action->reviewclarified = array('main' => '$date, determined by the <strong>System</strong>. The result is <strong>To Be Clarified</strong>. Please re-initiate the review after edit.');
|
||||
$lang->story->action->reviewreverted = array('main' => '$date, determined by the <strong>System</strong>. The result is <strong>Undo Change</strong>.');
|
||||
$lang->story->action->linked2plan = array('main' => '$date, liên kết bởi <strong>$actor</strong> tới kế hoạch <strong>$extra</strong>');
|
||||
$lang->story->action->unlinkedfromplan = array('main' => '$date, bị hủy bởi <strong>$actor</strong> từ kế hoạch <strong>$extra</strong>.');
|
||||
$lang->story->action->linked2execution = array('main' => '$date, liên kết bởi <strong>$actor</strong> tới ' . $lang->executionCommon . ' <strong>$extra</strong>.');
|
||||
|
||||
@@ -321,7 +321,8 @@ $lang->story->action->recalled = array('main' => '$date, 由 <stron
|
||||
$lang->story->action->closed = array('main' => '$date, 由 <strong>$actor</strong> 关闭,原因为 <strong>$extra</strong> $appendLink。', 'extra' => 'reasonList');
|
||||
$lang->story->action->reviewpassed = array('main' => '$date, 由 <strong>系统</strong> 判定,结果为 <strong>确认通过</strong>。');
|
||||
$lang->story->action->reviewrejected = array('main' => '$date, 由 <strong>系统</strong> 关闭,原因为 <strong>拒绝</strong>。');
|
||||
$lang->story->action->reviewclarified = array('main' => '$date, 由 <strong>系统</strong> 判定,结果为 <strong>有待明确</strong>,请变更后重新发起评审。');
|
||||
$lang->story->action->reviewclarified = array('main' => '$date, 由 <strong>系统</strong> 判定,结果为 <strong>有待明确</strong>,请编辑后重新发起评审。');
|
||||
$lang->story->action->reviewreverted = array('main' => '$date, 由 <strong>系统</strong> 判定,结果为 <strong>撤销变更</strong>。');
|
||||
$lang->story->action->linked2plan = array('main' => '$date, 由 <strong>$actor</strong> 关联到计划 <strong>$extra</strong>。');
|
||||
$lang->story->action->unlinkedfromplan = array('main' => '$date, 由 <strong>$actor</strong> 从计划 <strong>$extra</strong> 移除。');
|
||||
$lang->story->action->linked2execution = array('main' => '$date, 由 <strong>$actor</strong> 关联到' . $lang->executionCommon . ' <strong>$extra</strong>。');
|
||||
|
||||
@@ -297,7 +297,8 @@ $lang->story->action->recalled = array('main' => '$date, 由 <stron
|
||||
$lang->story->action->closed = array('main' => '$date, 由 <strong>$actor</strong> 關閉,原因為 <strong>$extra</strong> $appendLink。', 'extra' => 'reasonList');
|
||||
$lang->story->action->reviewpassed = array('main' => '$date, 由 <strong>系統</strong> 判定,結果為 <strong>確認通過</strong>。');
|
||||
$lang->story->action->reviewrejected = array('main' => '$date, 由 <strong>系統</strong> 關閉,原因為 <strong>拒絶</strong>。');
|
||||
$lang->story->action->reviewclarified = array('main' => '$date, 由 <strong>系統</strong> 判定,結果為 <strong>有待明確</strong>,請變更後重新發起評審。');
|
||||
$lang->story->action->reviewclarified = array('main' => '$date, 由 <strong>系統</strong> 判定,結果為 <strong>有待明確</strong>,請編輯後重新發起評審。');
|
||||
$lang->story->action->reviewreverted = array('main' => '$date, 由 <strong>系統</strong> 判定,結果為 <strong>撤銷變更</strong>。');
|
||||
$lang->story->action->linked2plan = array('main' => '$date, 由 <strong>$actor</strong> 關聯到計劃 <strong>$extra</strong>。');
|
||||
$lang->story->action->unlinkedfromplan = array('main' => '$date, 由 <strong>$actor</strong> 從計劃 <strong>$extra</strong> 移除。');
|
||||
$lang->story->action->linked2execution = array('main' => '$date, 由 <strong>$actor</strong> 關聯到' . $lang->executionCommon . ' <strong>$extra</strong>。');
|
||||
|
||||
+125
-102
@@ -904,7 +904,7 @@ class storyModel extends model
|
||||
}
|
||||
|
||||
$this->dao->update(TABLE_STORY)
|
||||
->data($story, 'reviewers,spec,verify')
|
||||
->data($story, 'reviewers,spec,verify,finalResult')
|
||||
->autoCheck()
|
||||
->checkIF(isset($story->closedBy), 'closedReason', 'notempty')
|
||||
->checkIF(isset($story->closedReason) and $story->closedReason == 'done', 'stage', 'notempty')
|
||||
@@ -912,6 +912,7 @@ class storyModel extends model
|
||||
->checkIF($story->notifyEmail, 'notifyEmail', 'email')
|
||||
->checkFlow()
|
||||
->where('id')->eq((int)$storyID)->exec();
|
||||
if(dao::isError()) return false;
|
||||
|
||||
if(!dao::isError())
|
||||
{
|
||||
@@ -1039,9 +1040,27 @@ class storyModel extends model
|
||||
}
|
||||
}
|
||||
|
||||
$changes = common::createChanges($oldStory, $story);
|
||||
$deleteFiles = isset($_POST['deleteFiles']) ? $this->file->getPairs($_POST['deleteFiles'], 'title') : array();
|
||||
|
||||
if(isset($_POST['deleteFiles'])) $this->file->deleteStoryFile($storyID, $oldStory->version, $_POST['deleteFiles']);
|
||||
$this->file->updateObjectID($this->post->uid, $storyID, 'story');
|
||||
return common::createChanges($oldStory, $story);
|
||||
|
||||
$files = $this->file->saveUpload($oldStory->type, $storyID, ",$oldStory->version,");
|
||||
if(empty($files) and $this->post->uid != '' and isset($_SESSION['album']['used'][$this->post->uid])) $files = $this->file->getPairs($_SESSION['album']['used'][$this->post->uid]);
|
||||
|
||||
if($this->post->comment != '' or !empty($changes) or !empty($files) or !empty($deleteFiles))
|
||||
{
|
||||
$action = (!empty($changes) or !empty($files)) ? 'Edited' : 'Commented';
|
||||
$fileAction = empty($files) ? '' : $this->lang->addFiles . join(',', $files) . "\n" ;
|
||||
$fileAction .= empty($deleteFiles) ? '' : $this->lang->deleteFiles . join(',', $deleteFiles) . "\n";
|
||||
$actionID = $this->action->create('story', $storyID, $action, $fileAction . $this->post->comment);
|
||||
$this->action->logHistory($actionID, $changes);
|
||||
|
||||
if(isset($story->finalResult)) $this->recordReviewAction($story);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1440,7 +1459,6 @@ class storyModel extends model
|
||||
->setDefault('reviewedDate', $date)
|
||||
->stripTags($this->config->story->editor->review['id'], $this->config->allowedTags)
|
||||
->setIF(!$this->post->assignedTo, 'assignedTo', '')
|
||||
->setIF($this->post->result == 'revert', 'version', $oldStory->version - 1)
|
||||
->removeIF($this->post->result != 'reject', 'closedReason, duplicateStory, childStories')
|
||||
->removeIF($this->post->result == 'reject' and $this->post->closedReason != 'duplicate', 'duplicateStory')
|
||||
->removeIF($this->post->result == 'reject' and $this->post->closedReason != 'subdivided', 'childStories')
|
||||
@@ -1459,12 +1477,12 @@ class storyModel extends model
|
||||
|
||||
$story = $this->updateStoryByReview($storyID, $oldStory, $story);
|
||||
|
||||
$skipFields = '';
|
||||
$skipFields = 'finalResult';
|
||||
$isSuperReviewer = strpos(',' . trim(zget($this->config->story, 'superReviewers', ''), ',') . ',', ',' . $this->app->user->account . ',');
|
||||
if($isSuperReviewer === false)
|
||||
{
|
||||
$reviewers = $this->getReviewerPairs($storyID, $oldStory->version);
|
||||
if(count($reviewers) > 1) $skipFields = 'closedReason';
|
||||
if(count($reviewers) > 1) $skipFields .= ',closedReason';
|
||||
}
|
||||
|
||||
$this->dao->update(TABLE_STORY)->data($story, $skipFields)
|
||||
@@ -1473,27 +1491,21 @@ class storyModel extends model
|
||||
->checkIF($this->post->result == 'reject', 'closedReason', 'notempty')
|
||||
->checkIF($this->post->result == 'reject' and $this->post->closedReason == 'duplicate', 'duplicateStory', 'notempty')
|
||||
->checkFlow()
|
||||
->where('id')->eq($storyID)->exec();
|
||||
if($this->post->result == 'revert')
|
||||
{
|
||||
$preTitle = $this->dao->select('title')->from(TABLE_STORYSPEC)->where('story')->eq($storyID)->andWHere('version')->eq($oldStory->version - 1)->fetch('title');
|
||||
$this->dao->update(TABLE_STORY)->set('title')->eq($preTitle)->where('id')->eq($storyID)->exec();
|
||||
->where('id')->eq($storyID)
|
||||
->exec();
|
||||
if(dao::isError()) return false;
|
||||
|
||||
/* Delete versions that is after this version. */
|
||||
$deleteVersion = array();
|
||||
for($version = $oldStory->version; $version > $story->version; $version --) $deleteVersion[] = $version;
|
||||
if($deleteVersion)
|
||||
{
|
||||
$this->dao->delete()->from(TABLE_STORYSPEC)->where('story')->eq($storyID)->andWHere('version')->in($deleteVersion)->exec();
|
||||
$this->dao->delete()->from(TABLE_STORYREVIEW)->where('story')->eq($storyID)->andWhere('version')->in($deleteVersion)->exec();
|
||||
}
|
||||
|
||||
$this->file->deleteStoryFile($storyID, $oldStory->version);
|
||||
}
|
||||
if($this->post->result != 'reject') $this->setStage($storyID);
|
||||
|
||||
if(isset($story->closedReason) and $isSuperReviewer === false) unset($story->closedReason);
|
||||
return common::createChanges($oldStory, $story);
|
||||
$changes = common::createChanges($oldStory, $story);
|
||||
if($changes)
|
||||
{
|
||||
$actionID = $this->recordReviewAction($story, $this->post->result, $this->post->closedReason);
|
||||
$this->action->logHistory($actionID, $changes);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1524,6 +1536,7 @@ class storyModel extends model
|
||||
if($oldStory->status != 'reviewing') continue;
|
||||
if(!in_array($this->app->user->account, array_keys($reviewerList[$storyID])) and $isSuperReviewer === false) continue;
|
||||
if(isset($hasResult[$storyID]) and $hasResult[$storyID]->version == $oldStories[$storyID]->version) continue;
|
||||
if($oldStory->version > 1 and $result == 'reject') continue;
|
||||
|
||||
$story = new stdClass();
|
||||
$story->reviewedDate = $now;
|
||||
@@ -1546,20 +1559,11 @@ class storyModel extends model
|
||||
foreach($reviewerList[$storyID] as $reviewer => $reviewInfo) $reviewerPairs[$reviewer] = $reviewInfo->result;
|
||||
$reviewerPairs[$this->app->user->account] = $result;
|
||||
|
||||
$status = $this->setStatusByReviewRules($reviewerPairs);
|
||||
$story->status = $status ? $status : $oldStory->status;
|
||||
|
||||
if($story->status == 'closed')
|
||||
{
|
||||
$story->closedBy = $this->app->user->account;
|
||||
$story->closedDate = $now;
|
||||
$story->assignedTo = 'closed';
|
||||
$story->stage = 'closed';
|
||||
if($reason == 'done') $story->stage = 'released';
|
||||
}
|
||||
$reviewResult = $this->getReviewResult($reviewerPairs);
|
||||
$story = $this->setStatusByReviewResult($story, $oldStory, $reviewResult, $reason);
|
||||
}
|
||||
|
||||
$this->dao->update(TABLE_STORY)->data($story)->autoCheck()->where('id')->eq($storyID)->exec();
|
||||
$this->dao->update(TABLE_STORY)->data($story, 'finalResult')->autoCheck()->where('id')->eq($storyID)->exec();
|
||||
$this->setStage($storyID);
|
||||
|
||||
$story->id = $storyID;
|
||||
@@ -1632,6 +1636,7 @@ class storyModel extends model
|
||||
$story = fixer::input('post')
|
||||
->setDefault('status', 'active')
|
||||
->setDefault('reviewer', '')
|
||||
->setDefault('reviewedBy', '')
|
||||
->remove('needNotReview')
|
||||
->join('reviewer', ',')
|
||||
->get();
|
||||
@@ -1653,7 +1658,7 @@ class storyModel extends model
|
||||
$story->status = 'reviewing';
|
||||
}
|
||||
|
||||
$this->dao->update(TABLE_STORY)->set('status')->eq($story->status)->where('id')->eq($storyID)->exec();
|
||||
$this->dao->update(TABLE_STORY)->data($story, 'reviewer')->where('id')->eq($storyID)->exec();
|
||||
if(!dao::isError()) return common::createChanges($oldStory, $story);
|
||||
|
||||
return false;
|
||||
@@ -5549,41 +5554,92 @@ class storyModel extends model
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function setStatusByReviewRules($reviewerList)
|
||||
public function getReviewResult($reviewerList)
|
||||
{
|
||||
$status = '';
|
||||
$results = '';
|
||||
$passCount = 0;
|
||||
$rejectCount = 0;
|
||||
$reviewRule = $this->config->story->reviewRules;
|
||||
foreach($reviewerList as $reviewer => $reviewResult)
|
||||
$results = '';
|
||||
$passCount = 0;
|
||||
$rejectCount = 0;
|
||||
$revertCount = 0;
|
||||
$clarifyCount = 0;
|
||||
$reviewRule = $this->config->story->reviewRules;
|
||||
foreach($reviewerList as $reviewer => $result)
|
||||
{
|
||||
if($reviewResult == 'clarify') return 'draft';
|
||||
$passCount = $result == 'pass' ? $passCount + 1 : $passCount;
|
||||
$rejectCount = $result == 'reject' ? $rejectCount + 1 : $rejectCount;
|
||||
$revertCount = $result == 'revert' ? $revertCount + 1 : $revertCount;
|
||||
$clarifyCount = $result == 'clarify' ? $clarifyCount + 1 : $clarifyCount;
|
||||
|
||||
$passCount = $reviewResult == 'pass' ? $passCount + 1 : $passCount;
|
||||
$rejectCount = $reviewResult == 'reject' ? $rejectCount + 1 : $rejectCount;
|
||||
|
||||
$results .= $reviewResult . ',';
|
||||
$results .= $result . ',';
|
||||
}
|
||||
|
||||
if($reviewRule == 'allpass')
|
||||
{
|
||||
if(strpos($results, 'reject') !== false) return 'closed';
|
||||
$finalResult = '';
|
||||
if($reviewRule == 'allpass' and $passCount == count($reviewerList)) $finalResult = 'pass';
|
||||
if($reviewRule == 'halfpass' and $passCount >= floor(count($reviewerList) / 2) + 1) $finalResult = 'pass';
|
||||
|
||||
if($passCount == count($reviewerList)) $status = 'active';
|
||||
if($rejectCount == count($reviewerList)) $status = 'closed';
|
||||
if(empty($finalResult))
|
||||
{
|
||||
if($clarifyCount >= floor(count($reviewerList) / 2) + 1) return 'clarify';
|
||||
if($revertCount >= floor(count($reviewerList) / 2) + 1) return 'revert';
|
||||
if($rejectCount >= floor(count($reviewerList) / 2) + 1) return 'reject';
|
||||
|
||||
if(strpos($results, 'clarify') !== false) return 'clarify';
|
||||
if(strpos($results, 'revert') !== false) return 'revert';
|
||||
if(strpos($results, 'reject') !== false) return 'reject';
|
||||
}
|
||||
|
||||
if($reviewRule == 'halfpass')
|
||||
{
|
||||
/* When the number of reviewers is even, half of them reject to close. */
|
||||
if(count($reviewerList) > 1 and count($reviewerList) % 2 == 0 and $rejectCount == floor(count($reviewerList) / 2)) return 'closed';
|
||||
return $finalResult;
|
||||
}
|
||||
|
||||
if($passCount >= floor(count($reviewerList) / 2) + 1) $status = 'active';
|
||||
if($rejectCount >= floor(count($reviewerList) / 2) + 1) $status = 'closed';
|
||||
/**
|
||||
* Set story status by reeview result.
|
||||
*
|
||||
* @param int $story
|
||||
* @param int $oldStory
|
||||
* @param int $result
|
||||
* @param string $reason
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function setStatusByReviewResult($story, $oldStory, $result, $reason = 'cancel')
|
||||
{
|
||||
if($result == 'pass') $story->status = 'active';
|
||||
|
||||
if($result == 'clarify')
|
||||
{
|
||||
/* When the review result of the changed story is clarify, the status should be changing. */
|
||||
$isChanged = $oldStory->changedBy ? true : false;
|
||||
$story->status = $isChanged ? 'changing' : 'draft';
|
||||
}
|
||||
|
||||
return $status;
|
||||
if($result == 'revert')
|
||||
{
|
||||
$story->status = 'active';
|
||||
$story->version = $oldStory->version - 1;
|
||||
$story->title = $this->dao->select('title')->from(TABLE_STORYSPEC)->where('story')->eq($story->id)->andWHere('version')->eq($oldStory->version - 1)->fetch('title');
|
||||
|
||||
/* Delete versions that is after this version. */
|
||||
$this->dao->delete()->from(TABLE_STORYSPEC)->where('story')->eq($story->id)->andWHere('version')->in($oldStory->version)->exec();
|
||||
$this->dao->delete()->from(TABLE_STORYREVIEW)->where('story')->eq($story->id)->andWhere('version')->in($oldStory->version)->exec();
|
||||
|
||||
$this->file->deleteStoryFile($story->id, $oldStory->version);
|
||||
}
|
||||
|
||||
if($result == 'reject')
|
||||
{
|
||||
$now = helper::now();
|
||||
$reason = (empty($reason) and isset($story->closedReason)) ? $story->closedReason : $reason;
|
||||
|
||||
$story->status = 'closed';
|
||||
$story->closedBy = $this->app->user->account;
|
||||
$story->closedDate = $now;
|
||||
$story->assignedTo = 'closed';
|
||||
$story->assignedDate = $now;
|
||||
$story->stage = $reason == 'done' ? 'released' : 'closed';
|
||||
$story->closedReason = $reason;
|
||||
}
|
||||
|
||||
$story->finalResult = $result;
|
||||
return $story;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5608,17 +5664,15 @@ class storyModel extends model
|
||||
}
|
||||
|
||||
$reasonParam = $result == 'reject' ? ',' . $reason : '';
|
||||
$reviewers = $this->getReviewerPairs($story->id, $story->version);
|
||||
$reviewedBy = explode(',', trim($story->reviewedBy, ','));
|
||||
$actionID = !empty($result) ? $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($result != 'revert')
|
||||
if(isset($story->finalResult))
|
||||
{
|
||||
$isChanged = $story->changedBy ? true : false;
|
||||
if($story->status == 'closed') $this->action->create('story', $story->id, 'ReviewRejected', '', $isChanged ? 'changing' : 'draft');
|
||||
if($story->status == 'active') $this->action->create('story', $story->id, 'ReviewPassed');
|
||||
if(!array_diff(array_keys($reviewers), $reviewedBy) and ($story->status == 'draft' or $story->status == 'changing')) $this->action->create('story', $story->id, 'ReviewClarified');
|
||||
if($story->finalResult == 'reject') $this->action->create('story', $story->id, 'ReviewRejected', '', $isChanged ? 'changing' : 'draft');
|
||||
if($story->finalResult == 'pass') $this->action->create('story', $story->id, 'ReviewPassed');
|
||||
if($story->finalResult == 'clarify') $this->action->create('story', $story->id, 'ReviewClarified');
|
||||
if($story->finalResult == 'revert') $this->action->create('story', $story->id, 'ReviewReverted');
|
||||
}
|
||||
|
||||
return $actionID;
|
||||
@@ -5638,27 +5692,12 @@ class storyModel extends model
|
||||
$isSuperReviewer = strpos(',' . trim(zget($this->config->story, 'superReviewers', ''), ',') . ',', ',' . $this->app->user->account . ',');
|
||||
if($isSuperReviewer !== false) return $this->superReview($storyID, $oldStory, $story);
|
||||
|
||||
$now = helper::now();
|
||||
$reviewerList = $this->getReviewerPairs($storyID, $oldStory->version);
|
||||
$reviewedBy = explode(',', trim($story->reviewedBy, ','));
|
||||
if(!array_diff(array_keys($reviewerList), $reviewedBy))
|
||||
{
|
||||
$status = $this->post->result == 'revert' ? 'active' : $this->setStatusByReviewRules($reviewerList);
|
||||
|
||||
/* When the review result of the changed story is clarify, the status should be changing. */
|
||||
$isChanged = $oldStory->changedBy ? true : false;
|
||||
$status = ($isChanged and $status == 'draft') ? 'changing' : $status;
|
||||
|
||||
$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';
|
||||
}
|
||||
$reviewResult = $this->getReviewResult($reviewerList);
|
||||
$story = $this->setStatusByReviewResult($story, $oldStory, $reviewResult);
|
||||
}
|
||||
|
||||
return $story;
|
||||
@@ -5680,24 +5719,8 @@ class storyModel extends model
|
||||
$result = isset($_POST['result']) ? $this->post->result : $result;
|
||||
if(empty($result)) return $story;
|
||||
|
||||
$now = helper::now();
|
||||
$status = $oldStory->status;
|
||||
if(strpos('revert,pass', $result) !== false) $status = 'active';
|
||||
if($result == 'reject') $status = 'closed';
|
||||
if($result == 'clarify') $status = 'draft';
|
||||
|
||||
$story->status = $status;
|
||||
|
||||
if($story->status == 'closed')
|
||||
{
|
||||
$story->closedBy = $this->app->user->account;
|
||||
$story->closedDate = $now;
|
||||
$story->assignedTo = 'closed';
|
||||
$story->assignedDate = $now;
|
||||
$story->stage = 'closed';
|
||||
$story->closedReason = isset($_POST['closedReason']) ? $_POST['closedReason'] : $reason;
|
||||
if($_POST['closedReason'] == 'done') $story->stage = 'released';
|
||||
}
|
||||
$reason = isset($_POST['closedReason']) ? $_POST['closedReason'] : $reason;
|
||||
$story = $this->setStatusByReviewResult($story, $oldStory, $result, $reason);
|
||||
|
||||
$this->dao->delete()->from(TABLE_STORYREVIEW)
|
||||
->where('story')->eq($storyID)
|
||||
|
||||
Reference in New Issue
Block a user