BUGFIX #2056: Removed all references to deprecated Member::isAdmin()

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@65232 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2008-11-04 23:31:33 +00:00
parent 72d90ab270
commit 5f177b9f08
6 changed files with 12 additions and 22 deletions

View File

@ -1761,9 +1761,7 @@ class DataObject extends ViewableData implements DataObjectInterface,i18nEntityP
if(!isset($member)) { if(!isset($member)) {
$member = Member::currentUser(); $member = Member::currentUser();
} }
if($member && $member->isAdmin()) { if(Permission::checkMember($member, "ADMIN")) return true;
return true;
}
if($this->many_many('Can' . $perm)) { if($this->many_many('Can' . $perm)) {
if($this->ParentID && $this->SecurityType == 'Inherit') { if($this->ParentID && $this->SecurityType == 'Inherit') {

View File

@ -62,7 +62,7 @@ class DatabaseAdmin extends Controller {
* Updates the database schema, creating tables & fields as necessary. * Updates the database schema, creating tables & fields as necessary.
*/ */
function build() { 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, Security::permissionFailure($this,
"This page is secured and you need administrator rights to access it. " . "This page is secured and you need administrator rights to access it. " .
"Enter your credentials below and we will send you right along."); "Enter your credentials below and we will send you right along.");

View File

@ -523,9 +523,7 @@ class SiteTree extends DataObject {
if(!isset($member)) { if(!isset($member)) {
$member = Member::currentUser(); $member = Member::currentUser();
} }
if($member && $member->isAdmin()) { if(Permission::checkMember($member, "ADMIN")) return true;
return true;
}
if(method_exists($this, 'can' . ucfirst($perm))) { if(method_exists($this, 'can' . ucfirst($perm))) {
$method = 'can' . ucfirst($perm); $method = 'can' . ucfirst($perm);
@ -562,9 +560,7 @@ class SiteTree extends DataObject {
if(!isset($member)) { if(!isset($member)) {
$member = Member::currentUser(); $member = Member::currentUser();
} }
if($member && $member->isAdmin()) { if(Permission::checkMember($member, "ADMIN")) return true;
return true;
}
$args = array($member, true); $args = array($member, true);
$this->extend('alternateCanAddChildren', $args); $this->extend('alternateCanAddChildren', $args);
@ -594,7 +590,7 @@ class SiteTree extends DataObject {
if(!isset($member)) $member = Member::currentUser(); if(!isset($member)) $member = Member::currentUser();
// admin override // admin override
if($member && $member->isAdmin()) return true; if(Permission::checkMember($member, "ADMIN")) return true;
// decorated access checks // decorated access checks
$args = array($member, true); $args = array($member, true);
@ -647,7 +643,7 @@ class SiteTree extends DataObject {
public function canDelete($member = null) { public function canDelete($member = null) {
if(!isset($member)) $member = Member::currentUser(); if(!isset($member)) $member = Member::currentUser();
if($member && $member->isAdmin()) return true; if(Permission::checkMember($member, "ADMIN")) return true;
$args = array($member, true); $args = array($member, true);
$this->extend('alternateCanDelete', $args); $this->extend('alternateCanDelete', $args);
@ -685,7 +681,7 @@ class SiteTree extends DataObject {
public function canCreate($member = null) { public function canCreate($member = null) {
if(!isset($member)) $member = Member::currentUser(); if(!isset($member)) $member = Member::currentUser();
if($member && $member->isAdmin()) return true; if(Permission::checkMember($member, "ADMIN")) return true;
$args = array($member, true); $args = array($member, true);
$this->extend('alternateCanCreate', $args); $this->extend('alternateCanCreate', $args);

View File

@ -46,8 +46,7 @@ class Folder extends File {
} }
function userCanUse() { function userCanUse() {
if( Member::currentUser()->isAdmin() ) if(Permission::check("ADMIN")) return true;
return true;
$useGroups = $this->CanUse(); $useGroups = $this->CanUse();
@ -62,8 +61,7 @@ class Folder extends File {
} }
function userCanEdit() { function userCanEdit() {
if( Member::currentUser()->isAdmin() ) if(Permission::check("ADMIN")) return true;
return true;
$useGroups = $this->CanEdit(); $useGroups = $this->CanEdit();

View File

@ -566,13 +566,11 @@ class Member extends DataObject {
* Returns true if this user is an administrator. * Returns true if this user is an administrator.
* Administrators have access to everything. * Administrators have access to everything.
* *
* @TODO Should this function really exist? Is not {@link isAdmin()} the * @deprecated Use Permission::check('ADMIN') instead
* only right name for this?
*
* @return Returns TRUE if this user is an administrator. * @return Returns TRUE if this user is an administrator.
*/ */
function isAdmin() { function isAdmin() {
return Permission::check('ADMIN'); return Permission::checkMember($this, 'ADMIN');
} }
//------------------- HELPER METHODS -----------------------------------// //------------------- HELPER METHODS -----------------------------------//

View File

@ -871,7 +871,7 @@ class Security extends Controller {
*/ */
public function encryptallpasswords() { public function encryptallpasswords() {
// Only administrators can run this method // Only administrators can run this method
if(!Member::currentUser() || !Member::currentUser()->isAdmin()) { if(!Permission::check("ADMIN")) {
Security::permissionFailure($this, Security::permissionFailure($this,
_t('Security.PERMFAILURE',' This page is secured and you need administrator rights to access it. _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.')); Enter your credentials below and we will send you right along.'));