3 final class PhabricatorAuthMessage
4 extends PhabricatorAuthDAO
6 PhabricatorApplicationTransactionInterface
,
7 PhabricatorPolicyInterface
,
8 PhabricatorDestructibleInterface
{
10 protected $messageKey;
11 protected $messageText;
13 private $messageType = self
::ATTACHABLE
;
15 public static function initializeNewMessage(
16 PhabricatorAuthMessageType
$type) {
19 ->setMessageKey($type->getMessageTypeKey())
20 ->attachMessageType($type);
23 protected function getConfiguration() {
25 self
::CONFIG_AUX_PHID
=> true,
26 self
::CONFIG_COLUMN_SCHEMA
=> array(
27 'messageKey' => 'text64',
28 'messageText' => 'text',
30 self
::CONFIG_KEY_SCHEMA
=> array(
32 'columns' => array('messageKey'),
36 ) + parent
::getConfiguration();
39 public function getPHIDType() {
40 return PhabricatorAuthMessagePHIDType
::TYPECONST
;
43 public function getObjectName() {
44 return pht('Auth Message %d', $this->getID());
47 public function getURI() {
48 return urisprintf('/auth/message/%s/', $this->getID());
51 public function attachMessageType(PhabricatorAuthMessageType
$type) {
52 $this->messageType
= $type;
56 public function getMessageType() {
57 return $this->assertAttached($this->messageType
);
60 public function getMessageTypeDisplayName() {
61 return $this->getMessageType()->getDisplayName();
64 public static function loadMessage(
65 PhabricatorUser
$viewer,
67 return id(new PhabricatorAuthMessageQuery())
69 ->withMessageKeys(array($message_key))
73 public static function loadMessageText(
74 PhabricatorUser
$viewer,
77 $message = self
::loadMessage($viewer, $message_key);
79 $message_text = $message->getMessageText();
80 if (strlen($message_text)) {
85 $message_type = PhabricatorAuthMessageType
::newFromKey($message_key);
87 return $message_type->getDefaultMessageText();
91 /* -( PhabricatorPolicyInterface )----------------------------------------- */
94 public function getCapabilities() {
96 PhabricatorPolicyCapability
::CAN_VIEW
,
97 PhabricatorPolicyCapability
::CAN_EDIT
,
101 public function getPolicy($capability) {
102 switch ($capability) {
103 case PhabricatorPolicyCapability
::CAN_VIEW
:
104 return PhabricatorPolicies
::getMostOpenPolicy();
110 public function hasAutomaticCapability($capability, PhabricatorUser
$viewer) {
111 switch ($capability) {
112 case PhabricatorPolicyCapability
::CAN_VIEW
:
113 // Even if an install doesn't allow public users, you can still view
114 // auth messages: otherwise, we can't do things like show you
115 // guidance on the login screen.
122 /* -( PhabricatorApplicationTransactionInterface )------------------------- */
125 public function getApplicationTransactionEditor() {
126 return new PhabricatorAuthMessageEditor();
129 public function getApplicationTransactionTemplate() {
130 return new PhabricatorAuthMessageTransaction();
134 /* -( PhabricatorDestructibleInterface )----------------------------------- */
137 public function destroyObjectPermanently(
138 PhabricatorDestructionEngine
$engine) {