2011-01-16 22:51:39 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DifferentialAction {
|
|
|
|
|
2012-04-24 02:40:57 +02:00
|
|
|
const ACTION_CLOSE = 'commit';
|
2011-01-16 22:51:39 +01:00
|
|
|
const ACTION_COMMENT = 'none';
|
|
|
|
const ACTION_ACCEPT = 'accept';
|
|
|
|
const ACTION_REJECT = 'reject';
|
2011-04-14 01:10:54 +02:00
|
|
|
const ACTION_RETHINK = 'rethink';
|
2011-01-16 22:51:39 +01:00
|
|
|
const ACTION_ABANDON = 'abandon';
|
|
|
|
const ACTION_REQUEST = 'request_review';
|
|
|
|
const ACTION_RECLAIM = 'reclaim';
|
|
|
|
const ACTION_UPDATE = 'update';
|
|
|
|
const ACTION_RESIGN = 'resign';
|
|
|
|
const ACTION_SUMMARIZE = 'summarize';
|
|
|
|
const ACTION_TESTPLAN = 'testplan';
|
|
|
|
const ACTION_CREATE = 'create';
|
|
|
|
const ACTION_ADDREVIEWERS = 'add_reviewers';
|
2011-06-24 21:21:48 +02:00
|
|
|
const ACTION_ADDCCS = 'add_ccs';
|
2012-04-17 23:59:31 +02:00
|
|
|
const ACTION_CLAIM = 'claim';
|
2013-01-19 18:10:15 +01:00
|
|
|
const ACTION_REOPEN = 'reopen';
|
2011-01-16 22:51:39 +01:00
|
|
|
|
2011-01-30 20:02:22 +01:00
|
|
|
public static function getActionPastTenseVerb($action) {
|
2012-06-15 04:18:05 +02:00
|
|
|
$verbs = array(
|
2011-01-16 22:51:39 +01:00
|
|
|
self::ACTION_COMMENT => 'commented on',
|
|
|
|
self::ACTION_ACCEPT => 'accepted',
|
|
|
|
self::ACTION_REJECT => 'requested changes to',
|
2011-04-14 01:10:54 +02:00
|
|
|
self::ACTION_RETHINK => 'planned changes to',
|
2011-01-16 22:51:39 +01:00
|
|
|
self::ACTION_ABANDON => 'abandoned',
|
2012-06-15 04:18:05 +02:00
|
|
|
self::ACTION_CLOSE => pht('closed'),
|
2011-01-16 22:51:39 +01:00
|
|
|
self::ACTION_REQUEST => 'requested a review of',
|
|
|
|
self::ACTION_RECLAIM => 'reclaimed',
|
|
|
|
self::ACTION_UPDATE => 'updated',
|
|
|
|
self::ACTION_RESIGN => 'resigned from',
|
|
|
|
self::ACTION_SUMMARIZE => 'summarized',
|
|
|
|
self::ACTION_TESTPLAN => 'explained the test plan for',
|
|
|
|
self::ACTION_CREATE => 'created',
|
|
|
|
self::ACTION_ADDREVIEWERS => 'added reviewers to',
|
2011-06-24 21:21:48 +02:00
|
|
|
self::ACTION_ADDCCS => 'added CCs to',
|
2012-04-17 23:59:31 +02:00
|
|
|
self::ACTION_CLAIM => 'commandeered',
|
2013-01-19 18:10:15 +01:00
|
|
|
self::ACTION_REOPEN => 'reopened',
|
2011-01-16 22:51:39 +01:00
|
|
|
);
|
|
|
|
|
2011-01-30 19:37:36 +01:00
|
|
|
if (!empty($verbs[$action])) {
|
2011-01-16 22:51:39 +01:00
|
|
|
return $verbs[$action];
|
|
|
|
} else {
|
|
|
|
return 'brazenly "'.$action.'ed"';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-30 20:02:22 +01:00
|
|
|
public static function getActionVerb($action) {
|
|
|
|
static $verbs = array(
|
|
|
|
self::ACTION_COMMENT => 'Comment',
|
|
|
|
self::ACTION_ACCEPT => "Accept Revision \xE2\x9C\x94",
|
|
|
|
self::ACTION_REJECT => "Request Changes \xE2\x9C\x98",
|
2011-04-14 01:10:54 +02:00
|
|
|
self::ACTION_RETHINK => "Plan Changes \xE2\x9C\x98",
|
2011-01-30 20:02:22 +01:00
|
|
|
self::ACTION_ABANDON => 'Abandon Revision',
|
|
|
|
self::ACTION_REQUEST => 'Request Review',
|
|
|
|
self::ACTION_RECLAIM => 'Reclaim Revision',
|
|
|
|
self::ACTION_RESIGN => 'Resign as Reviewer',
|
|
|
|
self::ACTION_ADDREVIEWERS => 'Add Reviewers',
|
2011-06-24 21:21:48 +02:00
|
|
|
self::ACTION_ADDCCS => 'Add CCs',
|
2012-04-24 02:40:57 +02:00
|
|
|
self::ACTION_CLOSE => 'Close Revision',
|
2012-04-17 23:59:31 +02:00
|
|
|
self::ACTION_CLAIM => 'Commandeer Revision',
|
2013-01-19 18:10:15 +01:00
|
|
|
self::ACTION_REOPEN => 'Reopen',
|
2011-01-30 20:02:22 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
if (!empty($verbs[$action])) {
|
|
|
|
return $verbs[$action];
|
|
|
|
} else {
|
|
|
|
return 'brazenly '.$action;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-20 23:11:11 +02:00
|
|
|
public static function allowReviewers($action) {
|
|
|
|
if ($action == DifferentialAction::ACTION_ADDREVIEWERS ||
|
|
|
|
$action == DifferentialAction::ACTION_REQUEST) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-01-16 22:51:39 +01:00
|
|
|
}
|