mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Added Permission::get_groups_by_permission
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@41211 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
49375c45c4
commit
211f7b7ae6
@ -189,6 +189,25 @@ class Permission extends DataObject {
|
|||||||
return $members;
|
return $members;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all of the groups that have one of the given permission codes
|
||||||
|
* @param $codes array|string Either a single permission code, or an array of permission codes
|
||||||
|
* @return DataObjectSet The matching group objects
|
||||||
|
*/
|
||||||
|
static function get_groups_by_permission($codes) {
|
||||||
|
if(!is_array($codes)) $codes = array($codes);
|
||||||
|
|
||||||
|
$SQLa_codes = Convert::raw2sql($codes);
|
||||||
|
$SQL_codes = join("','", $SQLa_codes);
|
||||||
|
|
||||||
|
return DataObject::get(
|
||||||
|
'Group',
|
||||||
|
"Permission.Code IN ('$SQL_codes')",
|
||||||
|
"",
|
||||||
|
"LEFT JOIN Permission ON Group.ID = Permission.GroupID"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
static function get_codes($blankItemText = null) {
|
static function get_codes($blankItemText = null) {
|
||||||
$classes = ClassInfo::implementorsOf('PermissionProvider');
|
$classes = ClassInfo::implementorsOf('PermissionProvider');
|
||||||
|
|
||||||
@ -213,7 +232,7 @@ class Permission extends DataObject {
|
|||||||
return $allCodes;
|
return $allCodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Controller action to list the codes available
|
* Controller action to list the codes available
|
||||||
*/
|
*/
|
||||||
function listcodes() {
|
function listcodes() {
|
||||||
|
Loading…
Reference in New Issue
Block a user