Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/meta/controller/PhabricatorApplicationDetailViewController.php b/src/applications/meta/controller/PhabricatorApplicationDetailViewController.php
index 443a7e37d3..f86f9eb4d1 100644
--- a/src/applications/meta/controller/PhabricatorApplicationDetailViewController.php
+++ b/src/applications/meta/controller/PhabricatorApplicationDetailViewController.php
@@ -1,211 +1,210 @@
<?php
final class PhabricatorApplicationDetailViewController
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();
}
$title = $selected->getName();
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($selected->getName());
$crumbs->setBorder(true);
$header = id(new PHUIHeaderView())
->setHeader($title)
->setUser($viewer)
->setPolicyObject($selected)
->setHeaderIcon($selected->getIcon());
if ($selected->isInstalled()) {
$header->setStatus('fa-check', 'bluegrey', pht('Installed'));
} else {
$header->setStatus('fa-ban', 'dark', pht('Uninstalled'));
}
$curtain = $this->buildCurtain($selected);
$details = $this->buildPropertySectionView($selected);
$policies = $this->buildPolicyView($selected);
$configs =
PhabricatorApplicationConfigurationPanel::loadAllPanelsForApplication(
$selected);
$panels = array();
foreach ($configs as $config) {
$config->setViewer($viewer);
$config->setApplication($selected);
$panel = $config->buildConfigurationPagePanel();
$panel->setBackground(PHUIObjectBoxView::BLUE_PROPERTY);
$panels[] = $panel;
}
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setCurtain($curtain)
->setMainColumn(array(
$policies,
$panels,
))
->addPropertySection(pht('DETAILS'), $details);
return $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->appendChild(
array(
$view,
));
}
private function buildPropertySectionView(
PhabricatorApplication $application) {
$viewer = $this->getViewer();
$properties = id(new PHUIPropertyListView());
$properties->addProperty(
pht('Description'),
$application->getShortDescription());
if ($application->getFlavorText()) {
$properties->addProperty(
null,
phutil_tag('em', array(), $application->getFlavorText()));
}
if ($application->isPrototype()) {
$proto_href = PhabricatorEnv::getDoclink(
'User Guide: Prototype Applications');
$learn_more = phutil_tag(
'a',
array(
'href' => $proto_href,
'target' => '_blank',
),
pht('Learn More'));
$properties->addProperty(
pht('Prototype'),
pht(
'This application is a prototype. %s',
$learn_more));
}
$overview = $application->getOverview();
if (strlen($overview)) {
$overview = new PHUIRemarkupView($viewer, $overview);
$properties->addSectionHeader(
pht('Overview'), PHUIPropertyListView::ICON_SUMMARY);
$properties->addTextContent($overview);
}
return $properties;
}
private function buildPolicyView(
PhabricatorApplication $application) {
$viewer = $this->getViewer();
- $properties = id(new PHUIPropertyListView())
- ->setStacked(true);
+ $properties = id(new PHUIPropertyListView());
$header = id(new PHUIHeaderView())
->setHeader(pht('POLICIES'))
->setHeaderIcon('fa-lock');
$descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions(
$viewer,
$application);
foreach ($application->getCapabilities() as $capability) {
$properties->addProperty(
$application->getCapabilityLabel($capability),
idx($descriptions, $capability));
}
return id(new PHUIObjectBoxView())
->setHeader($header)
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->appendChild($properties);
}
private function buildCurtain(PhabricatorApplication $application) {
$viewer = $this->getViewer();
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$application,
PhabricatorPolicyCapability::CAN_EDIT);
$key = get_class($application);
$edit_uri = $this->getApplicationURI("edit/{$key}/");
$install_uri = $this->getApplicationURI("{$key}/install/");
$uninstall_uri = $this->getApplicationURI("{$key}/uninstall/");
$curtain = $this->newCurtainView($application);
$curtain->addAction(
id(new PhabricatorActionView())
->setName(pht('Edit Policies'))
->setIcon('fa-pencil')
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit)
->setHref($edit_uri));
if ($application->canUninstall()) {
if ($application->isInstalled()) {
$curtain->addAction(
id(new PhabricatorActionView())
->setName(pht('Uninstall'))
->setIcon('fa-times')
->setDisabled(!$can_edit)
->setWorkflow(true)
->setHref($uninstall_uri));
} else {
$action = id(new PhabricatorActionView())
->setName(pht('Install'))
->setIcon('fa-plus')
->setDisabled(!$can_edit)
->setWorkflow(true)
->setHref($install_uri);
$prototypes_enabled = PhabricatorEnv::getEnvConfig(
'phabricator.show-prototypes');
if ($application->isPrototype() && !$prototypes_enabled) {
$action->setDisabled(true);
}
$curtain->addAction($action);
}
} else {
$curtain->addAction(
id(new PhabricatorActionView())
->setName(pht('Uninstall'))
->setIcon('fa-times')
->setWorkflow(true)
->setDisabled(true)
->setHref($uninstall_uri));
}
return $curtain;
}
}
diff --git a/src/applications/meta/controller/PhabricatorApplicationEditController.php b/src/applications/meta/controller/PhabricatorApplicationEditController.php
index d9d7b3c15c..ed51405db9 100644
--- a/src/applications/meta/controller/PhabricatorApplicationEditController.php
+++ b/src/applications/meta/controller/PhabricatorApplicationEditController.php
@@ -1,192 +1,197 @@
<?php
final class PhabricatorApplicationEditController
extends PhabricatorApplicationsController {
public function handleRequest(AphrontRequest $request) {
$user = $request->getUser();
$application = $request->getURIData('application');
$application = id(new PhabricatorApplicationQuery())
->setViewer($user)
->withClasses(array($application))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$application) {
return new Aphront404Response();
}
$title = $application->getName();
$view_uri = $this->getApplicationURI('view/'.get_class($application).'/');
$policies = id(new PhabricatorPolicyQuery())
->setViewer($user)
->setObject($application)
->execute();
if ($request->isFormPost()) {
$result = array();
foreach ($application->getCapabilities() as $capability) {
$old = $application->getPolicy($capability);
$new = $request->getStr('policy:'.$capability);
if ($old == $new) {
// No change to the setting.
continue;
}
if (empty($policies[$new])) {
// Not a standard policy, check for a custom policy.
$policy = id(new PhabricatorPolicyQuery())
->setViewer($user)
->withPHIDs(array($new))
->executeOne();
if (!$policy) {
// Not a custom policy either. Can't set the policy to something
// invalid, so skip this.
continue;
}
}
if ($new == PhabricatorPolicies::POLICY_PUBLIC) {
$capobj = PhabricatorPolicyCapability::getCapabilityByKey(
$capability);
if (!$capobj || !$capobj->shouldAllowPublicPolicySetting()) {
// Can't set non-public policies to public.
continue;
}
}
$result[$capability] = $new;
}
if ($result) {
$key = 'phabricator.application-settings';
$config_entry = PhabricatorConfigEntry::loadConfigEntry($key);
$value = $config_entry->getValue();
$phid = $application->getPHID();
if (empty($value[$phid])) {
$value[$application->getPHID()] = array();
}
if (empty($value[$phid]['policy'])) {
$value[$phid]['policy'] = array();
}
$value[$phid]['policy'] = $result + $value[$phid]['policy'];
// Don't allow users to make policy edits which would lock them out of
// applications, since they would be unable to undo those actions.
PhabricatorEnv::overrideConfig($key, $value);
PhabricatorPolicyFilter::mustRetainCapability(
$user,
$application,
PhabricatorPolicyCapability::CAN_VIEW);
PhabricatorPolicyFilter::mustRetainCapability(
$user,
$application,
PhabricatorPolicyCapability::CAN_EDIT);
PhabricatorConfigEditor::storeNewValue(
$user,
$config_entry,
$value,
PhabricatorContentSource::newFromRequest($request));
}
return id(new AphrontRedirectResponse())->setURI($view_uri);
}
$descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions(
$user,
$application);
$form = id(new AphrontFormView())
->setUser($user);
$locked_policies = PhabricatorEnv::getEnvConfig('policy.locked');
foreach ($application->getCapabilities() as $capability) {
$label = $application->getCapabilityLabel($capability);
$can_edit = $application->isCapabilityEditable($capability);
$locked = idx($locked_policies, $capability);
$caption = $application->getCapabilityCaption($capability);
if (!$can_edit || $locked) {
$form->appendChild(
id(new AphrontFormStaticControl())
->setLabel($label)
->setValue(idx($descriptions, $capability))
->setCaption($caption));
} else {
$control = id(new AphrontFormPolicyControl())
->setUser($user)
->setDisabled($locked)
->setCapability($capability)
->setPolicyObject($application)
->setPolicies($policies)
->setLabel($label)
->setName('policy:'.$capability)
->setCaption($caption);
$template = $application->getCapabilityTemplatePHIDType($capability);
if ($template) {
$phid_types = PhabricatorPHIDType::getAllTypes();
$phid_type = idx($phid_types, $template);
if ($phid_type) {
$template_object = $phid_type->newObject();
if ($template_object) {
$template_policies = id(new PhabricatorPolicyQuery())
->setViewer($user)
->setObject($template_object)
->execute();
// NOTE: We want to expose both any object template policies
// (like "Subscribers") and any custom policy.
$all_policies = $template_policies + $policies;
$control->setPolicies($all_policies);
$control->setTemplateObject($template_object);
}
}
$control->setTemplatePHIDType($template);
}
$form->appendControl($control);
}
}
$form->appendChild(
id(new AphrontFormSubmitControl())
->setValue(pht('Save Policies'))
->addCancelButton($view_uri));
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($application->getName(), $view_uri);
$crumbs->addTextCrumb(pht('Edit Policies'));
+ $crumbs->setBorder(true);
$header = id(new PHUIHeaderView())
- ->setHeader(pht('Edit Policies: %s', $application->getName()));
+ ->setHeader(pht('Edit Policies: %s', $application->getName()))
+ ->setHeaderIcon('fa-pencil');
$object_box = id(new PHUIObjectBoxView())
- ->setHeader($header)
+ ->setHeaderText(pht('Policies'))
+ ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setForm($form);
- return $this->buildApplicationPage(
- array(
- $crumbs,
+ $view = id(new PHUITwoColumnView())
+ ->setHeader($header)
+ ->setFooter(array(
$object_box,
- ),
- array(
- 'title' => $title,
));
+
+ return $this->newPage()
+ ->setTitle($title)
+ ->setCrumbs($crumbs)
+ ->appendChild($view);
}
}
diff --git a/src/applications/meta/controller/PhabricatorApplicationEmailCommandsController.php b/src/applications/meta/controller/PhabricatorApplicationEmailCommandsController.php
index 08f8e450b5..2979e92229 100644
--- a/src/applications/meta/controller/PhabricatorApplicationEmailCommandsController.php
+++ b/src/applications/meta/controller/PhabricatorApplicationEmailCommandsController.php
@@ -1,152 +1,148 @@
<?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();
$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 '.
'greater range of actions (like claiming a task or requesting changes '.
'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 '.
"`!assign alincoln`.\n\n".
'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:'.
"\n\n```\n!claim\n\nI'll take care of this.\n```\n\n\n".
"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:".
"\n\n```\n!assign alincoln\n!close\n\nI just talked to @alincoln, ".
"and he showed me that he fixed this.\n```\n",
PhabricatorEnv::getDoclink('Configuring Inbound Email'));
$content[] = '= '.$spec['header'];
$content[] = $spec['summary'];
$content[] = '= '.pht('Quick Reference');
$content[] = pht(
'This table summarizes the available mail commands. For details on a '.
'specific command, see the command section below.');
$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);
$title = $spec['name'];
$crumbs = $this->buildApplicationCrumbs();
$this->addApplicationCrumb($crumbs, $selected);
$crumbs->addTextCrumb($title);
$crumbs->setBorder(true);
$content_box = new PHUIRemarkupView($viewer, $content);
$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);
$document = id(new PHUIDocumentViewPro())
->setHeader($header)
->appendChild($info_view)
->appendChild($content_box);
- return $this->buildApplicationPage(
- array(
- $crumbs,
- $document,
- ),
- array(
- 'title' => $title,
- ));
+ return $this->newPage()
+ ->setTitle($title)
+ ->setCrumbs($crumbs)
+ ->appendChild($document);
}
}
diff --git a/src/applications/meta/controller/PhabricatorApplicationPanelController.php b/src/applications/meta/controller/PhabricatorApplicationPanelController.php
index 48355d131f..4fab71c501 100644
--- a/src/applications/meta/controller/PhabricatorApplicationPanelController.php
+++ b/src/applications/meta/controller/PhabricatorApplicationPanelController.php
@@ -1,67 +1,72 @@
<?php
final class PhabricatorApplicationPanelController
extends PhabricatorApplicationsController {
private $application;
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
$application = $request->getURIData('application');
$panel_key = $request->getURIData('panel');
$selected = id(new PhabricatorApplicationQuery())
->setViewer($viewer)
->withClasses(array($application))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$selected) {
return new Aphront404Response();
}
$panels =
PhabricatorApplicationConfigurationPanel::loadAllPanelsForApplication(
$selected);
if (empty($panels[$panel_key])) {
return new Aphront404Response();
}
$panel = $panels[$panel_key];
if (!$panel->shouldShowForApplication($selected)) {
return new Aphront404Response();
}
$panel->setViewer($viewer);
$panel->setApplication($selected);
$this->application = $selected;
return $panel->handlePanelRequest($request, $this);
}
public function buildPanelCrumbs(
PhabricatorApplicationConfigurationPanel $panel) {
$application = $this->application;
$crumbs = $this->buildApplicationCrumbs();
$view_uri = '/applications/view/'.get_class($application).'/';
$crumbs->addTextCrumb($application->getName(), $view_uri);
return $crumbs;
}
public function buildPanelPage(
PhabricatorApplicationConfigurationPanel $panel,
- $content,
- array $options) {
- return $this->buildApplicationPage($content, $options);
+ $title,
+ $crumbs,
+ $content) {
+
+ return $this->newPage()
+ ->setTitle($title)
+ ->setCrumbs($crumbs)
+ ->appendChild($content);
}
}
diff --git a/src/applications/metamta/applicationpanel/PhabricatorMetaMTAApplicationEmailPanel.php b/src/applications/metamta/applicationpanel/PhabricatorMetaMTAApplicationEmailPanel.php
index 1899ac1be1..a2d32e3360 100644
--- a/src/applications/metamta/applicationpanel/PhabricatorMetaMTAApplicationEmailPanel.php
+++ b/src/applications/metamta/applicationpanel/PhabricatorMetaMTAApplicationEmailPanel.php
@@ -1,405 +1,408 @@
<?php
final class PhabricatorMetaMTAApplicationEmailPanel
extends PhabricatorApplicationConfigurationPanel {
public function getPanelKey() {
return 'email';
}
public function shouldShowForApplication(
PhabricatorApplication $application) {
return $application->supportsEmailIntegration();
}
public function buildConfigurationPagePanel() {
$viewer = $this->getViewer();
$application = $this->getApplication();
$table = $this->buildEmailTable($is_edit = false, null);
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$application,
PhabricatorPolicyCapability::CAN_EDIT);
$header = id(new PHUIHeaderView())
->setHeader(pht('Application Emails'))
->addActionLink(
id(new PHUIButtonView())
->setTag('a')
->setText(pht('Edit Application Emails'))
->setIcon('fa-pencil')
->setHref($this->getPanelURI())
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit));
$box = id(new PHUIObjectBoxView())
->setHeader($header)
+ ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setTable($table);
return $box;
}
public function handlePanelRequest(
AphrontRequest $request,
PhabricatorController $controller) {
$viewer = $request->getViewer();
$application = $this->getApplication();
$path = $request->getURIData('path');
if (strlen($path)) {
return new Aphront404Response();
}
$uri = $request->getRequestURI();
$uri->setQueryParams(array());
$new = $request->getStr('new');
$edit = $request->getInt('edit');
$delete = $request->getInt('delete');
if ($new) {
return $this->returnNewAddressResponse($request, $uri, $application);
}
if ($edit) {
return $this->returnEditAddressResponse($request, $uri, $edit);
}
if ($delete) {
return $this->returnDeleteAddressResponse($request, $uri, $delete);
}
$table = $this->buildEmailTable(
$is_edit = true,
$request->getInt('id'));
$form = id(new AphrontFormView())
->setUser($viewer);
$crumbs = $controller->buildPanelCrumbs($this);
$crumbs->addTextCrumb(pht('Edit Application Emails'));
+ $crumbs->setBorder(true);
$header = id(new PHUIHeaderView())
->setHeader(pht('Edit Application Emails: %s', $application->getName()))
- ->setSubheader($application->getAppEmailBlurb());
+ ->setSubheader($application->getAppEmailBlurb())
+ ->setHeaderIcon('fa-pencil');
$icon = id(new PHUIIconView())
->setIcon('fa-plus');
$button = new PHUIButtonView();
$button->setText(pht('Add New Address'));
$button->setTag('a');
$button->setHref($uri->alter('new', 'true'));
$button->setIcon($icon);
$button->addSigil('workflow');
$header->addActionLink($button);
$object_box = id(new PHUIObjectBoxView())
- ->setHeader($header)
+ ->setHeaderText(pht('Emails'))
+ ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setTable($table);
$title = $application->getName();
+ $view = id(new PHUITwoColumnView())
+ ->setHeader($header)
+ ->setFooter($object_box);
return $controller->buildPanelPage(
$this,
- array(
- $crumbs,
- $object_box,
- ),
- array(
- 'title' => $title,
- ));
+ $title,
+ $crumbs,
+ $view);
}
private function returnNewAddressResponse(
AphrontRequest $request,
PhutilURI $uri,
PhabricatorApplication $application) {
$viewer = $request->getUser();
$email_object =
PhabricatorMetaMTAApplicationEmail::initializeNewAppEmail($viewer)
->setApplicationPHID($application->getPHID());
return $this->returnSaveAddressResponse(
$request,
$uri,
$email_object,
$is_new = true);
}
private function returnEditAddressResponse(
AphrontRequest $request,
PhutilURI $uri,
$email_object_id) {
$viewer = $request->getUser();
$email_object = id(new PhabricatorMetaMTAApplicationEmailQuery())
->setViewer($viewer)
->withIDs(array($email_object_id))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$email_object) {
return new Aphront404Response();
}
return $this->returnSaveAddressResponse(
$request,
$uri,
$email_object,
$is_new = false);
}
private function returnSaveAddressResponse(
AphrontRequest $request,
PhutilURI $uri,
PhabricatorMetaMTAApplicationEmail $email_object,
$is_new) {
$viewer = $request->getUser();
$config_default =
PhabricatorMetaMTAApplicationEmail::CONFIG_DEFAULT_AUTHOR;
$e_email = true;
$v_email = $email_object->getAddress();
$e_space = null;
$v_space = $email_object->getSpacePHID();
$v_default = $email_object->getConfigValue($config_default);
$validation_exception = null;
if ($request->isDialogFormPost()) {
$e_email = null;
$v_email = trim($request->getStr('email'));
$v_space = $request->getStr('spacePHID');
$v_default = $request->getArr($config_default);
$v_default = nonempty(head($v_default), null);
$type_address =
PhabricatorMetaMTAApplicationEmailTransaction::TYPE_ADDRESS;
$type_space = PhabricatorTransactions::TYPE_SPACE;
$type_config =
PhabricatorMetaMTAApplicationEmailTransaction::TYPE_CONFIG;
$key_config = PhabricatorMetaMTAApplicationEmailTransaction::KEY_CONFIG;
$xactions = array();
$xactions[] = id(new PhabricatorMetaMTAApplicationEmailTransaction())
->setTransactionType($type_address)
->setNewValue($v_email);
$xactions[] = id(new PhabricatorMetaMTAApplicationEmailTransaction())
->setTransactionType($type_space)
->setNewValue($v_space);
$xactions[] = id(new PhabricatorMetaMTAApplicationEmailTransaction())
->setTransactionType($type_config)
->setMetadataValue($key_config, $config_default)
->setNewValue($v_default);
$editor = id(new PhabricatorMetaMTAApplicationEmailEditor())
->setActor($viewer)
->setContentSourceFromRequest($request)
->setContinueOnNoEffect(true);
try {
$editor->applyTransactions($email_object, $xactions);
return id(new AphrontRedirectResponse())->setURI(
$uri->alter('highlight', $email_object->getID()));
} catch (PhabricatorApplicationTransactionValidationException $ex) {
$validation_exception = $ex;
$e_email = $ex->getShortMessage($type_address);
$e_space = $ex->getShortMessage($type_space);
}
}
if ($v_default) {
$v_default = array($v_default);
} else {
$v_default = array();
}
$form = id(new AphrontFormView())
->setUser($viewer)
->appendChild(
id(new AphrontFormTextControl())
->setLabel(pht('Email'))
->setName('email')
->setValue($v_email)
->setError($e_email));
if (PhabricatorSpacesNamespaceQuery::getViewerSpacesExist($viewer)) {
$form->appendControl(
id(new AphrontFormSelectControl())
->setLabel(pht('Space'))
->setName('spacePHID')
->setValue($v_space)
->setError($e_space)
->setOptions(
PhabricatorSpacesNamespaceQuery::getSpaceOptionsForViewer(
$viewer,
$v_space)));
}
$form
->appendControl(
id(new AphrontFormTokenizerControl())
->setDatasource(new PhabricatorPeopleDatasource())
->setLabel(pht('Default Author'))
->setName($config_default)
->setLimit(1)
->setValue($v_default)
->setCaption(pht(
'Used if the "From:" address does not map to a known account.')));
if ($is_new) {
$title = pht('New Address');
} else {
$title = pht('Edit Address');
}
$dialog = id(new AphrontDialogView())
->setUser($viewer)
->setWidth(AphrontDialogView::WIDTH_FORM)
->setTitle($title)
->setValidationException($validation_exception)
->appendForm($form)
->addSubmitButton(pht('Save'))
->addCancelButton($uri);
if ($is_new) {
$dialog->addHiddenInput('new', 'true');
}
return id(new AphrontDialogResponse())->setDialog($dialog);
}
private function returnDeleteAddressResponse(
AphrontRequest $request,
PhutilURI $uri,
$email_object_id) {
$viewer = $this->getViewer();
$email_object = id(new PhabricatorMetaMTAApplicationEmailQuery())
->setViewer($viewer)
->withIDs(array($email_object_id))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$email_object) {
return new Aphront404Response();
}
if ($request->isDialogFormPost()) {
$engine = new PhabricatorDestructionEngine();
$engine->destroyObject($email_object);
return id(new AphrontRedirectResponse())->setURI($uri);
}
$dialog = id(new AphrontDialogView())
->setUser($viewer)
->addHiddenInput('delete', $email_object_id)
->setTitle(pht('Delete Address'))
->appendParagraph(pht(
'Are you sure you want to delete this email address?'))
->addSubmitButton(pht('Delete'))
->addCancelButton($uri);
return id(new AphrontDialogResponse())->setDialog($dialog);
}
private function buildEmailTable($is_edit, $highlight) {
$viewer = $this->getViewer();
$application = $this->getApplication();
$uri = new PhutilURI($this->getPanelURI());
$emails = id(new PhabricatorMetaMTAApplicationEmailQuery())
->setViewer($viewer)
->withApplicationPHIDs(array($application->getPHID()))
->execute();
$rowc = array();
$rows = array();
foreach ($emails as $email) {
$button_edit = javelin_tag(
'a',
array(
'class' => 'button small grey',
'href' => $uri->alter('edit', $email->getID()),
'sigil' => 'workflow',
),
pht('Edit'));
$button_remove = javelin_tag(
'a',
array(
'class' => 'button small grey',
'href' => $uri->alter('delete', $email->getID()),
'sigil' => 'workflow',
),
pht('Delete'));
if ($highlight == $email->getID()) {
$rowc[] = 'highlighted';
} else {
$rowc[] = null;
}
$space_phid = PhabricatorSpacesNamespaceQuery::getObjectSpacePHID($email);
if ($space_phid) {
$email_space = $viewer->renderHandle($space_phid);
} else {
$email_space = null;
}
$rows[] = array(
$email_space,
$email->getAddress(),
$button_edit,
$button_remove,
);
}
$table = id(new AphrontTableView($rows))
->setNoDataString(pht('No application emails created yet.'));
$table->setHeaders(
array(
pht('Space'),
pht('Email'),
pht('Edit'),
pht('Delete'),
));
$table->setColumnClasses(
array(
'',
'wide',
'action',
'action',
));
$table->setRowClasses($rowc);
$table->setColumnVisibility(
array(
PhabricatorSpacesNamespaceQuery::getViewerSpacesExist($viewer),
true,
$is_edit,
$is_edit,
));
return $table;
}
}

File Metadata

Mime Type
text/x-diff
Expires
Tue, Apr 7, 9:04 AM (1 d, 4 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1166019
Default Alt Text
(33 KB)

Event Timeline