mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
API CHANGE Deprecated Member::isInGroup() - use Member::inGroup() instead
ENHANCEMENT Allowing usage of ID, Code-String or Object as $group parameter in Member::inGroup() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@62847 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
6a7ead7183
commit
2d8656e72b
@ -588,7 +588,7 @@ class SiteTree extends DataObject {
|
|||||||
if(((!$this->Viewers) || ($this->Viewers == 'Anyone') ||
|
if(((!$this->Viewers) || ($this->Viewers == 'Anyone') ||
|
||||||
($this->Viewers == 'LoggedInUsers' && $member) ||
|
($this->Viewers == 'LoggedInUsers' && $member) ||
|
||||||
($this->Viewers == 'OnlyTheseUsers' && $member &&
|
($this->Viewers == 'OnlyTheseUsers' && $member &&
|
||||||
$member->isInGroup($this->ViewersGroup))) == false)
|
$member->inGroup($this->ViewersGroup))) == false)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -696,7 +696,7 @@ class SiteTree extends DataObject {
|
|||||||
if((Permission::check('CMS_ACCESS_CMSMain') &&
|
if((Permission::check('CMS_ACCESS_CMSMain') &&
|
||||||
(($this->Editors == 'LoggedInUsers' && $member) ||
|
(($this->Editors == 'LoggedInUsers' && $member) ||
|
||||||
($this->Editors == 'OnlyTheseUsers' && $member &&
|
($this->Editors == 'OnlyTheseUsers' && $member &&
|
||||||
$member->isInGroup($this->EditorsGroup)))) == false)
|
$member->inGroup($this->EditorsGroup)))) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -601,33 +601,29 @@ class Member extends DataObject {
|
|||||||
/**
|
/**
|
||||||
* Check if the member is in the given group
|
* Check if the member is in the given group
|
||||||
*
|
*
|
||||||
* @param int $groupID ID of the group to check
|
* @param int|Group|string $group Group instance, Group Code or ID
|
||||||
* @return bool Returns TRUE if the member is in the given group,
|
* @return bool Returns TRUE if the member is in the given group, otherwise FALSE.
|
||||||
* otherwise FALSE.
|
|
||||||
*/
|
*/
|
||||||
|
public function inGroup($group) {
|
||||||
public function inGroup($groupID) {
|
if(is_numeric($group)) {
|
||||||
foreach($this->Groups() as $group) {
|
$groupCheckObj = DataObject::get_by_id('Group', $group);
|
||||||
if($groupID == $group->ID)
|
} elseif(is_string($group)) {
|
||||||
|
$SQL_group = Convert::raw2sql($group);
|
||||||
|
$groupCheckObj = DataObject::get_one('Group', "Code = '{$SQL_group}'");
|
||||||
|
} elseif(is_a('Group', $group)) {
|
||||||
|
$groupCheckObj = $group;
|
||||||
|
} else {
|
||||||
|
user_error('Member::inGroup(): Wrong format for $group parameter', E_USER_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($this->Groups() as $groupCandidateObj) {
|
||||||
|
if($groupCandidateObj->ID == $groupCheckObj->ID)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Alias for {@link inGroup}
|
|
||||||
*
|
|
||||||
* @param int $groupID ID of the group to check
|
|
||||||
* @return bool Returns TRUE if the member is in the given group,
|
|
||||||
* otherwise FALSE.
|
|
||||||
* @see inGroup()
|
|
||||||
*/
|
|
||||||
public function isInGroup($groupID) {
|
|
||||||
return $this->inGroup($groupID);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if this user is an administrator.
|
* Returns true if this user is an administrator.
|
||||||
* Administrators have access to everything. The lucky bastards! ;-)
|
* Administrators have access to everything. The lucky bastards! ;-)
|
||||||
@ -1024,6 +1020,13 @@ class Member extends DataObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated 2.3 Use inGroup()
|
||||||
|
*/
|
||||||
|
public function isInGroup($groupID) {
|
||||||
|
user_error('Member::isInGroup() is deprecated. Please use inGroup() instead.', E_USER_NOTICE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user