From 72a069a3233d02f67b53ce8c93064e4da1469d09 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Tue, 28 Aug 2007 01:53:36 +0000 Subject: [PATCH] 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 --- security/Permission.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/security/Permission.php b/security/Permission.php index cdad11a41..4d0e4dc7e 100755 --- a/security/Permission.php +++ b/security/Permission.php @@ -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 );