3 final class PhabricatorApplicationEmailCommandsController
4 extends PhabricatorApplicationsController
{
6 public function shouldAllowPublic() {
10 public function handleRequest(AphrontRequest
$request) {
11 $viewer = $this->getViewer();
12 $application = $request->getURIData('application');
14 $selected = id(new PhabricatorApplicationQuery())
16 ->withClasses(array($application))
19 return new Aphront404Response();
22 $specs = $selected->getMailCommandObjects();
23 $type = $request->getURIData('type');
24 if (empty($specs[$type])) {
25 return new Aphront404Response();
28 $spec = $specs[$type];
29 $commands = MetaMTAEmailTransactionCommand
::getAllCommandsForObject(
32 $commands = msort($commands, 'getCommand');
36 $content[] = '= '.pht('Mail Commands Overview');
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 ]]**.'.
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.'.
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());
63 $content[] = '= '.$spec['header'];
64 $content[] = $spec['summary'];
66 $content[] = '= '.pht('Quick Reference');
68 'This table summarizes the available mail commands. For details on a '.
69 'specific command, see the command section below.');
71 $table[] = '| '.pht('Command').' | '.pht('Summary').' |';
72 $table[] = '|---|---|';
73 foreach ($commands as $command) {
74 $summary = $command->getCommandSummary();
75 $table[] = '| '.$command->getCommandSyntax().' | '.$summary;
77 $table = implode("\n", $table);
80 foreach ($commands as $command) {
81 $content[] = '== !'.$command->getCommand().' ==';
82 $content[] = $command->getCommandSummary();
84 $aliases = $command->getCommandAliases();
86 foreach ($aliases as $key => $alias) {
87 $aliases[$key] = '!'.$alias;
89 $aliases = implode(', ', $aliases);
91 $aliases = '//None//';
94 $syntax = $command->getCommandSyntax();
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);
106 $description = $command->getCommandDescription();
108 $content[] = $description;
112 $content = implode("\n\n", $content);
114 $title = $spec['name'];
116 $crumbs = $this->buildApplicationCrumbs();
117 $this->addApplicationCrumb($crumbs, $selected);
118 $crumbs->addTextCrumb($title);
119 $crumbs->setBorder(true);
121 $content_box = new PHUIRemarkupView($viewer, $content);
124 if (!PhabricatorEnv
::getEnvConfig('metamta.reply-handler-domain')) {
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));
133 $header = id(new PHUIHeaderView())
136 $document = id(new PHUIDocumentView())
138 ->appendChild($info_view)
139 ->appendChild($content_box);
141 return $this->newPage()
144 ->appendChild($document);