// logs in. The site front page will always show the same (logged-out) view.
// $CFG->disablemycourses = true;
//
+// Enable this option if you need fully working default frontpage role,
+// please note it might cause serious memory and performance issues,
+// also there should not be any negative capabilities in default
+// frontpage role (MDL-19039).
+// $CFG->fullusersbycapabilityonfrontpage = true;
+//
// If this setting is set to true, then Moodle will track the IP of the
// current user to make sure it hasn't changed during a session. This
// will prevent the possibility of sessions being hijacked via XSS, but it
$defaultroleinteresting = false;
}
+ // is the default role interesting? does it have
+ // a relevant rolecap? (we use this a lot later)
+ if (($isfrontpage or is_inside_frontpage($context)) and !empty($CFG->defaultfrontpageroleid) and in_array((int)$CFG->defaultfrontpageroleid, $roleids, true)) {
+ if (!empty($CFG->fullusersbycapabilityonfrontpage)) {
+ // new in 1.9.6 - full support for defaultfrontpagerole MDL-19039
+ $frontpageroleinteresting = true;
+ } else {
+ // old style 1.9.0-1.9.5 - much faster + fewer negative override problems on frontpage
+ $frontpageroleinteresting = ($context->contextlevel == CONTEXT_COURSE);
+ }
+ } else {
+ $frontpageroleinteresting = false;
+ }
+
//
// Prepare query clauses
//
if (!$negperm) {
// at the frontpage, and all site users have it - easy!
- if ($isfrontpage && !empty($CFG->defaultfrontpageroleid)
- && in_array((int)$CFG->defaultfrontpageroleid, $roleids, true)) {
-
+ if ($frontpageroleinteresting) {
return $DB->get_records_sql("SELECT $fields
FROM {user} u
WHERE u.deleted = 0
// Did the last user end up with a positive permission?
if ($lastuserid !=0) {
+ if ($frontpageroleinteresting) {
+ // add frontpage role if interesting
+ $ras[] = array('roleid' => $CFG->defaultfrontpageroleid,
+ 'depth' => $context->depth);
+ }
if ($defaultroleinteresting) {
// add the role at the end of $ras
$ras[] = array( 'roleid' => $CFG->defaultuserroleid,
// Prune last entry if necessary
if ($lastuserid !=0) {
+ if ($frontpageroleinteresting) {
+ // add frontpage role if interesting
+ $ras[] = array('roleid' => $CFG->defaultfrontpageroleid,
+ 'depth' => $context->depth);
+ }
if ($defaultroleinteresting) {
// add the role at the end of $ras
$ras[] = array( 'roleid' => $CFG->defaultuserroleid,