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:
Sam Minnee 2007-08-28 01:53:36 +00:00
parent 35665321b9
commit 72a069a323

View File

@ -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
);