Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/maniphest/command/ManiphestStatusEmailCommand.php
12256 views
1
<?php
2
3
final class ManiphestStatusEmailCommand
4
extends ManiphestEmailCommand {
5
6
public function getCommand() {
7
return 'status';
8
}
9
10
public function getCommandSyntax() {
11
return '**!status** //status//';
12
}
13
14
public function getCommandSummary() {
15
return pht('Change the status of a task.');
16
}
17
18
public function getCommandDescription() {
19
$names = ManiphestTaskStatus::getTaskStatusMap();
20
$keywords = ManiphestTaskStatus::getTaskStatusKeywordsMap();
21
22
$table = array();
23
$table[] = '| '.pht('Status').' | '.pht('Keywords');
24
$table[] = '|---|---|';
25
foreach ($keywords as $status => $words) {
26
if (ManiphestTaskStatus::isDisabledStatus($status)) {
27
continue;
28
}
29
30
$words = implode(', ', $words);
31
$table[] = '| '.$names[$status].' | '.$words;
32
}
33
$table = implode("\n", $table);
34
35
return pht(
36
"To change the status of a task, specify the desired status, like ".
37
"`%s`. This table shows the configured names for statuses.\n\n%s\n\n".
38
"If you specify an invalid status, the command is ignored. This ".
39
"command has no effect if you do not specify a status.\n\n".
40
"To quickly close a task, see `%s`.",
41
'!status invalid',
42
$table,
43
'!close');
44
}
45
46
public function buildTransactions(
47
PhabricatorUser $viewer,
48
PhabricatorApplicationTransactionInterface $object,
49
PhabricatorMetaMTAReceivedMail $mail,
50
$command,
51
array $argv) {
52
$xactions = array();
53
54
$target = phutil_utf8_strtolower(head($argv));
55
$status = null;
56
57
$keywords = ManiphestTaskStatus::getTaskStatusKeywordsMap();
58
foreach ($keywords as $key => $words) {
59
foreach ($words as $word) {
60
if ($word == $target) {
61
$status = $key;
62
break;
63
}
64
}
65
}
66
67
if ($status === null) {
68
return array();
69
}
70
71
if (ManiphestTaskStatus::isDisabledStatus($status)) {
72
return array();
73
}
74
75
$xactions[] = $object->getApplicationTransactionTemplate()
76
->setTransactionType(ManiphestTaskStatusTransaction::TRANSACTIONTYPE)
77
->setNewValue($status);
78
79
return $xactions;
80
}
81
82
}
83
84