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

Cannot clear lists of allowed roles when editing a role

XMLWordPrintable

    • MOODLE_34_STABLE, MOODLE_35_STABLE, MOODLE_36_STABLE
    • MOODLE_37_STABLE, MOODLE_38_STABLE
    • Easy
    • Hide
      1. Log in as admin
      2. Go to Site administration -> Users -> Permissions -> Define roles
      3. Edit one of the existing roles
      4. Select at least one value for all 'Allow role ****' multiple selects.
        • Fields are: Allow role assignments, Allow role overrides, Allow role switches and Allow role to view.
      5. Save changes
      6. Edit the same existing role again.
      7. Unselect all values in all  'Allow role ****' multiple selects.
      8. Save changes
      9. Edit the same existing role.
      10. Make sure changes were saved and the  'Allow role ****' multiple selects are empty.
      Show
      Log in as admin Go to Site administration -> Users -> Permissions -> Define roles Edit one of the existing roles Select at least one value for all 'Allow role ****' multiple selects. Fields are : Allow role assignments, Allow role overrides, Allow role switches and Allow role to view. Save changes Edit the same existing role again. Unselect all values in all  'Allow role ****' multiple selects. Save changes Edit the same existing role. Make sure changes were saved and the  'Allow role ****' multiple selects are empty.

      If an existing role has one or more allowed roles selected, clearing the list is ignored when saved and the list of allowed roles remains unchanged.

      The issue is caused by this code in define_role_table_advanced.php:

       // Allowed roles.
       $allow = optional_param_array('allowassign', null, PARAM_INT);
       if (!is_null($allow)) {
        $this->allowassign = $allow;
       }
       $allow = optional_param_array('allowoverride', null, PARAM_INT);
       if (!is_null($allow)) {
        $this->allowoverride = $allow;
       }
       $allow = optional_param_array('allowswitch', null, PARAM_INT);
       if (!is_null($allow)) {
        $this->allowswitch = $allow;
       }
       $allow = optional_param_array('allowview', null, PARAM_INT);
       if (!is_null($allow)) {
        $this->allowview = $allow;
       }
      

      Changing it to the following resolves the issue:

       // Allowed roles.
       $allow = optional_param_array('allowassign', null, PARAM_INT);
       if (!is_null($allow)) {
        $this->allowassign = $allow;
       } else {
        $this->allowassign = array();
       }
       $allow = optional_param_array('allowoverride', null, PARAM_INT);
       if (!is_null($allow)) {
        $this->allowoverride = $allow;
       } else {
        $this->allowoverride = array();
       }
       $allow = optional_param_array('allowswitch', null, PARAM_INT);
       if (!is_null($allow)) {
        $this->allowswitch = $allow;
       } else {
        $this->allowswitch = array();
       }
       $allow = optional_param_array('allowview', null, PARAM_INT);
       if (!is_null($allow)) {
        $this->allowview = $allow;
       } else {
        $this->allowview = array();
       }
       

      Steps to reproduce:

      • Log in as admin
      • Go to Site administration -> Users -> Permissions
      • Edit one of the existing roles
      • Select at least one value for all 'Allow role ****' multiple selects.
      • Save changes
      • Edit the same existing role again.
      • Unselect all values in all  'Allow role ****' multiple selects.
      • Save changes
      • Go to edit the same existing role. The  'Allow role ****' multiple selects are not empty. Changes were not saved.

            marina Marina Glancy
            svickers Stephen Vickers
            Paul Holden Paul Holden
            Andrew Lyons Andrew Lyons
            Janelle Barcega Janelle Barcega
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 hours, 12 minutes
                3h 12m

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