Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/meta/controller/PhabricatorApplicationEmailCommandsController.php
12256 views
1
<?php
2
3
final class PhabricatorApplicationEmailCommandsController
4
extends PhabricatorApplicationsController {
5
6
public function shouldAllowPublic() {
7
return true;
8
}
9
10
public function handleRequest(AphrontRequest $request) {
11
$viewer = $this->getViewer();
12
$application = $request->getURIData('application');
13
14
$selected = id(new PhabricatorApplicationQuery())
15
->setViewer($viewer)
16
->withClasses(array($application))
17
->executeOne();
18
if (!$selected) {
19
return new Aphront404Response();
20
}
21
22
$specs = $selected->getMailCommandObjects();
23
$type = $request->getURIData('type');
24
if (empty($specs[$type])) {
25
return new Aphront404Response();
26
}
27
28
$spec = $specs[$type];
29
$commands = MetaMTAEmailTransactionCommand::getAllCommandsForObject(
30
$spec['object']);
31
32
$commands = msort($commands, 'getCommand');
33
34
$content = array();
35
36
$content[] = '= '.pht('Mail Commands Overview');
37
$content[] = pht(
38
'After configuring processing for inbound mail, you can '.
39
'interact with objects (like tasks and revisions) over email. For '.
40
'information on configuring inbound mail, see '.
41
'**[[ %s | Configuring Inbound Email ]]**.'.
42
"\n\n".
43
'In most cases, you can reply to email you receive from this server '.
44
'to leave comments. You can also use **mail commands** to take a '.
45
'greater range of actions (like claiming a task or requesting changes '.
46
'to a revision) without needing to log in to the web UI.'.
47
"\n\n".
48
'Mail commands are keywords which start with an exclamation point, '.
49
'like `!claim`. Some commands may take parameters, like '.
50
"`!assign alincoln`.\n\n".
51
'To use mail commands, write one command per line at the beginning '.
52
'or end of your mail message. For example, you could write this in a '.
53
'reply to task email to claim the task:'.
54
"\n\n```\n!claim\n\nI'll take care of this.\n```\n\n\n".
55
"When %s receives your mail, it will process any commands ".
56
"first, then post the remaining message body as a comment. You can ".
57
"execute multiple commands at once:".
58
"\n\n```\n!assign alincoln\n!close\n\nI just talked to @alincoln, ".
59
"and he showed me that he fixed this.\n```\n",
60
PhabricatorEnv::getDoclink('Configuring Inbound Email'),
61
PlatformSymbols::getPlatformServerName());
62
63
$content[] = '= '.$spec['header'];
64
$content[] = $spec['summary'];
65
66
$content[] = '= '.pht('Quick Reference');
67
$content[] = pht(
68
'This table summarizes the available mail commands. For details on a '.
69
'specific command, see the command section below.');
70
$table = array();
71
$table[] = '| '.pht('Command').' | '.pht('Summary').' |';
72
$table[] = '|---|---|';
73
foreach ($commands as $command) {
74
$summary = $command->getCommandSummary();
75
$table[] = '| '.$command->getCommandSyntax().' | '.$summary;
76
}
77
$table = implode("\n", $table);
78
$content[] = $table;
79
80
foreach ($commands as $command) {
81
$content[] = '== !'.$command->getCommand().' ==';
82
$content[] = $command->getCommandSummary();
83
84
$aliases = $command->getCommandAliases();
85
if ($aliases) {
86
foreach ($aliases as $key => $alias) {
87
$aliases[$key] = '!'.$alias;
88
}
89
$aliases = implode(', ', $aliases);
90
} else {
91
$aliases = '//None//';
92
}
93
94
$syntax = $command->getCommandSyntax();
95
96
$table = array();
97
$table[] = '| '.pht('Property').' | '.pht('Value');
98
$table[] = '|---|---|';
99
$table[] = '| **'.pht('Syntax').'** | '.$syntax;
100
$table[] = '| **'.pht('Aliases').'** | '.$aliases;
101
$table[] = '| **'.pht('Class').'** | `'.get_class($command).'`';
102
$table = implode("\n", $table);
103
104
$content[] = $table;
105
106
$description = $command->getCommandDescription();
107
if ($description) {
108
$content[] = $description;
109
}
110
}
111
112
$content = implode("\n\n", $content);
113
114
$title = $spec['name'];
115
116
$crumbs = $this->buildApplicationCrumbs();
117
$this->addApplicationCrumb($crumbs, $selected);
118
$crumbs->addTextCrumb($title);
119
$crumbs->setBorder(true);
120
121
$content_box = new PHUIRemarkupView($viewer, $content);
122
123
$info_view = null;
124
if (!PhabricatorEnv::getEnvConfig('metamta.reply-handler-domain')) {
125
$error = pht(
126
"This server is not currently configured to accept inbound mail. ".
127
"You won't be able to interact with objects over email until ".
128
"inbound mail is set up.");
129
$info_view = id(new PHUIInfoView())
130
->setErrors(array($error));
131
}
132
133
$header = id(new PHUIHeaderView())
134
->setHeader($title);
135
136
$document = id(new PHUIDocumentView())
137
->setHeader($header)
138
->appendChild($info_view)
139
->appendChild($content_box);
140
141
return $this->newPage()
142
->setTitle($title)
143
->setCrumbs($crumbs)
144
->appendChild($document);
145
146
}
147
148
149
}
150
151