Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/auth/application/PhabricatorAuthApplication.php b/src/applications/auth/application/PhabricatorAuthApplication.php
index 3446ad597d..6d4a70b735 100644
--- a/src/applications/auth/application/PhabricatorAuthApplication.php
+++ b/src/applications/auth/application/PhabricatorAuthApplication.php
@@ -1,158 +1,158 @@
<?php
final class PhabricatorAuthApplication extends PhabricatorApplication {
public function canUninstall() {
return false;
}
public function getBaseURI() {
return '/auth/';
}
public function getIcon() {
return 'fa-key';
}
public function isPinnedByDefault(PhabricatorUser $viewer) {
return $viewer->getIsAdmin();
}
public function getName() {
return pht('Auth');
}
public function getShortDescription() {
return pht('Login/Registration');
}
public function getHelpDocumentationArticles(PhabricatorUser $viewer) {
// NOTE: Although reasonable help exists for this in "Configuring Accounts
// and Registration", specifying help items here means we get the menu
// item in all the login/link interfaces, which is confusing and not
// helpful.
// TODO: Special case this, or split the auth and auth administration
// applications?
return array();
}
public function getApplicationGroup() {
return self::GROUP_ADMIN;
}
public function getRoutes() {
return array(
'/auth/' => array(
'' => 'PhabricatorAuthListController',
'config/' => array(
'new/' => 'PhabricatorAuthNewController',
'edit/(?:(?P<id>\d+)/)?' => 'PhabricatorAuthEditController',
'(?P<action>enable|disable)/(?P<id>\d+)/'
=> 'PhabricatorAuthDisableController',
'view/(?P<id>\d+)/' => 'PhabricatorAuthProviderViewController',
),
'login/(?P<pkey>[^/]+)/(?:(?P<extra>[^/]+)/)?'
=> 'PhabricatorAuthLoginController',
'(?P<loggedout>loggedout)/' => 'PhabricatorAuthStartController',
'invite/(?P<code>[^/]+)/' => 'PhabricatorAuthInviteController',
'register/(?:(?P<akey>[^/]+)/)?' => 'PhabricatorAuthRegisterController',
'start/' => 'PhabricatorAuthStartController',
'validate/' => 'PhabricatorAuthValidateController',
'finish/' => 'PhabricatorAuthFinishController',
'unlink/(?P<id>\d+)/' => 'PhabricatorAuthUnlinkController',
'(?P<action>link|refresh)/(?P<id>\d+)/'
=> 'PhabricatorAuthLinkController',
'confirmlink/(?P<akey>[^/]+)/'
=> 'PhabricatorAuthConfirmLinkController',
'session/terminate/(?P<id>[^/]+)/'
=> 'PhabricatorAuthTerminateSessionController',
'token/revoke/(?P<id>[^/]+)/'
=> 'PhabricatorAuthRevokeTokenController',
'session/downgrade/'
=> 'PhabricatorAuthDowngradeSessionController',
'enroll/' => array(
'(?:(?P<pageKey>[^/]+)/)?(?:(?P<formSaved>saved)/)?'
=> 'PhabricatorAuthNeedsMultiFactorController',
),
'sshkey/' => array(
$this->getQueryRoutePattern('for/(?P<forPHID>[^/]+)/')
=> 'PhabricatorAuthSSHKeyListController',
'generate/' => 'PhabricatorAuthSSHKeyGenerateController',
'upload/' => 'PhabricatorAuthSSHKeyEditController',
'edit/(?P<id>\d+)/' => 'PhabricatorAuthSSHKeyEditController',
'revoke/(?P<id>\d+)/'
=> 'PhabricatorAuthSSHKeyRevokeController',
'view/(?P<id>\d+)/' => 'PhabricatorAuthSSHKeyViewController',
),
'password/' => 'PhabricatorAuthSetPasswordController',
'external/' => 'PhabricatorAuthSetExternalController',
'mfa/' => array(
$this->getQueryRoutePattern() =>
'PhabricatorAuthFactorProviderListController',
$this->getEditRoutePattern('edit/') =>
'PhabricatorAuthFactorProviderEditController',
'(?P<id>[1-9]\d*)/' =>
'PhabricatorAuthFactorProviderViewController',
'message/(?P<id>[1-9]\d*)/' =>
'PhabricatorAuthFactorProviderMessageController',
'challenge/status/(?P<id>[1-9]\d*)/' =>
'PhabricatorAuthChallengeStatusController',
),
'message/' => array(
$this->getQueryRoutePattern() =>
'PhabricatorAuthMessageListController',
$this->getEditRoutePattern('edit/') =>
'PhabricatorAuthMessageEditController',
- '(?P<id>[1-9]\d*)/' =>
+ '(?P<id>[^/]+)/' =>
'PhabricatorAuthMessageViewController',
),
'contact/' => array(
$this->getEditRoutePattern('edit/') =>
'PhabricatorAuthContactNumberEditController',
'(?P<id>[1-9]\d*)/' =>
'PhabricatorAuthContactNumberViewController',
'(?P<action>disable|enable)/(?P<id>[1-9]\d*)/' =>
'PhabricatorAuthContactNumberDisableController',
'primary/(?P<id>[1-9]\d*)/' =>
'PhabricatorAuthContactNumberPrimaryController',
'test/(?P<id>[1-9]\d*)/' =>
'PhabricatorAuthContactNumberTestController',
),
),
'/oauth/(?P<provider>\w+)/login/'
=> 'PhabricatorAuthOldOAuthRedirectController',
'/login/' => array(
'' => 'PhabricatorAuthStartController',
'email/' => 'PhabricatorEmailLoginController',
'once/'.
'(?P<type>[^/]+)/'.
'(?P<id>\d+)/'.
'(?P<key>[^/]+)/'.
'(?:(?P<emailID>\d+)/)?' => 'PhabricatorAuthOneTimeLoginController',
'refresh/' => 'PhabricatorRefreshCSRFController',
'mustverify/' => 'PhabricatorMustVerifyEmailController',
),
'/emailverify/(?P<code>[^/]+)/'
=> 'PhabricatorEmailVerificationController',
'/logout/' => 'PhabricatorLogoutController',
);
}
protected function getCustomCapabilities() {
return array(
AuthManageProvidersCapability::CAPABILITY => array(
'default' => PhabricatorPolicies::POLICY_ADMIN,
),
);
}
}
diff --git a/src/applications/auth/controller/message/PhabricatorAuthMessageListController.php b/src/applications/auth/controller/message/PhabricatorAuthMessageListController.php
index a3c518ab36..7981a03f16 100644
--- a/src/applications/auth/controller/message/PhabricatorAuthMessageListController.php
+++ b/src/applications/auth/controller/message/PhabricatorAuthMessageListController.php
@@ -1,77 +1,80 @@
<?php
final class PhabricatorAuthMessageListController
extends PhabricatorAuthProviderController {
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
$can_manage = $this->hasApplicationCapability(
AuthManageProvidersCapability::CAPABILITY);
$types = PhabricatorAuthMessageType::getAllMessageTypes();
$messages = id(new PhabricatorAuthMessageQuery())
->setViewer($viewer)
->execute();
$messages = mpull($messages, null, 'getMessageKey');
$list = new PHUIObjectItemListView();
foreach ($types as $type) {
$message = idx($messages, $type->getMessageTypeKey());
+
if ($message) {
$href = $message->getURI();
$name = $message->getMessageTypeDisplayName();
} else {
- $href = '/auth/message/edit/?messageKey='.$type->getMessageTypeKey();
+ $href = urisprintf(
+ '/auth/message/%s/',
+ $type->getMessageTypeKey());
$name = $type->getDisplayName();
}
$item = id(new PHUIObjectItemView())
->setHeader($name)
->setHref($href)
->addAttribute($type->getShortDescription());
if ($message) {
$item->addIcon('fa-circle', pht('Customized'));
} else {
$item->addIcon('fa-circle-o grey', pht('Default'));
}
$list->addItem($item);
}
$crumbs = $this->buildApplicationCrumbs()
->addTextCrumb(pht('Messages'))
->setBorder(true);
$list->setFlush(true);
$list = id(new PHUIObjectBoxView())
->setHeaderText(pht('Auth Messages'))
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->appendChild($list);
$title = pht('Auth Messages');
$header = id(new PHUIHeaderView())
->setHeader($title)
->setHeaderIcon('fa-commenting-o');
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setFooter(
array(
$list,
));
$nav = $this->newNavigation()
->setCrumbs($crumbs)
->appendChild($view);
$nav->selectFilter('message');
return $this->newPage()
->setTitle($title)
->appendChild($nav);
}
}
diff --git a/src/applications/auth/controller/message/PhabricatorAuthMessageViewController.php b/src/applications/auth/controller/message/PhabricatorAuthMessageViewController.php
index db7e7e65e0..fab5dcafb0 100644
--- a/src/applications/auth/controller/message/PhabricatorAuthMessageViewController.php
+++ b/src/applications/auth/controller/message/PhabricatorAuthMessageViewController.php
@@ -1,104 +1,155 @@
<?php
final class PhabricatorAuthMessageViewController
extends PhabricatorAuthMessageController {
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
$this->requireApplicationCapability(
AuthManageProvidersCapability::CAPABILITY);
- $message = id(new PhabricatorAuthMessageQuery())
- ->setViewer($viewer)
- ->withIDs(array($request->getURIData('id')))
- ->executeOne();
- if (!$message) {
- return new Aphront404Response();
+ // The "id" in the URI may either be an actual storage record ID (if a
+ // message has already been created) or a message type key (for a message
+ // type which does not have a record yet).
+
+ // This flow allows messages which have not been set yet to have a detail
+ // page (so users can get detailed information about the message and see
+ // any default value).
+
+ $id = $request->getURIData('id');
+ if (ctype_digit($id)) {
+ $message = id(new PhabricatorAuthMessageQuery())
+ ->setViewer($viewer)
+ ->withIDs(array($id))
+ ->executeOne();
+ if (!$message) {
+ return new Aphront404Response();
+ }
+ } else {
+ $types = PhabricatorAuthMessageType::getAllMessageTypes();
+ if (!isset($types[$id])) {
+ return new Aphront404Response();
+ }
+
+ // If this message type already has a storage record, redirect to the
+ // canonical page for the record.
+ $message = id(new PhabricatorAuthMessageQuery())
+ ->setViewer($viewer)
+ ->withMessageKeys(array($id))
+ ->executeOne();
+ if ($message) {
+ $message_uri = $message->getURI();
+ return id(new AphrontRedirectResponse())->setURI($message_uri);
+ }
+
+ // Otherwise, create an empty placeholder message object with the
+ // appropriate message type.
+ $message = PhabricatorAuthMessage::initializeNewMessage($types[$id]);
}
$crumbs = $this->buildApplicationCrumbs()
- ->addTextCrumb($message->getObjectName())
+ ->addTextCrumb($message->getMessageType()->getDisplayName())
->setBorder(true);
$header = $this->buildHeaderView($message);
$properties = $this->buildPropertiesView($message);
$curtain = $this->buildCurtain($message);
- $timeline = $this->buildTransactionTimeline(
- $message,
- new PhabricatorAuthMessageTransactionQuery());
- $timeline->setShouldTerminate(true);
+ if ($message->getID()) {
+ $timeline = $this->buildTransactionTimeline(
+ $message,
+ new PhabricatorAuthMessageTransactionQuery());
+ $timeline->setShouldTerminate(true);
+ } else {
+ $timeline = null;
+ }
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setCurtain($curtain)
->setMainColumn(
array(
$timeline,
))
->addPropertySection(pht('Details'), $properties);
return $this->newPage()
->setTitle($message->getMessageTypeDisplayName())
->setCrumbs($crumbs)
->setPageObjectPHIDs(
array(
$message->getPHID(),
))
->appendChild($view);
}
private function buildHeaderView(PhabricatorAuthMessage $message) {
$viewer = $this->getViewer();
$view = id(new PHUIHeaderView())
->setViewer($viewer)
->setHeader($message->getMessageTypeDisplayName());
return $view;
}
private function buildPropertiesView(PhabricatorAuthMessage $message) {
$viewer = $this->getViewer();
$view = id(new PHUIPropertyListView())
->setViewer($viewer);
$view->addProperty(
pht('Description'),
$message->getMessageType()->getShortDescription());
- $view->addSectionHeader(
- pht('Message Preview'),
- PHUIPropertyListView::ICON_SUMMARY);
+ if (strlen($message->getMessageText())) {
+ $view->addSectionHeader(
+ pht('Message Preview'),
+ PHUIPropertyListView::ICON_SUMMARY);
- $view->addTextContent(
- new PHUIRemarkupView($viewer, $message->getMessageText()));
+ $view->addTextContent(
+ new PHUIRemarkupView($viewer, $message->getMessageText()));
+ }
return $view;
}
private function buildCurtain(PhabricatorAuthMessage $message) {
$viewer = $this->getViewer();
$id = $message->getID();
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$message,
PhabricatorPolicyCapability::CAN_EDIT);
+ if ($id) {
+ $edit_uri = urisprintf('message/edit/%s/', $id);
+ $edit_name = pht('Edit Message');
+ } else {
+ $edit_uri = urisprintf('message/edit/');
+ $params = array(
+ 'messageKey' => $message->getMessageKey(),
+ );
+ $edit_uri = new PhutilURI($edit_uri, $params);
+
+ $edit_name = pht('Customize Message');
+ }
+ $edit_uri = $this->getApplicationURI($edit_uri);
+
$curtain = $this->newCurtainView($message);
$curtain->addAction(
id(new PhabricatorActionView())
- ->setName(pht('Edit Message'))
+ ->setName($edit_name)
->setIcon('fa-pencil')
- ->setHref($this->getApplicationURI("message/edit/{$id}/"))
+ ->setHref($edit_uri)
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit));
return $curtain;
}
}

File Metadata

Mime Type
text/x-diff
Expires
Wed, Jul 2, 3:22 PM (1 d, 4 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
164998
Default Alt Text
(14 KB)

Event Timeline