From 80fe8fff03e735d42234838535bd9b7e7073d2d0 Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Wed, 21 Jan 2009 00:31:18 +0000 Subject: [PATCH] MINOR: merged patch from simon_w. Changed can*() methods to check they are sent valid member objects rather then arrays git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@70493 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/SiteTree.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/core/model/SiteTree.php b/core/model/SiteTree.php index 0e5760979..2da87cf1d 100644 --- a/core/model/SiteTree.php +++ b/core/model/SiteTree.php @@ -559,7 +559,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid * @todo Check we get a endless recursion if we use parent::can() */ function can($perm, $member = null) { - if(!$member && $member !== FALSE) $member = Member::currentUser(); + if(!$member || !(is_a($member, 'Member')) || is_numeric($member)) $member = Member::currentUser(); if($member && Permission::checkMember($member, "ADMIN")) return true; @@ -596,7 +596,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid * @return boolean True if the current user can add children. */ public function canAddChildren($member = null) { - if(!$member && $member !== FALSE) $member = Member::currentUser(); + if(!$member || !(is_a($member, 'Member')) || is_numeric($member)) $member = Member::currentUser(); if($member && Permission::checkMember($member, "ADMIN")) return true; @@ -628,7 +628,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid * @return boolean True if the current user can view this page. */ public function canView($member = null) { - if(!$member && $member !== FALSE) $member = Member::currentUser(); + if(!$member || !(is_a($member, 'Member')) || is_numeric($member)) $member = Member::currentUser(); // admin override if($member && Permission::checkMember($member, "ADMIN")) return true; @@ -683,7 +683,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid * @return boolean True if the current user can delete this page. */ public function canDelete($member = null) { - if(!$member && $member !== FALSE) $member = Member::currentUser(); + if(!$member || !(is_a($member, 'Member')) || is_numeric($member)) $member = Member::currentUser(); if($member && Permission::checkMember($member, "ADMIN")) return true; @@ -725,7 +725,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid * @return boolean True if the current user can create pages on this class. */ public function canCreate($member = null) { - if(!$member && $member !== FALSE) $member = Member::currentUser(); + if(!$member || !(is_a($member, 'Member')) || is_numeric($member)) $member = Member::currentUser(); if($member && Permission::checkMember($member, "ADMIN")) return true; @@ -761,7 +761,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid * @return boolean True if the current user can edit this page. */ public function canEdit($member = null) { - if(!$member && $member !== FALSE) $member = Member::currentUser(); + if(!$member || !(is_a($member, 'Member')) || is_numeric($member)) $member = Member::currentUser(); if($member && Permission::checkMember($member, "ADMIN")) return true; @@ -809,7 +809,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid * @return boolean True if the current user can publish this page. */ public function canPublish($member = null) { - if(!$member && $member !== FALSE) $member = Member::currentUser(); + if(!$member || !(is_a($member, 'Member')) || is_numeric($member)) $member = Member::currentUser(); if($member && Permission::checkMember($member, "ADMIN")) return true;