phorge/src/applications/meta/controller/PhabricatorApplicationEmailCommandsController.php36e2d02d6ec5master
phorge/src/applications/meta/controller/PhabricatorApplicationEmailCommandsController.php
36e2d02d6ec5master
PhabricatorApplicationEmailCommandsController.php
PhabricatorApplicationEmailCommandsController.php
6f95b325c6b3 | <?php | ||
---|---|---|---|
final class PhabricatorApplicationEmailCommandsController | |||
extends PhabricatorApplicationsController { | |||
public function shouldAllowPublic() { | |||
return true; | |||
} | |||
public function handleRequest(AphrontRequest $request) { | |||
$viewer = $this->getViewer(); | |||
$application = $request->getURIData('application'); | |||
$selected = id(new PhabricatorApplicationQuery()) | |||
->setViewer($viewer) | |||
->withClasses(array($application)) | |||
->executeOne(); | |||
if (!$selected) { | |||
return new Aphront404Response(); | |||
} | |||
$specs = $selected->getMailCommandObjects(); | |||
$type = $request->getURIData('type'); | |||
if (empty($specs[$type])) { | |||
return new Aphront404Response(); | |||
} | |||
$spec = $specs[$type]; | |||
$commands = MetaMTAEmailTransactionCommand::getAllCommandsForObject( | |||
$spec['object']); | |||
$commands = msort($commands, 'getCommand'); | |||
$content = array(); | |||
25f8a37f857d | $content[] = '= '.pht('Mail Commands Overview'); | ||
$content[] = pht( | |||
'After configuring Phabricator to process inbound mail, you can '. | |||
'interact with objects (like tasks and revisions) over email. For '. | |||
'information on configuring Phabricator, see '. | |||
'**[[ %s | Configuring Inbound Email ]]**.'. | |||
"\n\n". | |||
'In most cases, you can reply to email you receive from Phabricator '. | |||
'to leave comments. You can also use **mail commands** to take a '. | |||
36e2d02d6ec5 | 'greater range of actions (like claiming a task or requesting changes '. | ||
25f8a37f857d | 'to a revision) without needing to log in to the web UI.'. | ||
"\n\n". | |||
'Mail commands are keywords which start with an exclamation point, '. | |||
'like `!claim`. Some commands may take parameters, like '. | |||
36e2d02d6ec5 | "`!assign alincoln`.\n\n". | ||
25f8a37f857d | 'To use mail commands, write one command per line at the beginning '. | ||
'or end of your mail message. For example, you could write this in a '. | |||
'reply to task email to claim the task:'. | |||
36e2d02d6ec5 | "\n\n```\n!claim\n\nI'll take care of this.\n```\n\n\n". | ||
25f8a37f857d | "When Phabricator receives your mail, it will process any commands ". | ||
"first, then post the remaining message body as a comment. You can ". | |||
"execute multiple commands at once:". | |||
36e2d02d6ec5 | "\n\n```\n!assign alincoln\n!close\n\nI just talked to @alincoln, ". | ||
"and he showed me that he fixed this.\n```\n", | |||
25f8a37f857d | PhabricatorEnv::getDoclink('Configuring Inbound Email')); | ||
$content[] = '= '.$spec['header']; | |||
$content[] = $spec['summary']; | |||
6f95b325c6b3 | $content[] = '= '.pht('Quick Reference'); | ||
25f8a37f857d | $content[] = pht( | ||
'This table summarizes the available mail commands. For details on a '. | |||
'specific command, see the command section below.'); | |||
6f95b325c6b3 | $table = array(); | ||
$table[] = '| '.pht('Command').' | '.pht('Summary').' |'; | |||
$table[] = '|---|---|'; | |||
foreach ($commands as $command) { | |||
$summary = $command->getCommandSummary(); | |||
$table[] = '| '.$command->getCommandSyntax().' | '.$summary; | |||
} | |||
$table = implode("\n", $table); | |||
$content[] = $table; | |||
foreach ($commands as $command) { | |||
$content[] = '== !'.$command->getCommand().' =='; | |||
$content[] = $command->getCommandSummary(); | |||
$aliases = $command->getCommandAliases(); | |||
if ($aliases) { | |||
foreach ($aliases as $key => $alias) { | |||
$aliases[$key] = '!'.$alias; | |||
} | |||
$aliases = implode(', ', $aliases); | |||
} else { | |||
$aliases = '//None//'; | |||
} | |||
$syntax = $command->getCommandSyntax(); | |||
$table = array(); | |||
$table[] = '| '.pht('Property').' | '.pht('Value'); | |||
$table[] = '|---|---|'; | |||
$table[] = '| **'.pht('Syntax').'** | '.$syntax; | |||
$table[] = '| **'.pht('Aliases').'** | '.$aliases; | |||
$table[] = '| **'.pht('Class').'** | `'.get_class($command).'`'; | |||
$table = implode("\n", $table); | |||
$content[] = $table; | |||
$description = $command->getCommandDescription(); | |||
if ($description) { | |||
$content[] = $description; | |||
} | |||
} | |||
$content = implode("\n\n", $content); | |||
c169199e6429 | $title = $spec['name']; | ||
6f95b325c6b3 | $crumbs = $this->buildApplicationCrumbs(); | ||
$this->addApplicationCrumb($crumbs, $selected); | |||
c169199e6429 | $crumbs->addTextCrumb($title); | ||
6f95b325c6b3 | |||
25f8a37f857d | $content_box = PhabricatorMarkupEngine::renderOneObject( | ||
id(new PhabricatorMarkupOneOff())->setContent($content), | |||
'default', | |||
$viewer); | |||
$info_view = null; | |||
if (!PhabricatorEnv::getEnvConfig('metamta.reply-handler-domain')) { | |||
$error = pht( | |||
"Phabricator is not currently configured to accept inbound mail. ". | |||
"You won't be able to interact with objects over email until ". | |||
"inbound mail is set up."); | |||
$info_view = id(new PHUIInfoView()) | |||
->setErrors(array($error)); | |||
} | |||
$header = id(new PHUIHeaderView()) | |||
->setHeader($title); | |||
6f95b325c6b3 | |||
25f8a37f857d | $document = id(new PHUIDocumentView()) | ||
->setHeader($header) | |||
->setFontKit(PHUIDocumentView::FONT_SOURCE_SANS) | |||
->appendChild($info_view) | |||
6f95b325c6b3 | ->appendChild($content_box); | ||
return $this->buildApplicationPage( | |||
array( | |||
$crumbs, | |||
25f8a37f857d | $document, | ||
6f95b325c6b3 | ), | ||
array( | |||
c169199e6429 | 'title' => $title, | ||
6f95b325c6b3 | )); | ||
} | |||
} |
Owner Packages
Owner Packages
- No Owners