Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-7250

Roles: load_defaultuser_role can set 'inherit' into $USER->capabilities, should leave unset

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.7, 1.8
    • Fix Version/s: 1.7, 1.8
    • Component/s: Roles / Access
    • Labels:
      None
    • Affected Branches:
      MOODLE_17_STABLE, MOODLE_18_STABLE
    • Fixed Branches:
      MOODLE_17_STABLE, MOODLE_18_STABLE

      Description

      The defaultuser role can load 0 (inherit) into $USER->capabilities, which shouldn't happen. (Basically if you have something set for a context then it stops looking at parents.) At least on our ystem this caused problems.

      I pasted the patch below, but will check it in too.

      Index: lib/accesslib.php
      ===================================================================
      RCS file: /cvsroot/moodle/moodle/lib/accesslib.php,v
      retrieving revision 1.166.2.14
      diff -u -r1.166.2.14 accesslib.php
      — lib/accesslib.php 26 Oct 2006 09:42:58 -0000 1.166.2.14
      +++ lib/accesslib.php 27 Oct 2006 16:07:48 -0000
      @@ -130,7 +130,8 @@
      if ($capabilities = get_records_select('role_capabilities',
      "roleid = $CFG->defaultuserroleid AND contextid = $sitecontext->id")) {
      foreach ($capabilities as $capability) {

      • if (!isset($USER->capabilities[$sitecontext->id][$capability->capability]))
        Unknown macro: { // Don't overwrite+ if (!isset($USER->capabilities[$sitecontext->id][$capability->capability]) + && $capability->permission) { // Don't overwrite if it's already set, nor store 'inherit' $USER->capabilities[$sitecontext->id][$capability->capability] = $capability->permission; } }

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                quen Sam Marshall
                Reporter:
                quen Sam Marshall
                Tester:
                Nobody
                Participants:
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  7/Nov/06