mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-15 19:32:40 +01:00
92175488e9
Summary: Fixes T9496. If you have some statuses or priorities you don't need, allow users to disable them to stop the bleeding. Test Plan: - Set task to status X and priority Y. - Disabled X and Y using config. - Verified task still had old status/priority. - Verified new task could not be created/edited into those settings. - Verified task/priority appeared in typeahead, but were marked as disabled. - Viewed email command docs. Reviewers: chad Reviewed By: chad Maniphest Tasks: T9496 Differential Revision: https://secure.phabricator.com/D14681
80 lines
2.1 KiB
PHP
80 lines
2.1 KiB
PHP
<?php
|
|
|
|
final class ManiphestPriorityEmailCommand
|
|
extends ManiphestEmailCommand {
|
|
|
|
public function getCommand() {
|
|
return 'priority';
|
|
}
|
|
|
|
public function getCommandSyntax() {
|
|
return '**!priority** //priority//';
|
|
}
|
|
|
|
public function getCommandSummary() {
|
|
return pht('Change the priority of a task.');
|
|
}
|
|
|
|
public function getCommandDescription() {
|
|
$names = ManiphestTaskPriority::getTaskPriorityMap();
|
|
$keywords = ManiphestTaskPriority::getTaskPriorityKeywordsMap();
|
|
|
|
$table = array();
|
|
$table[] = '| '.pht('Priority').' | '.pht('Keywords');
|
|
$table[] = '|---|---|';
|
|
foreach ($keywords as $priority => $words) {
|
|
if (ManiphestTaskPriority::isDisabledPriority($priority)) {
|
|
continue;
|
|
}
|
|
$words = implode(', ', $words);
|
|
$table[] = '| '.$names[$priority].' | '.$words;
|
|
}
|
|
$table = implode("\n", $table);
|
|
|
|
return pht(
|
|
"To change the priority of a task, specify the desired priority, like ".
|
|
"`%s`. This table shows the configured names for priority levels.".
|
|
"\n\n%s\n\n".
|
|
"If you specify an invalid priority, the command is ignored. This ".
|
|
"command has no effect if you do not specify a priority.",
|
|
'!priority high',
|
|
$table);
|
|
}
|
|
|
|
public function buildTransactions(
|
|
PhabricatorUser $viewer,
|
|
PhabricatorApplicationTransactionInterface $object,
|
|
PhabricatorMetaMTAReceivedMail $mail,
|
|
$command,
|
|
array $argv) {
|
|
$xactions = array();
|
|
|
|
$target = phutil_utf8_strtolower(head($argv));
|
|
$priority = null;
|
|
|
|
$keywords = ManiphestTaskPriority::getTaskPriorityKeywordsMap();
|
|
foreach ($keywords as $key => $words) {
|
|
foreach ($words as $word) {
|
|
if ($word == $target) {
|
|
$priority = $key;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($priority === null) {
|
|
return array();
|
|
}
|
|
|
|
if (ManiphestTaskPriority::isDisabledPriority($priority)) {
|
|
return array();
|
|
}
|
|
|
|
$xactions[] = $object->getApplicationTransactionTemplate()
|
|
->setTransactionType(ManiphestTransaction::TYPE_PRIORITY)
|
|
->setNewValue($priority);
|
|
|
|
return $xactions;
|
|
}
|
|
|
|
}
|