[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorCountdown 4 extends PhabricatorCountdownDAO 5 implements PhabricatorPolicyInterface { 6 7 protected $title; 8 protected $authorPHID; 9 protected $epoch; 10 protected $viewPolicy; 11 12 public static function initializeNewCountdown(PhabricatorUser $actor) { 13 $app = id(new PhabricatorApplicationQuery()) 14 ->setViewer($actor) 15 ->withClasses(array('PhabricatorCountdownApplication')) 16 ->executeOne(); 17 18 $view_policy = $app->getPolicy( 19 PhabricatorCountdownDefaultViewCapability::CAPABILITY); 20 21 return id(new PhabricatorCountdown()) 22 ->setAuthorPHID($actor->getPHID()) 23 ->setViewPolicy($view_policy) 24 ->setEpoch(PhabricatorTime::getNow()); 25 } 26 27 public function getConfiguration() { 28 return array( 29 self::CONFIG_AUX_PHID => true, 30 self::CONFIG_COLUMN_SCHEMA => array( 31 'title' => 'text255', 32 ), 33 ) + parent::getConfiguration(); 34 } 35 36 public function generatePHID() { 37 return PhabricatorPHID::generateNewPHID( 38 PhabricatorCountdownCountdownPHIDType::TYPECONST); 39 } 40 41 42 /* -( PhabricatorPolicyInterface )----------------------------------------- */ 43 44 45 public function getCapabilities() { 46 return array( 47 PhabricatorPolicyCapability::CAN_VIEW, 48 PhabricatorPolicyCapability::CAN_EDIT, 49 ); 50 } 51 52 public function getPolicy($capability) { 53 switch ($capability) { 54 case PhabricatorPolicyCapability::CAN_VIEW: 55 return $this->getViewPolicy(); 56 case PhabricatorPolicyCapability::CAN_EDIT: 57 return PhabricatorPolicies::POLICY_NOONE; 58 } 59 } 60 61 public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { 62 return ($viewer->getPHID() == $this->getAuthorPHID()); 63 } 64 65 public function describeAutomaticCapability($capability) { 66 return pht('The author of a countdown can always view and edit it.'); 67 } 68 69 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |