diff --git a/core/model/DataObject.php b/core/model/DataObject.php index 7f4a1ae8c..35b0f9c9a 100644 --- a/core/model/DataObject.php +++ b/core/model/DataObject.php @@ -1761,9 +1761,7 @@ class DataObject extends ViewableData implements DataObjectInterface,i18nEntityP if(!isset($member)) { $member = Member::currentUser(); } - if($member && $member->isAdmin()) { - return true; - } + if(Permission::checkMember($member, "ADMIN")) return true; if($this->many_many('Can' . $perm)) { if($this->ParentID && $this->SecurityType == 'Inherit') { diff --git a/core/model/DatabaseAdmin.php b/core/model/DatabaseAdmin.php index d0a9ac45e..0579cc09c 100644 --- a/core/model/DatabaseAdmin.php +++ b/core/model/DatabaseAdmin.php @@ -62,7 +62,7 @@ class DatabaseAdmin extends Controller { * Updates the database schema, creating tables & fields as necessary. */ function build() { - if(Director::isLive() && Security::database_is_ready() && !Director::is_cli() && (!Member::currentUser() || !Member::currentUser()->isAdmin())) { + if(Director::isLive() && Security::database_is_ready() && !Director::is_cli() && !Permission::check("ADMIN")) { Security::permissionFailure($this, "This page is secured and you need administrator rights to access it. " . "Enter your credentials below and we will send you right along."); diff --git a/core/model/SiteTree.php b/core/model/SiteTree.php index 2ce0cfd2d..d0985e2f2 100644 --- a/core/model/SiteTree.php +++ b/core/model/SiteTree.php @@ -523,9 +523,7 @@ class SiteTree extends DataObject { if(!isset($member)) { $member = Member::currentUser(); } - if($member && $member->isAdmin()) { - return true; - } + if(Permission::checkMember($member, "ADMIN")) return true; if(method_exists($this, 'can' . ucfirst($perm))) { $method = 'can' . ucfirst($perm); @@ -562,9 +560,7 @@ class SiteTree extends DataObject { if(!isset($member)) { $member = Member::currentUser(); } - if($member && $member->isAdmin()) { - return true; - } + if(Permission::checkMember($member, "ADMIN")) return true; $args = array($member, true); $this->extend('alternateCanAddChildren', $args); @@ -594,7 +590,7 @@ class SiteTree extends DataObject { if(!isset($member)) $member = Member::currentUser(); // admin override - if($member && $member->isAdmin()) return true; + if(Permission::checkMember($member, "ADMIN")) return true; // decorated access checks $args = array($member, true); @@ -647,7 +643,7 @@ class SiteTree extends DataObject { public function canDelete($member = null) { if(!isset($member)) $member = Member::currentUser(); - if($member && $member->isAdmin()) return true; + if(Permission::checkMember($member, "ADMIN")) return true; $args = array($member, true); $this->extend('alternateCanDelete', $args); @@ -685,7 +681,7 @@ class SiteTree extends DataObject { public function canCreate($member = null) { if(!isset($member)) $member = Member::currentUser(); - if($member && $member->isAdmin()) return true; + if(Permission::checkMember($member, "ADMIN")) return true; $args = array($member, true); $this->extend('alternateCanCreate', $args); diff --git a/filesystem/Folder.php b/filesystem/Folder.php index 6ac95981c..4859c9d35 100755 --- a/filesystem/Folder.php +++ b/filesystem/Folder.php @@ -46,8 +46,7 @@ class Folder extends File { } function userCanUse() { - if( Member::currentUser()->isAdmin() ) - return true; + if(Permission::check("ADMIN")) return true; $useGroups = $this->CanUse(); @@ -62,8 +61,7 @@ class Folder extends File { } function userCanEdit() { - if( Member::currentUser()->isAdmin() ) - return true; + if(Permission::check("ADMIN")) return true; $useGroups = $this->CanEdit(); diff --git a/security/Member.php b/security/Member.php index 7514f361e..99e68a030 100644 --- a/security/Member.php +++ b/security/Member.php @@ -566,13 +566,11 @@ class Member extends DataObject { * Returns true if this user is an administrator. * Administrators have access to everything. * - * @TODO Should this function really exist? Is not {@link isAdmin()} the - * only right name for this? - * + * @deprecated Use Permission::check('ADMIN') instead * @return Returns TRUE if this user is an administrator. */ function isAdmin() { - return Permission::check('ADMIN'); + return Permission::checkMember($this, 'ADMIN'); } //------------------- HELPER METHODS -----------------------------------// diff --git a/security/Security.php b/security/Security.php index 138be9be0..81b2b0d1b 100644 --- a/security/Security.php +++ b/security/Security.php @@ -871,7 +871,7 @@ class Security extends Controller { */ public function encryptallpasswords() { // Only administrators can run this method - if(!Member::currentUser() || !Member::currentUser()->isAdmin()) { + if(!Permission::check("ADMIN")) { Security::permissionFailure($this, _t('Security.PERMFAILURE',' This page is secured and you need administrator rights to access it. Enter your credentials below and we will send you right along.'));