Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phame/storage/PhameBlog.php
Show All 15 Lines | final class PhameBlog extends PhameDAO | ||||
protected $name; | protected $name; | ||||
protected $description; | protected $description; | ||||
protected $domain; | protected $domain; | ||||
protected $configData; | protected $configData; | ||||
protected $creatorPHID; | protected $creatorPHID; | ||||
protected $viewPolicy; | protected $viewPolicy; | ||||
protected $editPolicy; | protected $editPolicy; | ||||
protected $joinPolicy; | protected $joinPolicy; | ||||
protected $mailKey; | |||||
private static $requestBlog; | private static $requestBlog; | ||||
protected function getConfiguration() { | protected function getConfiguration() { | ||||
return array( | return array( | ||||
self::CONFIG_AUX_PHID => true, | self::CONFIG_AUX_PHID => true, | ||||
self::CONFIG_SERIALIZATION => array( | self::CONFIG_SERIALIZATION => array( | ||||
'configData' => self::SERIALIZATION_JSON, | 'configData' => self::SERIALIZATION_JSON, | ||||
), | ), | ||||
self::CONFIG_COLUMN_SCHEMA => array( | self::CONFIG_COLUMN_SCHEMA => array( | ||||
'name' => 'text64', | 'name' => 'text64', | ||||
'description' => 'text', | 'description' => 'text', | ||||
'domain' => 'text128?', | 'domain' => 'text128?', | ||||
'mailKey' => 'bytes20', | |||||
// T6203/NULLABILITY | // T6203/NULLABILITY | ||||
// These policies should always be non-null. | // These policies should always be non-null. | ||||
'joinPolicy' => 'policy?', | 'joinPolicy' => 'policy?', | ||||
'editPolicy' => 'policy?', | 'editPolicy' => 'policy?', | ||||
'viewPolicy' => 'policy?', | 'viewPolicy' => 'policy?', | ||||
), | ), | ||||
self::CONFIG_KEY_SCHEMA => array( | self::CONFIG_KEY_SCHEMA => array( | ||||
'key_phid' => null, | 'key_phid' => null, | ||||
'phid' => array( | 'phid' => array( | ||||
'columns' => array('phid'), | 'columns' => array('phid'), | ||||
'unique' => true, | 'unique' => true, | ||||
), | ), | ||||
'domain' => array( | 'domain' => array( | ||||
'columns' => array('domain'), | 'columns' => array('domain'), | ||||
'unique' => true, | 'unique' => true, | ||||
), | ), | ||||
), | ), | ||||
) + parent::getConfiguration(); | ) + parent::getConfiguration(); | ||||
} | } | ||||
public function save() { | |||||
if (!$this->getMailKey()) { | |||||
$this->setMailKey(Filesystem::readRandomCharacters(20)); | |||||
} | |||||
return parent::save(); | |||||
} | |||||
public function generatePHID() { | public function generatePHID() { | ||||
return PhabricatorPHID::generateNewPHID( | return PhabricatorPHID::generateNewPHID( | ||||
PhabricatorPhameBlogPHIDType::TYPECONST); | PhabricatorPhameBlogPHIDType::TYPECONST); | ||||
} | } | ||||
public static function initializeNewBlog(PhabricatorUser $actor) { | public static function initializeNewBlog(PhabricatorUser $actor) { | ||||
$blog = id(new PhameBlog()) | $blog = id(new PhameBlog()) | ||||
->setCreatorPHID($actor->getPHID()) | ->setCreatorPHID($actor->getPHID()) | ||||
▲ Show 20 Lines • Show All 143 Lines • ▼ Show 20 Lines | public function getLiveURI(PhamePost $post = null) { | ||||
if ($post) { | if ($post) { | ||||
$base .= '/post/'.$post->getPhameTitle(); | $base .= '/post/'.$post->getPhameTitle(); | ||||
} | } | ||||
return $base; | return $base; | ||||
} | } | ||||
public function getViewURI() { | |||||
$uri = '/phame/blog/view/'.$this->getID().'/'; | |||||
return PhabricatorEnv::getProductionURI($uri); | |||||
} | |||||
/* -( PhabricatorPolicyInterface Implementation )-------------------------- */ | /* -( PhabricatorPolicyInterface Implementation )-------------------------- */ | ||||
public function getCapabilities() { | public function getCapabilities() { | ||||
return array( | return array( | ||||
PhabricatorPolicyCapability::CAN_VIEW, | PhabricatorPolicyCapability::CAN_VIEW, | ||||
PhabricatorPolicyCapability::CAN_EDIT, | PhabricatorPolicyCapability::CAN_EDIT, | ||||
▲ Show 20 Lines • Show All 126 Lines • Show Last 20 Lines |