Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phame/storage/PhamePost.php
| Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | final class PhamePost extends PhameDAO | ||||
| public function getBlog() { | public function getBlog() { | ||||
| return $this->assertAttached($this->blog); | return $this->assertAttached($this->blog); | ||||
| } | } | ||||
| public function getLiveURI() { | public function getLiveURI() { | ||||
| $blog = $this->getBlog(); | $blog = $this->getBlog(); | ||||
| $is_draft = $this->isDraft(); | $is_draft = $this->isDraft(); | ||||
| if (strlen($blog->getDomain()) && !$is_draft) { | $is_archived = $this->isArchived(); | ||||
| if (strlen($blog->getDomain()) && !$is_draft && !$is_archived) { | |||||
| return $this->getExternalLiveURI(); | return $this->getExternalLiveURI(); | ||||
| } else { | } else { | ||||
| return $this->getInternalLiveURI(); | return $this->getInternalLiveURI(); | ||||
| } | } | ||||
| } | } | ||||
| public function getExternalLiveURI() { | public function getExternalLiveURI() { | ||||
| $id = $this->getID(); | $id = $this->getID(); | ||||
| Show All 22 Lines | final class PhamePost extends PhameDAO | ||||
| public function getEditURI() { | public function getEditURI() { | ||||
| return '/phame/post/edit/'.$this->getID().'/'; | return '/phame/post/edit/'.$this->getID().'/'; | ||||
| } | } | ||||
| public function isDraft() { | public function isDraft() { | ||||
| return ($this->getVisibility() == PhameConstants::VISIBILITY_DRAFT); | return ($this->getVisibility() == PhameConstants::VISIBILITY_DRAFT); | ||||
| } | } | ||||
| public function isArchived() { | |||||
| return ($this->getVisibility() == PhameConstants::VISIBILITY_ARCHIVED); | |||||
| } | |||||
| 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( | ||||
| 'title' => 'text255', | 'title' => 'text255', | ||||
| ▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | /* -( PhabricatorPolicyInterface Implementation )-------------------------- */ | ||||
| } | } | ||||
| public function getPolicy($capability) { | public function getPolicy($capability) { | ||||
| // Draft posts are visible only to the author. Published posts are visible | // Draft posts are visible only to the author. Published posts are visible | ||||
| // to whoever the blog is visible to. | // to whoever the blog is visible to. | ||||
| switch ($capability) { | switch ($capability) { | ||||
| case PhabricatorPolicyCapability::CAN_VIEW: | case PhabricatorPolicyCapability::CAN_VIEW: | ||||
| if (!$this->isDraft() && $this->getBlog()) { | if (!$this->isDraft() && !$this->isArchived() && $this->getBlog()) { | ||||
| return $this->getBlog()->getViewPolicy(); | return $this->getBlog()->getViewPolicy(); | ||||
| } else if ($this->getBlog()) { | } else if ($this->getBlog()) { | ||||
| return $this->getBlog()->getEditPolicy(); | return $this->getBlog()->getEditPolicy(); | ||||
| } else { | } else { | ||||
| return PhabricatorPolicies::POLICY_NOONE; | return PhabricatorPolicies::POLICY_NOONE; | ||||
| } | } | ||||
| break; | break; | ||||
| case PhabricatorPolicyCapability::CAN_EDIT: | case PhabricatorPolicyCapability::CAN_EDIT: | ||||
| ▲ Show 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | return array( | ||||
| ->setDescription(pht('Publish date, if the post has been published.')), | ->setDescription(pht('Publish date, if the post has been published.')), | ||||
| ); | ); | ||||
| } | } | ||||
| public function getFieldValuesForConduit() { | public function getFieldValuesForConduit() { | ||||
| if ($this->isDraft()) { | if ($this->isDraft()) { | ||||
| $date_published = null; | $date_published = null; | ||||
| } else if ($this->isArchived()) { | |||||
| $date_published = null; | |||||
| } else { | } else { | ||||
| $date_published = (int)$this->getDatePublished(); | $date_published = (int)$this->getDatePublished(); | ||||
| } | } | ||||
| return array( | return array( | ||||
| 'title' => $this->getTitle(), | 'title' => $this->getTitle(), | ||||
| 'slug' => $this->getSlug(), | 'slug' => $this->getSlug(), | ||||
| 'blogPHID' => $this->getBlogPHID(), | 'blogPHID' => $this->getBlogPHID(), | ||||
| Show All 11 Lines | |||||