Skip to content

Commit

Permalink
modifying get_user_by_capability to handle requests on frontpage cour…
Browse files Browse the repository at this point in the history
…ses and sub contexts. MDL-11143
  • Loading branch information
toyomoyo committed Sep 27, 2007
1 parent 3b0ee36 commit 4d7e30b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/accesslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 4d7e30b

Please sign in to comment.