mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX: Fixed some bugs in the performance fixes on Permission
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@84066 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
25f22d3e99
commit
7d49e1adbf
@ -139,9 +139,12 @@ class Permission extends DataObject {
|
|||||||
* not exist at all.
|
* not exist at all.
|
||||||
*/
|
*/
|
||||||
public static function checkMember($member, $code, $arg = "any", $strict = true) {
|
public static function checkMember($member, $code, $arg = "any", $strict = true) {
|
||||||
$perms_list = self::get_declared_permissions_list();
|
if(!$member) {
|
||||||
$memberID = (is_object($member)) ? $member->ID : $member;
|
$memberID = $member = Member::currentUserID();
|
||||||
|
} else {
|
||||||
|
$memberID = (is_object($member)) ? $member->ID : $member;
|
||||||
|
}
|
||||||
|
|
||||||
if($arg == 'any') {
|
if($arg == 'any') {
|
||||||
// Cache the permissions in memory
|
// Cache the permissions in memory
|
||||||
if(!isset(self::$cache_permissions[$memberID])) {
|
if(!isset(self::$cache_permissions[$memberID])) {
|
||||||
@ -227,15 +230,18 @@ class Permission extends DataObject {
|
|||||||
*/
|
*/
|
||||||
public static function permissions_for_member($memberID) {
|
public static function permissions_for_member($memberID) {
|
||||||
$groupList = self::groupList($memberID);
|
$groupList = self::groupList($memberID);
|
||||||
$groupCSV = implode(", ", $groupList);
|
if($groupList) {
|
||||||
|
$groupCSV = implode(", ", $groupList);
|
||||||
|
|
||||||
// Raw SQL for efficiency
|
// Raw SQL for efficiency
|
||||||
return DB::query("
|
return DB::query("
|
||||||
SELECT \"Code\"
|
SELECT \"Code\"
|
||||||
FROM \"Permission\"
|
FROM \"Permission\"
|
||||||
WHERE \"Type\" = " . self::GRANT_PERMISSION . " AND \"GroupID\" IN ($groupCSV)
|
WHERE \"Type\" = " . self::GRANT_PERMISSION . " AND \"GroupID\" IN ($groupCSV)
|
||||||
")->column();
|
")->column();
|
||||||
|
} else {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user