mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Allow passing of an array of permission codes to Permission::get_members_by_permission()
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@40961 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
35665321b9
commit
72a069a323
@ -152,16 +152,18 @@ class Permission extends DataObject {
|
||||
/**
|
||||
* Returns all members for a specific permission.
|
||||
*
|
||||
* @param $code String
|
||||
* @param $code String|array Either a single permission code, or a list of permission codes
|
||||
* @return DataObjectSet
|
||||
*/
|
||||
static function get_members_by_permission($code) {
|
||||
$groupIDs = array();
|
||||
$SQL_code = Convert::raw2sql($code);
|
||||
|
||||
if(is_array($code)) $SQL_filter = "Permission.Code IN ('" . implode("','", Convert::raw2sql($code)) . "')";
|
||||
else $SQL_filter = "Permission.Code = '" . Convert::raw2sql($code) . "'";
|
||||
|
||||
$toplevelGroups = DataObject::get(
|
||||
'Group',
|
||||
"Permission.Code = '{$SQL_code}'", // filter
|
||||
$SQL_filter, // filter
|
||||
null, // limit
|
||||
"LEFT JOIN `Permission` ON `Group`.`ID` = `Permission`.`GroupID`" // join
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user