2011-01-16 22:51:39 +01:00
|
|
|
<?php
|
|
|
|
|
2015-06-15 10:02:26 +02:00
|
|
|
final class DifferentialAction extends Phobject {
|
2011-01-16 22:51:39 +01:00
|
|
|
|
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
|
|
|
|
2014-02-09 19:07:29 +01:00
|
|
|
public static function getBasicStoryText($action, $author_name) {
|
|
|
|
switch ($action) {
|
2015-05-13 22:50:28 +02:00
|
|
|
case self::ACTION_COMMENT:
|
2015-05-22 09:27:56 +02:00
|
|
|
$title = pht(
|
|
|
|
'%s commented on this revision.',
|
2014-09-12 19:12:52 +02:00
|
|
|
$author_name);
|
|
|
|
break;
|
2015-05-13 22:50:28 +02:00
|
|
|
case self::ACTION_ACCEPT:
|
2015-05-22 09:27:56 +02:00
|
|
|
$title = pht(
|
|
|
|
'%s accepted this revision.',
|
2014-09-12 19:12:52 +02:00
|
|
|
$author_name);
|
|
|
|
break;
|
2015-05-13 22:50:28 +02:00
|
|
|
case self::ACTION_REJECT:
|
2015-05-22 09:27:56 +02:00
|
|
|
$title = pht(
|
|
|
|
'%s requested changes to this revision.',
|
2014-09-12 19:12:52 +02:00
|
|
|
$author_name);
|
|
|
|
break;
|
2015-05-13 22:50:28 +02:00
|
|
|
case self::ACTION_RETHINK:
|
2015-05-22 09:27:56 +02:00
|
|
|
$title = pht(
|
|
|
|
'%s planned changes to this revision.',
|
2014-09-12 19:12:52 +02:00
|
|
|
$author_name);
|
|
|
|
break;
|
2015-05-13 22:50:28 +02:00
|
|
|
case self::ACTION_ABANDON:
|
2015-05-22 09:27:56 +02:00
|
|
|
$title = pht(
|
|
|
|
'%s abandoned this revision.',
|
2014-09-12 19:12:52 +02:00
|
|
|
$author_name);
|
|
|
|
break;
|
2015-05-13 22:50:28 +02:00
|
|
|
case self::ACTION_CLOSE:
|
2015-05-22 09:27:56 +02:00
|
|
|
$title = pht(
|
|
|
|
'%s closed this revision.',
|
2014-09-12 19:12:52 +02:00
|
|
|
$author_name);
|
|
|
|
break;
|
2015-05-13 22:50:28 +02:00
|
|
|
case self::ACTION_REQUEST:
|
2015-05-22 09:27:56 +02:00
|
|
|
$title = pht(
|
|
|
|
'%s requested a review of this revision.',
|
2014-09-12 19:12:52 +02:00
|
|
|
$author_name);
|
|
|
|
break;
|
2015-05-13 22:50:28 +02:00
|
|
|
case self::ACTION_RECLAIM:
|
2015-05-22 09:27:56 +02:00
|
|
|
$title = pht(
|
|
|
|
'%s reclaimed this revision.',
|
2014-09-12 19:12:52 +02:00
|
|
|
$author_name);
|
|
|
|
break;
|
2015-05-13 22:50:28 +02:00
|
|
|
case self::ACTION_UPDATE:
|
2015-05-22 09:27:56 +02:00
|
|
|
$title = pht(
|
|
|
|
'%s updated this revision.',
|
2014-09-12 19:12:52 +02:00
|
|
|
$author_name);
|
|
|
|
break;
|
2015-05-13 22:50:28 +02:00
|
|
|
case self::ACTION_RESIGN:
|
2015-05-22 09:27:56 +02:00
|
|
|
$title = pht(
|
|
|
|
'%s resigned from this revision.',
|
2014-09-12 19:12:52 +02:00
|
|
|
$author_name);
|
|
|
|
break;
|
2015-05-13 22:50:28 +02:00
|
|
|
case self::ACTION_SUMMARIZE:
|
2015-05-22 09:27:56 +02:00
|
|
|
$title = pht(
|
|
|
|
'%s summarized this revision.',
|
2014-09-12 19:12:52 +02:00
|
|
|
$author_name);
|
|
|
|
break;
|
2015-05-13 22:50:28 +02:00
|
|
|
case self::ACTION_TESTPLAN:
|
2015-05-22 09:27:56 +02:00
|
|
|
$title = pht(
|
|
|
|
'%s explained the test plan for this revision.',
|
2014-09-12 19:12:52 +02:00
|
|
|
$author_name);
|
|
|
|
break;
|
2015-05-13 22:50:28 +02:00
|
|
|
case self::ACTION_CREATE:
|
2015-05-22 09:27:56 +02:00
|
|
|
$title = pht(
|
|
|
|
'%s created this revision.',
|
2014-09-12 19:12:52 +02:00
|
|
|
$author_name);
|
|
|
|
break;
|
2015-05-13 22:50:28 +02:00
|
|
|
case self::ACTION_ADDREVIEWERS:
|
2015-05-22 09:27:56 +02:00
|
|
|
$title = pht(
|
|
|
|
'%s added reviewers to this revision.',
|
2014-09-12 19:12:52 +02:00
|
|
|
$author_name);
|
|
|
|
break;
|
2015-05-13 22:50:28 +02:00
|
|
|
case self::ACTION_ADDCCS:
|
2015-05-22 09:27:56 +02:00
|
|
|
$title = pht(
|
|
|
|
'%s added CCs to this revision.',
|
2014-09-12 19:12:52 +02:00
|
|
|
$author_name);
|
|
|
|
break;
|
2015-05-13 22:50:28 +02:00
|
|
|
case self::ACTION_CLAIM:
|
2015-05-22 09:27:56 +02:00
|
|
|
$title = pht(
|
|
|
|
'%s commandeered this revision.',
|
2014-09-12 19:12:52 +02:00
|
|
|
$author_name);
|
|
|
|
break;
|
2015-05-13 22:50:28 +02:00
|
|
|
case self::ACTION_REOPEN:
|
2015-05-22 09:27:56 +02:00
|
|
|
$title = pht(
|
|
|
|
'%s reopened this revision.',
|
2014-09-12 19:12:52 +02:00
|
|
|
$author_name);
|
|
|
|
break;
|
|
|
|
case DifferentialTransaction::TYPE_INLINE:
|
|
|
|
$title = pht(
|
|
|
|
'%s added an inline comment.',
|
|
|
|
$author_name);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$title = pht('Ghosts happened to this revision.');
|
|
|
|
break;
|
|
|
|
}
|
2014-02-09 19:07:29 +01:00
|
|
|
return $title;
|
|
|
|
}
|
|
|
|
|
2011-01-30 20:02:22 +01:00
|
|
|
public static function getActionVerb($action) {
|
2013-01-24 19:46:47 +01:00
|
|
|
$verbs = array(
|
|
|
|
self::ACTION_COMMENT => pht('Comment'),
|
|
|
|
self::ACTION_ACCEPT => pht("Accept Revision \xE2\x9C\x94"),
|
|
|
|
self::ACTION_REJECT => pht("Request Changes \xE2\x9C\x98"),
|
|
|
|
self::ACTION_RETHINK => pht("Plan Changes \xE2\x9C\x98"),
|
|
|
|
self::ACTION_ABANDON => pht('Abandon Revision'),
|
|
|
|
self::ACTION_REQUEST => pht('Request Review'),
|
|
|
|
self::ACTION_RECLAIM => pht('Reclaim Revision'),
|
|
|
|
self::ACTION_RESIGN => pht('Resign as Reviewer'),
|
|
|
|
self::ACTION_ADDREVIEWERS => pht('Add Reviewers'),
|
2014-06-04 00:53:52 +02:00
|
|
|
self::ACTION_ADDCCS => pht('Add Subscribers'),
|
2013-01-24 19:46:47 +01:00
|
|
|
self::ACTION_CLOSE => pht('Close Revision'),
|
|
|
|
self::ACTION_CLAIM => pht('Commandeer Revision'),
|
|
|
|
self::ACTION_REOPEN => pht('Reopen'),
|
2011-01-30 20:02:22 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
if (!empty($verbs[$action])) {
|
|
|
|
return $verbs[$action];
|
|
|
|
} else {
|
2015-05-22 09:27:56 +02:00
|
|
|
return pht('brazenly %s', $action);
|
2011-01-30 20:02:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-20 23:11:11 +02:00
|
|
|
public static function allowReviewers($action) {
|
2015-05-13 22:50:28 +02:00
|
|
|
if ($action == self::ACTION_ADDREVIEWERS ||
|
|
|
|
$action == self::ACTION_REQUEST ||
|
|
|
|
$action == self::ACTION_RESIGN) {
|
2012-09-20 23:11:11 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-01-16 22:51:39 +01:00
|
|
|
}
|