]> git.mjollnir.org Git - moodle.git/commit
accesslib: has_capability_in_accessdata() respects rdef locality a bit more
authormartinlanghoff <martinlanghoff>
Tue, 20 Nov 2007 00:18:31 +0000 (00:18 +0000)
committermartinlanghoff <martinlanghoff>
Tue, 20 Nov 2007 00:18:31 +0000 (00:18 +0000)
commit4f957b116dda1043500f5899c426a8b16d524308
tree35f9589debdb82659bbb5664ea08a0aa6c2c7f36
parent9126bd7ee99b5ec45c03a0b29d5766663127023c
accesslib: has_capability_in_accessdata() respects rdef locality a bit more

With this patch, we respect rdef locality when two roles
assignments in the same context have conflicting rdefs.
In that case, the most local rdef wins.

So RA locality still matters most. If you are a teacher
sitewide and a student in course X, student role trumps
teacher.

For a use case, see the discussion here
http://moodle.org/mod/forum/discuss.php?d=84472

Notes:

- If we wanted to have locality of RDEF trump everything
  we can. A comment in this patch shows how.

- I don't know how to reproduce this in pure SQL.

And Also:

This patch also fixes a bug where if CAP_PROHIBIT was set
_and_ another role added to it in the same context, we would
add or substract 1 to CAP_PROHIBIT, and it would lose its magic.

And while at it, tighten the code to avoid casts. All the
ints are unambiguously ints.
lib/accesslib.php