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

Restore roles duplicate

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.8.2
    • Fix Version/s: 1.8.4, 1.9, 2.0
    • Component/s: Accessibility, Backup
    • Labels:
      None
    • Database:
      Any
    • Affected Branches:
      MOODLE_18_STABLE
    • Fixed Branches:
      MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_20_STABLE

      Description

      When restoring backups, Moodle create duplicate roles. This is big problem for our system: we have many users and many courses. Every evening it is necessary to delete tens duplicated roles. And because of a problem with perfomances (MDL-10848) , it occurs very slowly.

      It allows the users, having the right to restore backups, to create any roles and to assign in them any users.

      I suggest to correct restore_check.html: if the user has no right to create a role, let it has no right to choose item "new role". If the user cannot assign a role, then he cannot do it at restoring of a backup.

      This small patch (for restore_check.html, befor "$SESSION->restore = $restor;" ant after "$restore->restore_restorecatto = $cat_id;") check of assigment roles:


      if (isset($restore->rolesmapping)){
      foreach ($restore->rolesmapping as $c_key=>$c_id) {
      // Get context for check rights
      if ($restore->course_id != 0)

      { $c_context = get_context_instance(CONTEXT_COURSE, $restore->course_id); }

      elseif ($restore->restore_restorecatto != 0)

      { $c_context = get_context_instance(CONTEXT_COURSECAT, $restore->restore_restorecatto); }

      else

      { $c_context = get_context_instance(CONTEXT_SYSTEM); }

      // Check rights to assign roles
      if (!user_can_assign($c_context, $c_id))

      { // error ('you can not override this role in this context'); $restore->rolesmapping[$c_key] = get_default_course_role($c_context); }

      }
      unset($c_context); unset($c_key); unset($c_id);
      }

        Attachments

          Activity

            People

            • Assignee:
              lazyfish Yu Zhang
              Reporter:
              mentis Alex Djachenko
              Tester:
              Nobody
              Participants:
              Component watchers:
              Adrian Greeve, Mihail Geshoski, Peter Dias, Adrian Greeve, Mihail Geshoski, Peter Dias
            • Votes:
              3 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                11/Jan/08