Note: You are currently viewing documentation for Moodle 1.9. Up-to-date documentation for the latest stable version is available here: Role overrides revisited.

Obsolete:Role overrides revisited

From MoodleDocs

Originally the user capabilities were calculated as a sum of role capabilities/overrides in all parent contexts. In 1.9 it was completely rewritten.

Summary of problems in 1.9.x

  • overrides in one role affect evaluation of resulting capabilities from other roles
  • very hard to explain to normal people (including most of the developers, sorry)
  • relies heavily on PHP code and is nearly impossible to optimise with SQL especially when fetching list of courses where user is participating

Proposed solution

Change evaluation algorithm, instead of aggregation caps from all roles in each step, calculate resulting capability for each role and use OR logical operation on the result. The prohibit would work the same way as before.

Example

role_eval_proposal.png

Algorithm

Backwards compatibility

Needed code changes

Performance improvements