mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Wrong usage of Member::currentUser() in SiteTree->canEdit()
ENHANCEMENT Allowing to explicitly check SiteTree->can*() actions for a non-existing member without triggering Member::currentUser() fallback for better testability git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@66672 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
501cd2b70d
commit
47a67a5a4e
@ -616,10 +616,9 @@ class SiteTree extends DataObject {
|
||||
}
|
||||
|
||||
// check for any logged-in users
|
||||
if(
|
||||
$this->CanViewType == 'LoggedInUsers'
|
||||
&& Member::currentUser()
|
||||
) return true;
|
||||
if($this->CanViewType == 'LoggedInUsers' && $member) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// check for specific groups
|
||||
if(
|
||||
@ -691,7 +690,7 @@ class SiteTree extends DataObject {
|
||||
* @return boolean True if the current user can create pages on this class.
|
||||
*/
|
||||
public function canCreate($member = null) {
|
||||
if(!isset($member)) $member = Member::currentUser();
|
||||
if(!$member && $member !== FALSE) $member = Member::currentUser();
|
||||
|
||||
if(Permission::checkMember($member, "ADMIN")) return true;
|
||||
|
||||
@ -723,11 +722,11 @@ class SiteTree extends DataObject {
|
||||
* @uses EditorGroups()
|
||||
* @uses DataObjectDecorator->canEdit()
|
||||
*
|
||||
* @param Member $member
|
||||
* @param Member $member Set to FALSE if you want to explicitly test permissions without a valid user (useful for unit tests)
|
||||
* @return boolean True if the current user can edit this page.
|
||||
*/
|
||||
public function canEdit($member = null) {
|
||||
if(!$member) $member = Member::currentUser();
|
||||
if(!$member && $member !== FALSE) $member = Member::currentUser();
|
||||
|
||||
if(Permission::checkMember($member, "ADMIN")) return true;
|
||||
|
||||
@ -775,7 +774,7 @@ class SiteTree extends DataObject {
|
||||
* @return boolean True if the current user can publish this page.
|
||||
*/
|
||||
public function canPublish($member = null) {
|
||||
if(!$member) $member = Member::currentUser();
|
||||
if(!$member && $member !== FALSE) $member = Member::currentUser();
|
||||
|
||||
if(Permission::checkMember($member, "ADMIN")) return true;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user