mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 12:00:55 +01:00
Merge pull request #77 from mareksapota-fb/master
Pull request for differential revision D1048
This commit is contained in:
commit
2e174d8dbc
3 changed files with 10 additions and 2 deletions
|
@ -378,7 +378,9 @@ class DifferentialRevisionViewController extends DifferentialController {
|
||||||
DifferentialAction::ACTION_COMMENT => true,
|
DifferentialAction::ACTION_COMMENT => true,
|
||||||
);
|
);
|
||||||
|
|
||||||
$viewer_phid = $this->getRequest()->getUser()->getPHID();
|
$viewer = $this->getRequest()->getUser();
|
||||||
|
$viewer_phid = $viewer->getPHID();
|
||||||
|
$viewer_is_admin = $viewer->getIsAdmin();
|
||||||
$viewer_is_owner = ($viewer_phid == $revision->getAuthorPHID());
|
$viewer_is_owner = ($viewer_phid == $revision->getAuthorPHID());
|
||||||
$viewer_is_reviewer = in_array($viewer_phid, $revision->getReviewers());
|
$viewer_is_reviewer = in_array($viewer_phid, $revision->getReviewers());
|
||||||
$viewer_did_accept = ($viewer_phid === $revision->loadReviewedBy());
|
$viewer_did_accept = ($viewer_phid === $revision->loadReviewedBy());
|
||||||
|
@ -407,15 +409,18 @@ class DifferentialRevisionViewController extends DifferentialController {
|
||||||
} else {
|
} else {
|
||||||
switch ($revision->getStatus()) {
|
switch ($revision->getStatus()) {
|
||||||
case DifferentialRevisionStatus::NEEDS_REVIEW:
|
case DifferentialRevisionStatus::NEEDS_REVIEW:
|
||||||
|
$actions[DifferentialAction::ACTION_ABANDON] = $viewer_is_admin;
|
||||||
$actions[DifferentialAction::ACTION_ACCEPT] = true;
|
$actions[DifferentialAction::ACTION_ACCEPT] = true;
|
||||||
$actions[DifferentialAction::ACTION_REJECT] = true;
|
$actions[DifferentialAction::ACTION_REJECT] = true;
|
||||||
$actions[DifferentialAction::ACTION_RESIGN] = $viewer_is_reviewer;
|
$actions[DifferentialAction::ACTION_RESIGN] = $viewer_is_reviewer;
|
||||||
break;
|
break;
|
||||||
case DifferentialRevisionStatus::NEEDS_REVISION:
|
case DifferentialRevisionStatus::NEEDS_REVISION:
|
||||||
|
$actions[DifferentialAction::ACTION_ABANDON] = $viewer_is_admin;
|
||||||
$actions[DifferentialAction::ACTION_ACCEPT] = true;
|
$actions[DifferentialAction::ACTION_ACCEPT] = true;
|
||||||
$actions[DifferentialAction::ACTION_RESIGN] = $viewer_is_reviewer;
|
$actions[DifferentialAction::ACTION_RESIGN] = $viewer_is_reviewer;
|
||||||
break;
|
break;
|
||||||
case DifferentialRevisionStatus::ACCEPTED:
|
case DifferentialRevisionStatus::ACCEPTED:
|
||||||
|
$actions[DifferentialAction::ACTION_ABANDON] = $viewer_is_admin;
|
||||||
$actions[DifferentialAction::ACTION_REJECT] = true;
|
$actions[DifferentialAction::ACTION_REJECT] = true;
|
||||||
$actions[DifferentialAction::ACTION_RESIGN] =
|
$actions[DifferentialAction::ACTION_RESIGN] =
|
||||||
$viewer_is_reviewer && !$viewer_did_accept;
|
$viewer_is_reviewer && !$viewer_did_accept;
|
||||||
|
|
|
@ -98,7 +98,9 @@ class DifferentialCommentEditor {
|
||||||
$revision = $this->revision;
|
$revision = $this->revision;
|
||||||
$action = $this->action;
|
$action = $this->action;
|
||||||
$actor_phid = $this->actorPHID;
|
$actor_phid = $this->actorPHID;
|
||||||
|
$actor = id(new PhabricatorUser())->loadOneWhere('PHID = %s', $actor_phid);
|
||||||
$actor_is_author = ($actor_phid == $revision->getAuthorPHID());
|
$actor_is_author = ($actor_phid == $revision->getAuthorPHID());
|
||||||
|
$actor_is_admin = $actor->getIsAdmin();
|
||||||
$revision_status = $revision->getStatus();
|
$revision_status = $revision->getStatus();
|
||||||
|
|
||||||
$revision->loadRelationships();
|
$revision->loadRelationships();
|
||||||
|
@ -128,7 +130,7 @@ class DifferentialCommentEditor {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DifferentialAction::ACTION_ABANDON:
|
case DifferentialAction::ACTION_ABANDON:
|
||||||
if (!$actor_is_author) {
|
if (!($actor_is_author || $actor_is_admin)) {
|
||||||
throw new Exception('You can only abandon your revisions.');
|
throw new Exception('You can only abandon your revisions.');
|
||||||
}
|
}
|
||||||
if ($revision_status == DifferentialRevisionStatus::COMMITTED) {
|
if ($revision_status == DifferentialRevisionStatus::COMMITTED) {
|
||||||
|
|
|
@ -17,6 +17,7 @@ phutil_require_module('phabricator', 'applications/feed/constants/story');
|
||||||
phutil_require_module('phabricator', 'applications/feed/publisher');
|
phutil_require_module('phabricator', 'applications/feed/publisher');
|
||||||
phutil_require_module('phabricator', 'applications/herald/storage/transcript/base');
|
phutil_require_module('phabricator', 'applications/herald/storage/transcript/base');
|
||||||
phutil_require_module('phabricator', 'applications/markup/engine');
|
phutil_require_module('phabricator', 'applications/markup/engine');
|
||||||
|
phutil_require_module('phabricator', 'applications/people/storage/user');
|
||||||
phutil_require_module('phabricator', 'applications/phid/handle/data');
|
phutil_require_module('phabricator', 'applications/phid/handle/data');
|
||||||
phutil_require_module('phabricator', 'applications/search/index/indexer/differential');
|
phutil_require_module('phabricator', 'applications/search/index/indexer/differential');
|
||||||
phutil_require_module('phabricator', 'infrastructure/daemon/timeline/storage/event');
|
phutil_require_module('phabricator', 'infrastructure/daemon/timeline/storage/event');
|
||||||
|
|
Loading…
Reference in a new issue