Created
April 2, 2015 14:22
-
-
Save muskie9/b02ae7786d0b605a2019 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This function should return true if the current user can publish this | |
* page. It can be overloaded to customise the security model for an | |
* application. | |
* | |
* Denies permission if any of the following conditions is TRUE: | |
* - canPublish() on any decorator returns FALSE | |
* - canEdit() returns FALSE | |
* | |
* @uses SiteTreeDecorator->canPublish() | |
* | |
* @param Member $member | |
* @return boolean True if the current user can publish this page. | |
*/ | |
public function canPublish($member = null) { | |
if(!$member || !(is_a($member, 'Member')) || is_numeric($member)) $member = Member::currentUser(); | |
if($member && Permission::checkMember($member, "ADMIN")) return true; | |
// Standard mechanism for accepting permission changes from decorators | |
$extended = $this->extendedCan('canPublish', $member); | |
if($extended !== null) return $extended; | |
// Normal case - fail over to canEdit() | |
return $this->canEdit($member); | |
} | |
public function canDeleteFromLive($member = null) { | |
// Standard mechanism for accepting permission changes from decorators | |
$extended = $this->extendedCan('canDeleteFromLive', $member); | |
if($extended !==null) return $extended; | |
return $this->canPublish($member); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment