@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class ManiphestPriorityEmailCommand
4 extends ManiphestEmailCommand {
5
6 public function getCommand() {
7 return 'priority';
8 }
9
10 public function getCommandSyntax() {
11 return '**!priority** //priority//';
12 }
13
14 public function getCommandSummary() {
15 return pht('Change the priority of a task.');
16 }
17
18 public function getCommandDescription() {
19 $names = ManiphestTaskPriority::getTaskPriorityMap();
20 $keywords = ManiphestTaskPriority::getTaskPriorityKeywordsMap();
21
22 $table = array();
23 $table[] = '| '.pht('Priority').' | '.pht('Keywords');
24 $table[] = '|---|---|';
25 foreach ($keywords as $priority => $words) {
26 if (ManiphestTaskPriority::isDisabledPriority($priority)) {
27 continue;
28 }
29 $words = implode(', ', $words);
30 $table[] = '| '.$names[$priority].' | '.$words;
31 }
32 $table = implode("\n", $table);
33
34 return pht(
35 "To change the priority of a task, specify the desired priority, like ".
36 "`%s`. This table shows the configured names for priority levels.".
37 "\n\n%s\n\n".
38 "If you specify an invalid priority, the command is ignored. This ".
39 "command has no effect if you do not specify a priority.",
40 '!priority high',
41 $table);
42 }
43
44 public function buildTransactions(
45 PhabricatorUser $viewer,
46 PhabricatorApplicationTransactionInterface $object,
47 PhabricatorMetaMTAReceivedMail $mail,
48 $command,
49 array $argv) {
50 $xactions = array();
51
52 $keyword = phutil_utf8_strtolower(head($argv));
53 $priority = ManiphestTaskPriority::getTaskPriorityFromKeyword($keyword);
54
55 if ($priority === null) {
56 return array();
57 }
58
59 if (ManiphestTaskPriority::isDisabledPriority($priority)) {
60 return array();
61 }
62
63 $xactions[] = $object->getApplicationTransactionTemplate()
64 ->setTransactionType(ManiphestTaskPriorityTransaction::TRANSACTIONTYPE)
65 ->setNewValue($keyword);
66
67 return $xactions;
68 }
69
70}