Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phame/storage/PhamePost.php
| Show First 20 Lines • Show All 185 Lines • ▼ Show 20 Lines | /* -( PhabricatorPolicyInterface Implementation )-------------------------- */ | ||||
| public function getCapabilities() { | public function getCapabilities() { | ||||
| return array( | return array( | ||||
| PhabricatorPolicyCapability::CAN_VIEW, | PhabricatorPolicyCapability::CAN_VIEW, | ||||
| PhabricatorPolicyCapability::CAN_EDIT, | PhabricatorPolicyCapability::CAN_EDIT, | ||||
| ); | ); | ||||
| } | } | ||||
| 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 members of the Blog's Join Policy | ||||
| // to whoever the blog is visible to. | // Live posts are visible to the Blog's View Policy | ||||
| switch ($capability) { | switch ($capability) { | ||||
| case PhabricatorPolicyCapability::CAN_VIEW: | case PhabricatorPolicyCapability::CAN_VIEW: | ||||
| if (!$this->isDraft() && $this->getBlog()) { | if (!$this->isDraft() && $this->getBlog()) { | ||||
| return $this->getBlog()->getViewPolicy(); | return $this->getBlog()->getViewPolicy(); | ||||
| } else if ($this->getBlog()) { | |||||
| return $this->getBlog()->getJoinPolicy(); | |||||
| } else { | } else { | ||||
| return PhabricatorPolicies::POLICY_NOONE; | return PhabricatorPolicies::POLICY_NOONE; | ||||
| } | } | ||||
| break; | break; | ||||
| case PhabricatorPolicyCapability::CAN_EDIT: | case PhabricatorPolicyCapability::CAN_EDIT: | ||||
| if ($this->getBlog()) { | |||||
| return $this->getBlog()->getJoinPolicy(); | |||||
| } else { | |||||
| return PhabricatorPolicies::POLICY_NOONE; | return PhabricatorPolicies::POLICY_NOONE; | ||||
| } | } | ||||
| break; | |||||
| } | |||||
| } | } | ||||
| public function hasAutomaticCapability($capability, PhabricatorUser $user) { | public function hasAutomaticCapability($capability, PhabricatorUser $user) { | ||||
| // A blog post's author can always view it, and is the only user allowed | // A blog post's author can always view it, and is the only user allowed | ||||
| // to edit it. | // to edit it. | ||||
| switch ($capability) { | switch ($capability) { | ||||
| case PhabricatorPolicyCapability::CAN_VIEW: | case PhabricatorPolicyCapability::CAN_VIEW: | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||