Remove product literal strings in "pht()", part 6
[phabricator.git] / src / applications / countdown / storage / PhabricatorCountdown.php
blob1c61ae7ffc5638a01edbf806df4d540bd08d3954
1 <?php
3 final class PhabricatorCountdown extends PhabricatorCountdownDAO
4 implements
5 PhabricatorPolicyInterface,
6 PhabricatorFlaggableInterface,
7 PhabricatorSubscribableInterface,
8 PhabricatorApplicationTransactionInterface,
9 PhabricatorTokenReceiverInterface,
10 PhabricatorSpacesInterface,
11 PhabricatorProjectInterface,
12 PhabricatorDestructibleInterface,
13 PhabricatorConduitResultInterface {
15 protected $title;
16 protected $authorPHID;
17 protected $epoch;
18 protected $description;
19 protected $viewPolicy;
20 protected $editPolicy;
21 protected $mailKey;
22 protected $spacePHID;
24 public static function initializeNewCountdown(PhabricatorUser $actor) {
25 $app = id(new PhabricatorApplicationQuery())
26 ->setViewer($actor)
27 ->withClasses(array('PhabricatorCountdownApplication'))
28 ->executeOne();
30 $view_policy = $app->getPolicy(
31 PhabricatorCountdownDefaultViewCapability::CAPABILITY);
33 $edit_policy = $app->getPolicy(
34 PhabricatorCountdownDefaultEditCapability::CAPABILITY);
36 return id(new PhabricatorCountdown())
37 ->setAuthorPHID($actor->getPHID())
38 ->setViewPolicy($view_policy)
39 ->setEditPolicy($edit_policy)
40 ->setSpacePHID($actor->getDefaultSpacePHID());
43 protected function getConfiguration() {
44 return array(
45 self::CONFIG_AUX_PHID => true,
46 self::CONFIG_COLUMN_SCHEMA => array(
47 'title' => 'text255',
48 'description' => 'text',
49 'mailKey' => 'bytes20',
51 self::CONFIG_KEY_SCHEMA => array(
52 'key_epoch' => array(
53 'columns' => array('epoch'),
55 'key_author' => array(
56 'columns' => array('authorPHID', 'epoch'),
59 ) + parent::getConfiguration();
62 public function generatePHID() {
63 return PhabricatorPHID::generateNewPHID(
64 PhabricatorCountdownCountdownPHIDType::TYPECONST);
67 public function getMonogram() {
68 return 'C'.$this->getID();
71 public function getURI() {
72 return '/'.$this->getMonogram();
75 public function save() {
76 if (!$this->getMailKey()) {
77 $this->setMailKey(Filesystem::readRandomCharacters(20));
79 return parent::save();
83 /* -( PhabricatorSubscribableInterface )----------------------------------- */
86 public function isAutomaticallySubscribed($phid) {
87 return ($phid == $this->getAuthorPHID());
91 /* -( PhabricatorApplicationTransactionInterface )------------------------- */
94 public function getApplicationTransactionEditor() {
95 return new PhabricatorCountdownEditor();
98 public function getApplicationTransactionTemplate() {
99 return new PhabricatorCountdownTransaction();
103 /* -( PhabricatorTokenReceiverInterface )---------------------------------- */
106 public function getUsersToNotifyOfTokenGiven() {
107 return array($this->getAuthorPHID());
111 /* -( PhabricatorPolicyInterface )----------------------------------------- */
114 public function getCapabilities() {
115 return array(
116 PhabricatorPolicyCapability::CAN_VIEW,
117 PhabricatorPolicyCapability::CAN_EDIT,
121 public function getPolicy($capability) {
122 switch ($capability) {
123 case PhabricatorPolicyCapability::CAN_VIEW:
124 return $this->getViewPolicy();
125 case PhabricatorPolicyCapability::CAN_EDIT:
126 return $this->getEditPolicy();
130 public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
131 return false;
134 /* -( PhabricatorSpacesInterface )------------------------------------------- */
137 public function getSpacePHID() {
138 return $this->spacePHID;
141 /* -( PhabricatorDestructibleInterface )----------------------------------- */
144 public function destroyObjectPermanently(
145 PhabricatorDestructionEngine $engine) {
147 $this->openTransaction();
148 $this->delete();
149 $this->saveTransaction();
152 /* -( PhabricatorConduitResultInterface )---------------------------------- */
155 public function getFieldSpecificationsForConduit() {
156 return array(
157 id(new PhabricatorConduitSearchFieldSpecification())
158 ->setKey('title')
159 ->setType('string')
160 ->setDescription(pht('The title of the countdown.')),
161 id(new PhabricatorConduitSearchFieldSpecification())
162 ->setKey('description')
163 ->setType('remarkup')
164 ->setDescription(pht('The description of the countdown.')),
165 id(new PhabricatorConduitSearchFieldSpecification())
166 ->setKey('epoch')
167 ->setType('epoch')
168 ->setDescription(pht('The end date of the countdown.')),
172 public function getFieldValuesForConduit() {
173 return array(
174 'title' => $this->getTitle(),
175 'description' => array(
176 'raw' => $this->getDescription(),
178 'epoch' => (int)$this->getEpoch(),
182 public function getConduitSearchAttachments() {
183 return array();