mirror of
https://github.com/moodle/moodle.git
synced 2025-04-20 07:56:06 +02:00
modifying get_user_by_capability to handle requests on frontpage courses and sub contexts. MDL-11143
This commit is contained in:
parent
3b0ee367a7
commit
4d7e30b3d8
@ -4010,6 +4010,16 @@ function get_users_by_capability($context, $capability, $fields='', $sort='',
|
||||
$view=false, $useviewallgroups=false) {
|
||||
global $CFG;
|
||||
|
||||
/// check for front page course, and see if default front page role has the required capability
|
||||
|
||||
$frontpagectx = get_context_instance(CONTEXT_COURSE, SITEID);
|
||||
if ($CFG->defaultfrontpageroleid && ($context->id == $frontpagectx->id || strstr($context->path, '/'.$cfrontpagectx->id.'/'))) {
|
||||
$roles = get_roles_with_capability($capability, CAP_ALLOW, $context);
|
||||
if (in_array($CFG->defaultfrontpageroleid, array_keys($roles))) {
|
||||
return get_records_sql("SELECT $fields FROM {$CFG->prefix}user ORDER BY $sort, $limitfrom, $limitnum");
|
||||
}
|
||||
}
|
||||
|
||||
/// Sorting out groups
|
||||
if ($groups) {
|
||||
if (is_array($groups)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user