Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/auth/controller/message/PhabricatorAuthMessageViewController.php b/src/applications/auth/controller/message/PhabricatorAuthMessageViewController.php
index fab5dcafb0..5665744463 100644
--- a/src/applications/auth/controller/message/PhabricatorAuthMessageViewController.php
+++ b/src/applications/auth/controller/message/PhabricatorAuthMessageViewController.php
@@ -1,155 +1,170 @@
<?php
final class PhabricatorAuthMessageViewController
extends PhabricatorAuthMessageController {
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
$this->requireApplicationCapability(
AuthManageProvidersCapability::CAPABILITY);
// 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->getMessageType()->getDisplayName())
->setBorder(true);
$header = $this->buildHeaderView($message);
$properties = $this->buildPropertiesView($message);
$curtain = $this->buildCurtain($message);
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();
+ $message_type = $message->getMessageType();
+
$view = id(new PHUIPropertyListView())
->setViewer($viewer);
- $view->addProperty(
- pht('Description'),
- $message->getMessageType()->getShortDescription());
+ $full_description = $message_type->getFullDescription();
+ if (strlen($full_description)) {
+ $view->addTextContent(new PHUIRemarkupView($viewer, $full_description));
+ } else {
+ $short_description = $message_type->getShortDescription();
+ $view->addProperty(pht('Description'), $short_description);
+ }
- if (strlen($message->getMessageText())) {
+ $message_text = $message->getMessageText();
+ if (strlen($message_text)) {
$view->addSectionHeader(
pht('Message Preview'),
PHUIPropertyListView::ICON_SUMMARY);
- $view->addTextContent(
- new PHUIRemarkupView($viewer, $message->getMessageText()));
+ $view->addTextContent(new PHUIRemarkupView($viewer, $message_text));
+ }
+
+ $default_text = $message_type->getDefaultMessageText();
+ if (strlen($default_text)) {
+ $view->addSectionHeader(
+ pht('Default Message'),
+ PHUIPropertyListView::ICON_SUMMARY);
+
+ $view->addTextContent(new PHUIRemarkupView($viewer, $default_text));
}
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($edit_name)
->setIcon('fa-pencil')
->setHref($edit_uri)
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit));
return $curtain;
}
}
diff --git a/src/applications/auth/message/PhabricatorAuthEmailLoginMessageType.php b/src/applications/auth/message/PhabricatorAuthEmailLoginMessageType.php
index a866dfa9e2..0bb55a7461 100644
--- a/src/applications/auth/message/PhabricatorAuthEmailLoginMessageType.php
+++ b/src/applications/auth/message/PhabricatorAuthEmailLoginMessageType.php
@@ -1,18 +1,41 @@
<?php
final class PhabricatorAuthEmailLoginMessageType
extends PhabricatorAuthMessageType {
const MESSAGEKEY = 'mail.login';
public function getDisplayName() {
return pht('Mail Body: Email Login');
}
public function getShortDescription() {
return pht(
'Guidance in the message body when users request an email link '.
'to access their account.');
}
+ public function getFullDescription() {
+ return pht(
+ 'Guidance included in the mail message body when users request an '.
+ 'email link to access their account.'.
+ "\n\n".
+ 'For installs with password authentication enabled, users access this '.
+ 'workflow by using the "Forgot your password?" link on the login '.
+ 'screen.'.
+ "\n\n".
+ 'For installs without password authentication enabled, users access '.
+ 'this workflow by using the "Send a login link to your email address." '.
+ 'link on the login screen. This workflow allows users to recover '.
+ 'access to their account if there is an issue with an external '.
+ 'login service.');
+ }
+
+ public function getDefaultMessageText() {
+ return pht(
+ 'You (or someone pretending to be you) recently requested an account '.
+ 'recovery link be sent to this email address. If you did not make '.
+ 'this request, you can ignore this message.');
+ }
+
}
diff --git a/src/applications/auth/message/PhabricatorAuthMessageType.php b/src/applications/auth/message/PhabricatorAuthMessageType.php
index f883cb4146..9474eee1f3 100644
--- a/src/applications/auth/message/PhabricatorAuthMessageType.php
+++ b/src/applications/auth/message/PhabricatorAuthMessageType.php
@@ -1,33 +1,41 @@
<?php
abstract class PhabricatorAuthMessageType
extends Phobject {
final public function getMessageTypeKey() {
return $this->getPhobjectClassConstant('MESSAGEKEY', 64);
}
final public static function getAllMessageTypes() {
return id(new PhutilClassMapQuery())
->setAncestorClass(__CLASS__)
->setUniqueMethod('getMessageTypeKey')
->execute();
}
final public static function newFromKey($key) {
$types = self::getAllMessageTypes();
if (empty($types[$key])) {
throw new Exception(
pht(
'No message type exists with key "%s".',
$key));
}
return clone $types[$key];
}
abstract public function getDisplayName();
abstract public function getShortDescription();
+ public function getFullDescription() {
+ return null;
+ }
+
+ public function getDefaultMessageText() {
+ return null;
+ }
+
}
diff --git a/src/applications/auth/storage/PhabricatorAuthMessage.php b/src/applications/auth/storage/PhabricatorAuthMessage.php
index f12550e440..9969d7aded 100644
--- a/src/applications/auth/storage/PhabricatorAuthMessage.php
+++ b/src/applications/auth/storage/PhabricatorAuthMessage.php
@@ -1,138 +1,142 @@
<?php
final class PhabricatorAuthMessage
extends PhabricatorAuthDAO
implements
PhabricatorApplicationTransactionInterface,
PhabricatorPolicyInterface,
PhabricatorDestructibleInterface {
protected $messageKey;
protected $messageText;
private $messageType = self::ATTACHABLE;
public static function initializeNewMessage(
PhabricatorAuthMessageType $type) {
return id(new self())
->setMessageKey($type->getMessageTypeKey())
->attachMessageType($type);
}
protected function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
self::CONFIG_COLUMN_SCHEMA => array(
'messageKey' => 'text64',
'messageText' => 'text',
),
self::CONFIG_KEY_SCHEMA => array(
'key_type' => array(
'columns' => array('messageKey'),
'unique' => true,
),
),
) + parent::getConfiguration();
}
public function getPHIDType() {
return PhabricatorAuthMessagePHIDType::TYPECONST;
}
public function getObjectName() {
return pht('Auth Message %d', $this->getID());
}
public function getURI() {
return urisprintf('/auth/message/%s/', $this->getID());
}
public function attachMessageType(PhabricatorAuthMessageType $type) {
$this->messageType = $type;
return $this;
}
public function getMessageType() {
return $this->assertAttached($this->messageType);
}
public function getMessageTypeDisplayName() {
return $this->getMessageType()->getDisplayName();
}
public static function loadMessage(
PhabricatorUser $viewer,
$message_key) {
return id(new PhabricatorAuthMessageQuery())
->setViewer($viewer)
->withMessageKeys(array($message_key))
->executeOne();
}
public static function loadMessageText(
PhabricatorUser $viewer,
$message_key) {
$message = self::loadMessage($viewer, $message_key);
-
- if (!$message) {
- return null;
+ if ($message) {
+ $message_text = $message->getMessageText();
+ if (strlen($message_text)) {
+ return $message_text;
+ }
}
- return $message->getMessageText();
+ $message_type = PhabricatorAuthMessageType::newFromKey($message_key);
+
+ return $message_type->getDefaultMessageText();
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */
public function getCapabilities() {
return array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
);
}
public function getPolicy($capability) {
switch ($capability) {
case PhabricatorPolicyCapability::CAN_VIEW:
return PhabricatorPolicies::getMostOpenPolicy();
default:
return false;
}
}
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
switch ($capability) {
case PhabricatorPolicyCapability::CAN_VIEW:
// Even if an install doesn't allow public users, you can still view
// auth messages: otherwise, we can't do things like show you
// guidance on the login screen.
return true;
default:
return false;
}
}
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
public function getApplicationTransactionEditor() {
return new PhabricatorAuthMessageEditor();
}
public function getApplicationTransactionTemplate() {
return new PhabricatorAuthMessageTransaction();
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */
public function destroyObjectPermanently(
PhabricatorDestructionEngine $engine) {
$this->delete();
}
}
diff --git a/src/applications/people/mail/PhabricatorPeopleMailEngine.php b/src/applications/people/mail/PhabricatorPeopleMailEngine.php
index b2f022bcdf..c1379dda9e 100644
--- a/src/applications/people/mail/PhabricatorPeopleMailEngine.php
+++ b/src/applications/people/mail/PhabricatorPeopleMailEngine.php
@@ -1,96 +1,99 @@
<?php
abstract class PhabricatorPeopleMailEngine
extends Phobject {
private $sender;
private $recipient;
private $recipientAddress;
final public function setSender(PhabricatorUser $sender) {
$this->sender = $sender;
return $this;
}
final public function getSender() {
if (!$this->sender) {
throw new PhutilInvalidStateException('setSender');
}
return $this->sender;
}
final public function setRecipient(PhabricatorUser $recipient) {
$this->recipient = $recipient;
return $this;
}
final public function getRecipient() {
if (!$this->recipient) {
throw new PhutilInvalidStateException('setRecipient');
}
return $this->recipient;
}
final public function setRecipientAddress(PhutilEmailAddress $address) {
$this->recipientAddress = $address;
return $this;
}
final public function getRecipientAddress() {
if (!$this->recipientAddress) {
throw new PhutilInvalidStateException('recipientAddress');
}
return $this->recipientAddress;
}
final public function hasRecipientAddress() {
return ($this->recipientAddress !== null);
}
final public function canSendMail() {
try {
$this->validateMail();
return true;
} catch (PhabricatorPeopleMailEngineException $ex) {
return false;
}
}
final public function sendMail() {
$this->validateMail();
$mail = $this->newMail();
if ($this->hasRecipientAddress()) {
$recipient_address = $this->getRecipientAddress();
$mail->addRawTos(array($recipient_address->getAddress()));
} else {
$recipient = $this->getRecipient();
$mail->addTos(array($recipient->getPHID()));
}
$mail
->setForceDelivery(true)
->save();
return $mail;
}
abstract public function validateMail();
abstract protected function newMail();
final protected function throwValidationException($title, $body) {
throw new PhabricatorPeopleMailEngineException($title, $body);
}
final protected function newRemarkupText($text) {
$recipient = $this->getRecipient();
$engine = PhabricatorMarkupEngine::newMarkupEngine(array())
->setConfig('viewer', $recipient)
->setConfig('uri.base', PhabricatorEnv::getProductionURI('/'))
->setMode(PhutilRemarkupEngine::MODE_TEXT);
- return $engine->markupText($text);
+ $rendered_text = $engine->markupText($text);
+ $rendered_text = rtrim($rendered_text, "\n");
+
+ return $rendered_text;
}
}

File Metadata

Mime Type
text/x-diff
Expires
Wed, Jul 2, 10:07 AM (1 d, 17 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
164848
Default Alt Text
(15 KB)

Event Timeline