-
Bug
-
Resolution: Fixed
-
Blocker
-
2.4
-
MOODLE_24_STABLE
-
MOODLE_24_STABLE
-
MDL-36864_master -
- Log in as an administrator and turn editing on.
- Visit <your site>/user/files.php
- Ensure you are not given errors about the myaddinstance capability not being defined for any blocks.
The reason this is happening is because the Private files page (and other pages using the user context) do not use the function $PAGE->set_blocks_editing_capability so the capability used by default is 'moodle/site:manageblocks'. Where as on the My Moodle page it specifies $PAGE->set_blocks_editing_capability('moodle/my:manageblocks') which allows users to add blocks on this page. Students do not have the capability 'moodle/site:manageblocks' by default, so on the private files page the student can not add blocks. However, an administrator does. Once this capability has been confirmed, another check on each individual block to see if it can be added is performed. With the previous logic in the function user_can_addto it was comparing the context to see if the user was on the My Moodle page. This if statement was then entered for the private files page as it uses the user context. With the introduction of the new capabilities it would then check 'moodle/my:manageblocks' and the 'myaddinstance' capability for the blocks, but the block capability was removed for these blocks (see MDL-34270) as they can not be added to the My Moodle page, which causes the debugging errors.
The fix was to perform a check on the page type to ensure we are indeed on the my-index page before we perform the myaddinstance capability check.
The block blog_menu does not define the standard capability block/blog_menu:myaddinstance
line 597 of /blocks/moodleblock.class.php: call to debugging()
line 570 of /blocks/moodleblock.class.php: call to block_base->has_add_block_capability()
line 236 of /lib/blocklib.php: call to block_base->user_can_addto()
line 1834 of /lib/blocklib.php: call to block_manager->get_addable_blocks()
line 1007 of /lib/blocklib.php: call to block_add_block_ui()
line 353 of /lib/blocklib.php: call to block_manager->ensure_content_created()
line 6 of /theme/base/layout/general.php: call to block_manager->region_has_content()
line 804 of /lib/outputrenderers.php: call to include()
line 734 of /lib/outputrenderers.php: call to core_renderer->render_page_layout()
line 74 of /user/files.php: call to core_renderer->header()
The block blog_recent does not define the standard capability block/blog_recent:myaddinstance
The block blog_tags does not define the standard capability block/blog_tags:myaddinstance
The block participants does not define the standard capability block/participants:myaddinstance
The block recent_activity does not define the standard capability block/recent_activity:myaddinstance