Changeset View
Changeset View
Standalone View
Standalone View
src/applications/owners/storage/PhabricatorOwnersPackage.php
| <?php | <?php | ||||
| final class PhabricatorOwnersPackage | final class PhabricatorOwnersPackage | ||||
| extends PhabricatorOwnersDAO | extends PhabricatorOwnersDAO | ||||
| implements | implements | ||||
| PhabricatorPolicyInterface, | PhabricatorPolicyInterface, | ||||
| PhabricatorApplicationTransactionInterface, | PhabricatorApplicationTransactionInterface, | ||||
| PhabricatorCustomFieldInterface, | PhabricatorCustomFieldInterface, | ||||
| PhabricatorDestructibleInterface, | PhabricatorDestructibleInterface, | ||||
| PhabricatorConduitResultInterface, | PhabricatorConduitResultInterface, | ||||
| PhabricatorFulltextInterface, | PhabricatorFulltextInterface, | ||||
| PhabricatorNgramsInterface { | PhabricatorNgramsInterface { | ||||
| protected $name; | protected $name; | ||||
| protected $originalName; | protected $originalName; | ||||
| protected $auditingEnabled; | protected $auditingEnabled; | ||||
| protected $autoReview; | |||||
| protected $description; | protected $description; | ||||
| protected $primaryOwnerPHID; | protected $primaryOwnerPHID; | ||||
| protected $mailKey; | protected $mailKey; | ||||
| protected $status; | protected $status; | ||||
| protected $viewPolicy; | protected $viewPolicy; | ||||
| protected $editPolicy; | protected $editPolicy; | ||||
| private $paths = self::ATTACHABLE; | private $paths = self::ATTACHABLE; | ||||
| private $owners = self::ATTACHABLE; | private $owners = self::ATTACHABLE; | ||||
| private $customFields = self::ATTACHABLE; | private $customFields = self::ATTACHABLE; | ||||
| const STATUS_ACTIVE = 'active'; | const STATUS_ACTIVE = 'active'; | ||||
| const STATUS_ARCHIVED = 'archived'; | const STATUS_ARCHIVED = 'archived'; | ||||
| const AUTOREVIEW_NONE = 'none'; | |||||
| const AUTOREVIEW_SUBSCRIBE = 'subscribe'; | |||||
| const AUTOREVIEW_REVIEW = 'review'; | |||||
| const AUTOREVIEW_BLOCK = 'block'; | |||||
| public static function initializeNewPackage(PhabricatorUser $actor) { | public static function initializeNewPackage(PhabricatorUser $actor) { | ||||
| $app = id(new PhabricatorApplicationQuery()) | $app = id(new PhabricatorApplicationQuery()) | ||||
| ->setViewer($actor) | ->setViewer($actor) | ||||
| ->withClasses(array('PhabricatorOwnersApplication')) | ->withClasses(array('PhabricatorOwnersApplication')) | ||||
| ->executeOne(); | ->executeOne(); | ||||
| $view_policy = $app->getPolicy( | $view_policy = $app->getPolicy( | ||||
| PhabricatorOwnersDefaultViewCapability::CAPABILITY); | PhabricatorOwnersDefaultViewCapability::CAPABILITY); | ||||
| $edit_policy = $app->getPolicy( | $edit_policy = $app->getPolicy( | ||||
| PhabricatorOwnersDefaultEditCapability::CAPABILITY); | PhabricatorOwnersDefaultEditCapability::CAPABILITY); | ||||
| return id(new PhabricatorOwnersPackage()) | return id(new PhabricatorOwnersPackage()) | ||||
| ->setAuditingEnabled(0) | ->setAuditingEnabled(0) | ||||
| ->setAutoReview(self::AUTOREVIEW_NONE) | |||||
| ->setViewPolicy($view_policy) | ->setViewPolicy($view_policy) | ||||
| ->setEditPolicy($edit_policy) | ->setEditPolicy($edit_policy) | ||||
| ->attachPaths(array()) | ->attachPaths(array()) | ||||
| ->setStatus(self::STATUS_ACTIVE) | ->setStatus(self::STATUS_ACTIVE) | ||||
| ->attachOwners(array()) | ->attachOwners(array()) | ||||
| ->setDescription(''); | ->setDescription(''); | ||||
| } | } | ||||
| public static function getStatusNameMap() { | public static function getStatusNameMap() { | ||||
| return array( | return array( | ||||
| self::STATUS_ACTIVE => pht('Active'), | self::STATUS_ACTIVE => pht('Active'), | ||||
| self::STATUS_ARCHIVED => pht('Archived'), | self::STATUS_ARCHIVED => pht('Archived'), | ||||
| ); | ); | ||||
| } | } | ||||
| public static function getAutoreviewOptionsMap() { | |||||
| return array( | |||||
| self::AUTOREVIEW_NONE => array( | |||||
| 'name' => pht('No Autoreview'), | |||||
| ), | |||||
| self::AUTOREVIEW_SUBSCRIBE => array( | |||||
| 'name' => pht('Subscribe to Changes'), | |||||
| ), | |||||
| // TODO: Implement these. | |||||
| // self::AUTOREVIEW_REVIEW => array( | |||||
| // 'name' => pht('Review Changes'), | |||||
| // ), | |||||
| // self::AUTOREVIEW_BLOCK => array( | |||||
| // 'name' => pht('Review Changes (Blocking)'), | |||||
| // ), | |||||
| ); | |||||
| } | |||||
| protected function getConfiguration() { | protected function getConfiguration() { | ||||
| return array( | return array( | ||||
| // This information is better available from the history table. | // This information is better available from the history table. | ||||
| self::CONFIG_TIMESTAMPS => false, | self::CONFIG_TIMESTAMPS => false, | ||||
| self::CONFIG_AUX_PHID => true, | self::CONFIG_AUX_PHID => true, | ||||
| self::CONFIG_COLUMN_SCHEMA => array( | self::CONFIG_COLUMN_SCHEMA => array( | ||||
| 'name' => 'sort128', | 'name' => 'sort128', | ||||
| 'originalName' => 'text255', | 'originalName' => 'text255', | ||||
| 'description' => 'text', | 'description' => 'text', | ||||
| 'primaryOwnerPHID' => 'phid?', | 'primaryOwnerPHID' => 'phid?', | ||||
| 'auditingEnabled' => 'bool', | 'auditingEnabled' => 'bool', | ||||
| 'mailKey' => 'bytes20', | 'mailKey' => 'bytes20', | ||||
| 'status' => 'text32', | 'status' => 'text32', | ||||
| 'autoReview' => 'text32', | |||||
| ), | ), | ||||
| ) + parent::getConfiguration(); | ) + parent::getConfiguration(); | ||||
| } | } | ||||
| public function generatePHID() { | public function generatePHID() { | ||||
| return PhabricatorPHID::generateNewPHID( | return PhabricatorPHID::generateNewPHID( | ||||
| PhabricatorOwnersPackagePHIDType::TYPECONST); | PhabricatorOwnersPackagePHIDType::TYPECONST); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 393 Lines • Show Last 20 Lines | |||||