1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-01 11:12:42 +01:00
phorge-phorge/src/applications/differential/constants/DifferentialReviewerStatus.php
epriestley 9da6ec2081 Make updates of rejected revisions behave correctly again
Summary:
Ref T2222. Ref T4481. Specifically:

  - When a revision is updated, change all "Reject" reviewers to "Reject Prior".
  - Change status to "Needs Review".
  - Update the state logic to account for this properly.

Test Plan:
  - Created a revision as user A, with B as a reviewer.
  - Rejected as B.
  - Updated the revision as A.
  - Saw revision in "needs review" state, with B as a "Rejected Prior" reviewer.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T4481, T2222

Differential Revision: https://secure.phabricator.com/D8402
2014-03-05 10:47:29 -08:00

42 lines
1.2 KiB
PHP

<?php
final class DifferentialReviewerStatus {
const STATUS_BLOCKING = 'blocking';
const STATUS_ADDED = 'added';
const STATUS_ACCEPTED = 'accepted';
const STATUS_REJECTED = 'rejected';
const STATUS_COMMENTED = 'commented';
const STATUS_ACCEPTED_OLDER = 'accepted-older';
const STATUS_REJECTED_OLDER = 'rejected-older';
/**
* Returns the relative strength of a status, used to pick a winner when a
* transaction group makes several status changes to a particular reviewer.
*
* For example, if you accept a revision and leave a comment, the transactions
* will attempt to update you to both "commented" and "accepted". We want
* "accepted" to win, because it's the stronger of the two.
*
* @param const Reviewer status constant.
* @return int Relative strength (higher is stronger).
*/
public static function getStatusStrength($constant) {
$map = array(
self::STATUS_ADDED => 1,
self::STATUS_COMMENTED => 2,
self::STATUS_BLOCKING => 3,
self::STATUS_ACCEPTED_OLDER => 4,
self::STATUS_REJECTED_OLDER => 4,
self::STATUS_ACCEPTED => 5,
self::STATUS_REJECTED => 5,
);
return idx($map, $constant, 0);
}
}