Moodle
  1. Moodle
  2. MDL-33401

A manager role at site level cannot add blocks

    Details

    • Testing Instructions:
      Hide

      TEST1:

      1. Run a fresh install of Moodle. (The cap for existing installs are not changed by this patch. It needs to be a clean, fresh install for it to work).
      2. Login as admin and assign one of the users manager role at system context(site admin>users>permissions>assign system role)
      3. Goto site admin>users>permissions>capability overview
      4. Select the cap "block:edit" and the role "manager"
      5. Make sure it says "allow" at system context

      TEST2:
      1. Login as a manager and turn editing on for the front page.
      2. Add a comments block.
      3. Configure the comments block and set the page contexts to display throughout the entire site.
      4. Browse to a course and check that the comments block is displayed on the course page.
      5. Configure the comments block on the course page and change the weight on this page to -10.
      6. Check that the comments block is displayed at the top of the course page (or just below any other blocks with weight -10).

      Show
      TEST1: Run a fresh install of Moodle. (The cap for existing installs are not changed by this patch. It needs to be a clean, fresh install for it to work). Login as admin and assign one of the users manager role at system context(site admin>users>permissions>assign system role) Goto site admin>users>permissions>capability overview Select the cap "block:edit" and the role "manager" Make sure it says "allow" at system context TEST2: 1. Login as a manager and turn editing on for the front page. 2. Add a comments block. 3. Configure the comments block and set the page contexts to display throughout the entire site. 4. Browse to a course and check that the comments block is displayed on the course page. 5. Configure the comments block on the course page and change the weight on this page to -10. 6. Check that the comments block is displayed at the top of the course page (or just below any other blocks with weight -10).
    • Workaround:
      Hide

      allow block edit capability for manager role

      Show
      allow block edit capability for manager role
    • Affected Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull Master Branch:
      MDL-33401-master

      Description

      A user with site level default manager permissions cannot add a block to the front page.

      MDLQA-2024 was executed during 2.2 QA testing and passed. I have tested this in 2.2.3 and 2.3 and a user with manager permissions at site level cannot add blocks to the front page on either of those versions of Moodle.

      Test both tests in 2.2.3 and 2.3.

      Test 1:
      Test Pre-requisites:

      • A user assigned the manager role at site level.

      Test Steps:
      1. Login as a manager and turn editing on for the front page.
      2. Add a comments block.
      3. Configure the comments block and set the page contexts to display throughout the entire site.
      4. Browse to a course and check that the comments block is displayed on the course page.
      5. Configure the comments block on the course page and change the weight on this page to -10.
      6. Check that the comments block is displayed at the top of the course page (or just below any other blocks with weight -10).

      Expected result:

      • The manager can add a comments block to the front page.

      Actual Result:

      • When editing is turned on the manager sees "There are no blocks that you can add to this page." in the "Add a block" block and there are no controls to add a block.

      Test 2:
      Test Pre-requisites:

      • A user assigned the manager role at site level.
      • A user assigned the manager role at front page level.

      Test Steps:
      1. Login as a manager and turn editing on for the front page.
      2. Add a comments block.
      3. Configure the comments block and set the page contexts to display throughout the entire site.
      4. Browse to a course and check that the comments block is displayed on the course page.
      5. Configure the comments block on the course page and change the weight on this page to -10.
      6. Check that the comments block is displayed at the top of the course page (or just below any other blocks with weight -10).

      Expected result:

      • The manager can add a comments block to the front page.

      Actual Result:

      • When editing is turned on the manager sees "There are no blocks that you can add to this page." in the "Add a block" block and there are no controls to add a block.

        Gliffy Diagrams

        1. 2.2.3.jpg
          145 kB
        2. 2.3.jpg
          150 kB

          Issue Links

            Activity

            Hide
            Petr Skoda added a comment -

            I guess this is because manager does not have have capability to edit blocks 'moodle/block:edit' by default. I do not know why it was implemented like this, but it looks like it never worked.

            Show
            Petr Skoda added a comment - I guess this is because manager does not have have capability to edit blocks 'moodle/block:edit' by default. I do not know why it was implemented like this, but it looks like it never worked.
            Hide
            Tim Barker added a comment -

            Bizarre how this passed in 2.2 QA, the workaround must have been implemented as part of testing, which actually invalidates the test.

            Show
            Tim Barker added a comment - Bizarre how this passed in 2.2 QA, the workaround must have been implemented as part of testing, which actually invalidates the test.
            Hide
            Ankit Agarwal added a comment - - edited

            http://docs.moodle.org/22/en/Capabilities/moodle/site:manageblocks needs to be updated, as that is not the capability that is used to see if a user is allowed to edit a block. we use block:edit instead.
            http://docs.moodle.org/22/en/Capabilities/moodle/block:edit needs to be updated accordingly.

            Since we are changing default capabilities, this needs to be mentioned in all relevant release docs

            Show
            Ankit Agarwal added a comment - - edited http://docs.moodle.org/22/en/Capabilities/moodle/site:manageblocks needs to be updated, as that is not the capability that is used to see if a user is allowed to edit a block. we use block:edit instead. http://docs.moodle.org/22/en/Capabilities/moodle/block:edit needs to be updated accordingly. Since we are changing default capabilities, this needs to be mentioned in all relevant release docs
            Hide
            Rossiani Wijaya added a comment -

            This looks good Ankit.

            Does this need to be backported to 2.1?

            Show
            Rossiani Wijaya added a comment - This looks good Ankit. Does this need to be backported to 2.1?
            Hide
            Ankit Agarwal added a comment -

            Thanks Rosi for the review.

            @integrator

            If you think this should go to 2.1 as well, feel free to cherry-pick. It should be a clean pick.

            Thanks

            Show
            Ankit Agarwal added a comment - Thanks Rosi for the review. @integrator If you think this should go to 2.1 as well, feel free to cherry-pick. It should be a clean pick. Thanks
            Hide
            Dan Poltawski added a comment -

            The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

            TIA and ciao

            Show
            Dan Poltawski added a comment - The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. TIA and ciao
            Hide
            Ankit Agarwal added a comment -

            rebased!
            Thanks

            Show
            Ankit Agarwal added a comment - rebased! Thanks
            Hide
            Dan Poltawski added a comment -

            Integrated to master, 22 and 21. Thanks Ankit.

            Tim: I am hestiating before resetting this QA test because you will not be able to see this behaviour without a new install.

            Once this has been tested and is available on QA site then you can use the 'reset to defaults' on the manager role capbilities to fix this.

            Show
            Dan Poltawski added a comment - Integrated to master, 22 and 21. Thanks Ankit. Tim: I am hestiating before resetting this QA test because you will not be able to see this behaviour without a new install. Once this has been tested and is available on QA site then you can use the 'reset to defaults' on the manager role capbilities to fix this.
            Hide
            Frédéric Massart added a comment - - edited

            Success on both 2.2 and master. Good job! Edit: Tested successfully on 2.1 as well.

            Show
            Frédéric Massart added a comment - - edited Success on both 2.2 and master. Good job! Edit: Tested successfully on 2.1 as well.
            Hide
            Ankit Agarwal added a comment -

            Adding Michael as watcher so he can take care release notes.
            Thanks

            Show
            Ankit Agarwal added a comment - Adding Michael as watcher so he can take care release notes. Thanks
            Hide
            Dan Poltawski added a comment -

            Pinging Tim: the linked test can be reset after the QA site has been updated to take this role definition.

            Show
            Dan Poltawski added a comment - Pinging Tim: the linked test can be reset after the QA site has been updated to take this role definition.
            Hide
            Eloy Lafuente (stronk7) added a comment -

            We could celebrate it today... but better if we perform a bigger party after releasing Moodle 2.3.

            Print this message and come to Perth that day, it's valid for one beer, wine, coke or... water, as you wish.

            Many thanks for your collaboration!

            Ciao

            Show
            Eloy Lafuente (stronk7) added a comment - We could celebrate it today... but better if we perform a bigger party after releasing Moodle 2.3. Print this message and come to Perth that day, it's valid for one beer, wine, coke or... water, as you wish. Many thanks for your collaboration! Ciao
            Hide
            Mary Cooch added a comment -

            I have updated the docs re Capabilities/moodle/block:edit saying in new installs managers can edit blocks by default; however I am not sure how to update Capabilities/moodle/site:manageblocks since I didn't know that wasn't for seeing if a user is allowed to edit a block Advice gratefully received.

            Show
            Mary Cooch added a comment - I have updated the docs re Capabilities/moodle/block:edit saying in new installs managers can edit blocks by default; however I am not sure how to update Capabilities/moodle/site:manageblocks since I didn't know that wasn't for seeing if a user is allowed to edit a block Advice gratefully received.
            Hide
            Dan Poltawski added a comment -

            Hi Mary, not sure I understand your question!

            But just checking you know about the reset to defaults thing in roles?

            Show
            Dan Poltawski added a comment - Hi Mary, not sure I understand your question! But just checking you know about the reset to defaults thing in roles?
            Hide
            Ankit Agarwal added a comment -

            Hi Mary,
            Also, this issue was ported to 2.1 as well.
            http://docs.moodle.org/22/en/Capabilities/moodle/block:edit (says only 2.2)
            Thanks

            Show
            Ankit Agarwal added a comment - Hi Mary, Also, this issue was ported to 2.1 as well. http://docs.moodle.org/22/en/Capabilities/moodle/block:edit (says only 2.2) Thanks
            Hide
            Mary Cooch added a comment - - edited

            Ankit -it says 2.2 becauase those are the 2.2 docs. In the 2.1 docs it says 2.1 http://docs.moodle.org/21/en/Capabilities/moodle/block:edit (etc..)

            Dan - yes I understand about resetting to defaults. My question (rephrased) is (relating to Ankit's earlier comment) Capabilities/moodle/block:edit allows user to edit a block's settings, so what extra/different does Capabilities/moodle/site:manageblocks do?

            Show
            Mary Cooch added a comment - - edited Ankit -it says 2.2 becauase those are the 2.2 docs. In the 2.1 docs it says 2.1 http://docs.moodle.org/21/en/Capabilities/moodle/block:edit (etc..) Dan - yes I understand about resetting to defaults. My question (rephrased) is (relating to Ankit's earlier comment) Capabilities/moodle/block:edit allows user to edit a block's settings, so what extra/different does Capabilities/moodle/site:manageblocks do?
            Hide
            Ankit Agarwal added a comment -

            Hi Mary,
            Looking at the code, I was able to find only one valid use of the site:manageblocks cap. It is used to check if "Updating stickiness and contexts of a block" is allowed or not.
            May be Dan, can explain it little better.
            Thanks

            Show
            Ankit Agarwal added a comment - Hi Mary, Looking at the code, I was able to find only one valid use of the site:manageblocks cap. It is used to check if "Updating stickiness and contexts of a block" is allowed or not. May be Dan, can explain it little better. Thanks
            Show
            Mary Cooch added a comment - removing docs required label - documented http://docs.moodle.org/22/en/Capabilities/moodle/block:edit and http://docs.moodle.org/21/en/Capabilities/moodle/block:edit

              People

              • Votes:
                2 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: