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 Phabricator to process inbound mail, you can '.
39 'interact with objects (like tasks and revisions) over email. For '.
40 'information on configuring Phabricator, see '.
41 '**[[ %s | Configuring Inbound Email ]]**.'.
43 'In most cases, you can reply to email you receive from Phabricator '.
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 Phabricator 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'));
62 $content[] = '= '.$spec['header'];
63 $content[] = $spec['summary'];
65 $content[] = '= '.pht('Quick Reference');
67 'This table summarizes the available mail commands. For details on a '.
68 'specific command, see the command section below.');
70 $table[] = '| '.pht('Command').' | '.pht('Summary').' |';
71 $table[] = '|---|---|';
72 foreach ($commands as $command) {
73 $summary = $command->getCommandSummary();
74 $table[] = '| '.$command->getCommandSyntax().' | '.$summary;
76 $table = implode("\n", $table);
79 foreach ($commands as $command) {
80 $content[] = '== !'.$command->getCommand().' ==';
81 $content[] = $command->getCommandSummary();
83 $aliases = $command->getCommandAliases();
85 foreach ($aliases as $key => $alias) {
86 $aliases[$key] = '!'.$alias;
88 $aliases = implode(', ', $aliases);
90 $aliases = '//None//';
93 $syntax = $command->getCommandSyntax();
96 $table[] = '| '.pht('Property').' | '.pht('Value');
97 $table[] = '|---|---|';
98 $table[] = '| **'.pht('Syntax').'** | '.$syntax;
99 $table[] = '| **'.pht('Aliases').'** | '.$aliases;
100 $table[] = '| **'.pht('Class').'** | `'.get_class($command).'`';
101 $table = implode("\n", $table);
105 $description = $command->getCommandDescription();
107 $content[] = $description;
111 $content = implode("\n\n", $content);
113 $title = $spec['name'];
115 $crumbs = $this->buildApplicationCrumbs();
116 $this->addApplicationCrumb($crumbs, $selected);
117 $crumbs->addTextCrumb($title);
118 $crumbs->setBorder(true);
120 $content_box = new PHUIRemarkupView($viewer, $content);
123 if (!PhabricatorEnv
::getEnvConfig('metamta.reply-handler-domain')) {
125 "Phabricator is not currently configured to accept inbound mail. ".
126 "You won't be able to interact with objects over email until ".
127 "inbound mail is set up.");
128 $info_view = id(new PHUIInfoView())
129 ->setErrors(array($error));
132 $header = id(new PHUIHeaderView())
135 $document = id(new PHUIDocumentView())
137 ->appendChild($info_view)
138 ->appendChild($content_box);
140 return $this->newPage()
143 ->appendChild($document);