Path: blob/master/src/applications/meta/controller/PhabricatorApplicationEmailCommandsController.php
12256 views
<?php12final class PhabricatorApplicationEmailCommandsController3extends PhabricatorApplicationsController {45public function shouldAllowPublic() {6return true;7}89public function handleRequest(AphrontRequest $request) {10$viewer = $this->getViewer();11$application = $request->getURIData('application');1213$selected = id(new PhabricatorApplicationQuery())14->setViewer($viewer)15->withClasses(array($application))16->executeOne();17if (!$selected) {18return new Aphront404Response();19}2021$specs = $selected->getMailCommandObjects();22$type = $request->getURIData('type');23if (empty($specs[$type])) {24return new Aphront404Response();25}2627$spec = $specs[$type];28$commands = MetaMTAEmailTransactionCommand::getAllCommandsForObject(29$spec['object']);3031$commands = msort($commands, 'getCommand');3233$content = array();3435$content[] = '= '.pht('Mail Commands Overview');36$content[] = pht(37'After configuring processing for inbound mail, you can '.38'interact with objects (like tasks and revisions) over email. For '.39'information on configuring inbound mail, see '.40'**[[ %s | Configuring Inbound Email ]]**.'.41"\n\n".42'In most cases, you can reply to email you receive from this server '.43'to leave comments. You can also use **mail commands** to take a '.44'greater range of actions (like claiming a task or requesting changes '.45'to a revision) without needing to log in to the web UI.'.46"\n\n".47'Mail commands are keywords which start with an exclamation point, '.48'like `!claim`. Some commands may take parameters, like '.49"`!assign alincoln`.\n\n".50'To use mail commands, write one command per line at the beginning '.51'or end of your mail message. For example, you could write this in a '.52'reply to task email to claim the task:'.53"\n\n```\n!claim\n\nI'll take care of this.\n```\n\n\n".54"When %s receives your mail, it will process any commands ".55"first, then post the remaining message body as a comment. You can ".56"execute multiple commands at once:".57"\n\n```\n!assign alincoln\n!close\n\nI just talked to @alincoln, ".58"and he showed me that he fixed this.\n```\n",59PhabricatorEnv::getDoclink('Configuring Inbound Email'),60PlatformSymbols::getPlatformServerName());6162$content[] = '= '.$spec['header'];63$content[] = $spec['summary'];6465$content[] = '= '.pht('Quick Reference');66$content[] = pht(67'This table summarizes the available mail commands. For details on a '.68'specific command, see the command section below.');69$table = array();70$table[] = '| '.pht('Command').' | '.pht('Summary').' |';71$table[] = '|---|---|';72foreach ($commands as $command) {73$summary = $command->getCommandSummary();74$table[] = '| '.$command->getCommandSyntax().' | '.$summary;75}76$table = implode("\n", $table);77$content[] = $table;7879foreach ($commands as $command) {80$content[] = '== !'.$command->getCommand().' ==';81$content[] = $command->getCommandSummary();8283$aliases = $command->getCommandAliases();84if ($aliases) {85foreach ($aliases as $key => $alias) {86$aliases[$key] = '!'.$alias;87}88$aliases = implode(', ', $aliases);89} else {90$aliases = '//None//';91}9293$syntax = $command->getCommandSyntax();9495$table = array();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);102103$content[] = $table;104105$description = $command->getCommandDescription();106if ($description) {107$content[] = $description;108}109}110111$content = implode("\n\n", $content);112113$title = $spec['name'];114115$crumbs = $this->buildApplicationCrumbs();116$this->addApplicationCrumb($crumbs, $selected);117$crumbs->addTextCrumb($title);118$crumbs->setBorder(true);119120$content_box = new PHUIRemarkupView($viewer, $content);121122$info_view = null;123if (!PhabricatorEnv::getEnvConfig('metamta.reply-handler-domain')) {124$error = pht(125"This server 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));130}131132$header = id(new PHUIHeaderView())133->setHeader($title);134135$document = id(new PHUIDocumentView())136->setHeader($header)137->appendChild($info_view)138->appendChild($content_box);139140return $this->newPage()141->setTitle($title)142->setCrumbs($crumbs)143->appendChild($document);144145}146147148}149150151