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

Source Code bug in accesslib.php

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Critical Critical
    • 1.9.9
    • 1.9.3, 1.9.4, 1.9.5, 1.9.6, 1.9.7, 1.9.8
    • Roles / Access
    • None
    • PostgreSQL
    • MOODLE_19_STABLE
    • MOODLE_19_STABLE

      When we setup assignments to different groups, we can view assignments . But if we choose a group, we got error message "No users were found with permissions to submit this assignment". I tracked the source code and found the problem is in the file accesslib.php in moodle lib directory. in function get_users_by_capability, because of our site settings, it went through the code
      if ($defaultroleinteresting) {
      $sql = "SELECT $fields
      FROM {$CFG->prefix}user u
      $uljoin
      $where
      ORDER BY $sort";

      return get_records_sql($sql, $limitfrom, $limitnum);
      }
      I displayed the sql statement, it shows
      SELECT u.id FROM mdl_user u WHERE u.deleted = 0 AND (ra.userid IN (SELECT userid FROM mdl_groups_members gm WHERE gm.groupid = 1)) ORDER BY u.lastaccess

      the problem is ra.userid in the statement, there is no table alias is ra, so I tracked down where it came from. It is still in the same function. the code is
      if ($groups) {
      if (is_array($groups))

      { $grouptest = 'gm.groupid IN (' . implode(',', $groups) . ')'; }

      else

      { $grouptest = 'gm.groupid = ' . $groups; }

      $grouptest = 'ra.userid IN (SELECT userid FROM ' .
      $CFG->prefix . 'groups_members gm WHERE ' . $grouptest . ')';

      if ($useviewallgroups)

      { $viewallgroupsusers = get_users_by_capability($context, 'moodle/site:accessallgroups', 'u.id, u.id', '', '', '', '', $exceptions); $wherecond['groups'] = '('. $grouptest . ' OR ra.userid IN (' . implode(',', array_keys($viewallgroupsusers)) . '))'; }

      else

      { $wherecond['groups'] = '(' . $grouptest .')'; }

      }

      if we change ra.userid to u.id in the code above, it will work. But I am not sure whether the changes will affect something else, so I report this bug and let the author of this file fix it.

      once it is fixed, please inform us and I can upload the fixed file to solve our problems.

      Thanks
      Ye

            skodak Petr Skoda
            yc5x Ye Chen (Inactive)
            Nobody Nobody (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.