diff --git a/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php b/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php index aa6b215d1e..d52dc85f26 100644 --- a/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php +++ b/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php @@ -378,7 +378,9 @@ class DifferentialRevisionViewController extends DifferentialController { 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_reviewer = in_array($viewer_phid, $revision->getReviewers()); $viewer_did_accept = ($viewer_phid === $revision->loadReviewedBy()); @@ -407,15 +409,18 @@ class DifferentialRevisionViewController extends DifferentialController { } else { switch ($revision->getStatus()) { case DifferentialRevisionStatus::NEEDS_REVIEW: + $actions[DifferentialAction::ACTION_ABANDON] = $viewer_is_admin; $actions[DifferentialAction::ACTION_ACCEPT] = true; $actions[DifferentialAction::ACTION_REJECT] = true; $actions[DifferentialAction::ACTION_RESIGN] = $viewer_is_reviewer; break; case DifferentialRevisionStatus::NEEDS_REVISION: + $actions[DifferentialAction::ACTION_ABANDON] = $viewer_is_admin; $actions[DifferentialAction::ACTION_ACCEPT] = true; $actions[DifferentialAction::ACTION_RESIGN] = $viewer_is_reviewer; break; case DifferentialRevisionStatus::ACCEPTED: + $actions[DifferentialAction::ACTION_ABANDON] = $viewer_is_admin; $actions[DifferentialAction::ACTION_REJECT] = true; $actions[DifferentialAction::ACTION_RESIGN] = $viewer_is_reviewer && !$viewer_did_accept; diff --git a/src/applications/differential/editor/comment/DifferentialCommentEditor.php b/src/applications/differential/editor/comment/DifferentialCommentEditor.php index 61e7ca55b5..2610f05f27 100644 --- a/src/applications/differential/editor/comment/DifferentialCommentEditor.php +++ b/src/applications/differential/editor/comment/DifferentialCommentEditor.php @@ -98,7 +98,9 @@ class DifferentialCommentEditor { $revision = $this->revision; $action = $this->action; $actor_phid = $this->actorPHID; + $actor = id(new PhabricatorUser())->loadOneWhere('PHID = %s', $actor_phid); $actor_is_author = ($actor_phid == $revision->getAuthorPHID()); + $actor_is_admin = $actor->getIsAdmin(); $revision_status = $revision->getStatus(); $revision->loadRelationships(); @@ -128,7 +130,7 @@ class DifferentialCommentEditor { break; case DifferentialAction::ACTION_ABANDON: - if (!$actor_is_author) { + if (!($actor_is_author || $actor_is_admin)) { throw new Exception('You can only abandon your revisions.'); } if ($revision_status == DifferentialRevisionStatus::COMMITTED) { diff --git a/src/applications/differential/editor/comment/__init__.php b/src/applications/differential/editor/comment/__init__.php index c60ff05e83..a93e72f8f9 100644 --- a/src/applications/differential/editor/comment/__init__.php +++ b/src/applications/differential/editor/comment/__init__.php @@ -17,6 +17,7 @@ phutil_require_module('phabricator', 'applications/feed/constants/story'); phutil_require_module('phabricator', 'applications/feed/publisher'); phutil_require_module('phabricator', 'applications/herald/storage/transcript/base'); 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/search/index/indexer/differential'); phutil_require_module('phabricator', 'infrastructure/daemon/timeline/storage/event');