2015-04-01 10:09:47 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class ManiphestStatusEmailCommand
|
|
|
|
extends ManiphestEmailCommand {
|
|
|
|
|
|
|
|
public function getCommand() {
|
|
|
|
return 'status';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCommandSyntax() {
|
|
|
|
return '**!status** //status//';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCommandSummary() {
|
|
|
|
return pht('Change the status of a task.');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCommandDescription() {
|
|
|
|
$names = ManiphestTaskStatus::getTaskStatusMap();
|
|
|
|
$keywords = ManiphestTaskStatus::getTaskStatusKeywordsMap();
|
|
|
|
|
|
|
|
$table = array();
|
|
|
|
$table[] = '| '.pht('Status').' | '.pht('Keywords');
|
|
|
|
$table[] = '|---|---|';
|
|
|
|
foreach ($keywords as $status => $words) {
|
2015-12-05 10:40:56 -08:00
|
|
|
if (ManiphestTaskStatus::isDisabledStatus($status)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2015-04-01 10:09:47 -07:00
|
|
|
$words = implode(', ', $words);
|
|
|
|
$table[] = '| '.$names[$status].' | '.$words;
|
|
|
|
}
|
|
|
|
$table = implode("\n", $table);
|
|
|
|
|
|
|
|
return pht(
|
2015-05-22 17:27:56 +10:00
|
|
|
"To change the status of a task, specify the desired status, like ".
|
|
|
|
"`%s`. This table shows the configured names for statuses.\n\n%s\n\n".
|
|
|
|
"If you specify an invalid status, the command is ignored. This ".
|
2016-01-05 14:56:28 -08:00
|
|
|
"command has no effect if you do not specify a status.\n\n".
|
|
|
|
"To quickly close a task, see `%s`.",
|
2015-05-22 17:27:56 +10:00
|
|
|
'!status invalid',
|
2016-01-05 14:56:28 -08:00
|
|
|
$table,
|
|
|
|
'!close');
|
2015-04-01 10:09:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public function buildTransactions(
|
|
|
|
PhabricatorUser $viewer,
|
|
|
|
PhabricatorApplicationTransactionInterface $object,
|
|
|
|
PhabricatorMetaMTAReceivedMail $mail,
|
|
|
|
$command,
|
|
|
|
array $argv) {
|
|
|
|
$xactions = array();
|
|
|
|
|
|
|
|
$target = phutil_utf8_strtolower(head($argv));
|
|
|
|
$status = null;
|
|
|
|
|
|
|
|
$keywords = ManiphestTaskStatus::getTaskStatusKeywordsMap();
|
|
|
|
foreach ($keywords as $key => $words) {
|
|
|
|
foreach ($words as $word) {
|
|
|
|
if ($word == $target) {
|
|
|
|
$status = $key;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($status === null) {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
2015-12-05 10:40:56 -08:00
|
|
|
if (ManiphestTaskStatus::isDisabledStatus($status)) {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
2015-04-01 10:09:47 -07:00
|
|
|
$xactions[] = $object->getApplicationTransactionTemplate()
|
2017-05-15 10:23:20 -07:00
|
|
|
->setTransactionType(ManiphestTaskStatusTransaction::TRANSACTIONTYPE)
|
2015-04-01 10:09:47 -07:00
|
|
|
->setNewValue($status);
|
|
|
|
|
|
|
|
return $xactions;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|