1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 14:30:56 +01:00

Allow admins to abandon Differential revisions.

Test Plan:
Login as an admin, go to a revision that you don't own - you should be able to
abandon this revision.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: 1048
This commit is contained in:
Marek Sapota 2011-10-25 14:03:34 -07:00
parent 6737ae4828
commit 9536e5606c
3 changed files with 10 additions and 2 deletions

View file

@ -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;

View file

@ -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) {

View file

@ -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');