Moodle

moodle/block:view to control block visibility

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.9
  • Fix Version/s: 1.9
  • Component/s: Blocks, Roles / Access
  • Labels:
    None
  • Affected Branches:
    MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_19_STABLE

Description

There are occasions where it would be useful to prevent users from viewing certain blocks. For instance, a course_list block might be placed on the front page to allow students to view their courses, but site administrators don't want guests to see a list of courses.

The natural way to control this behaviour would seem to be through roles. I would imagine the most frequently used workflow for this would be creating a prevent role overirde on the guest role of the block.

I've created a moodle/block:view capability which controls access to vew a block and works effectively.

There are a couple of issues though:

1) It seems to be assumed that CONTEXT_BLOCK capabilities will only come from block modules and not moodle components. Which means i've had to modified the langage string function and override functions to look at moodle components which have the CONTEXT_BLOCK capabilities. These are the only two places i've seen this assumption made, but presumably it could be in other places.

2) We have the capability cache 'problem', where by if a capability is changed it won't be observed in existing sessions because of the capability cache. It would be nice if we had a way of resetting the cache of current sessions on capability changes.

Issue Links

Activity

Hide
Dan Poltawski added a comment -

Adding Yu in here

Show
Dan Poltawski added a comment - Adding Yu in here
Hide
Dan Poltawski added a comment -

Regarding point 1) it seems that the language string finder and fetch_context_capabilities are the only points which this assumption has been made

Show
Dan Poltawski added a comment - Regarding point 1) it seems that the language string finder and fetch_context_capabilities are the only points which this assumption has been made
Hide
Dan Poltawski added a comment -

I've commited this to HEAD

Show
Dan Poltawski added a comment - I've commited this to HEAD
Hide
Petr Škoda (skodak) added a comment -

reopening:
1/ it is not implemented in block_list class
2/ also the definition of capability for user is not compatible with "switch role" - it would work fine if it was defined for normal roles

Show
Petr Škoda (skodak) added a comment - reopening: 1/ it is not implemented in block_list class 2/ also the definition of capability for user is not compatible with "switch role" - it would work fine if it was defined for normal roles
Hide
Dan Poltawski added a comment -

I've

  • Implementing block_list capapability check - ideally I think this capability check would not go in is_empty, however I can't really find a cleaner more explicit place to put it.
  • Added the default legacy permissions to fix the switch roles issue. I don't think there is a good way to add the capability definition to the default roles for sites which have already upgraded to get this capability?
Show
Dan Poltawski added a comment - I've
  • Implementing block_list capapability check - ideally I think this capability check would not go in is_empty, however I can't really find a cleaner more explicit place to put it.
  • Added the default legacy permissions to fix the switch roles issue. I don't think there is a good way to add the capability definition to the default roles for sites which have already upgraded to get this capability?
Hide
Ralf Hilgenstock added a comment -

Does it also work with additional customized new roles?

Show
Ralf Hilgenstock added a comment - Does it also work with additional customized new roles?
Hide
Petr Škoda (skodak) added a comment -

fix in MDL-10945 works around the problem in switch role mode

I do not think it is a major problem for sites that already upgraded to 1.9dev - they can use course reset feature; admins should review the capabilities manually anyway after each major upgrade (recommended/default settings are highlighted since 1.8).

Show
Petr Škoda (skodak) added a comment - fix in MDL-10945 works around the problem in switch role mode I do not think it is a major problem for sites that already upgraded to 1.9dev - they can use course reset feature; admins should review the capabilities manually anyway after each major upgrade (recommended/default settings are highlighted since 1.8).

People

Vote (0)
Watch (3)

Dates

  • Created:
    Updated:
    Resolved: