mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
merged fix for MDL-7055 - prohibts at site level not working
This commit is contained in:
parent
2058a0a1b2
commit
819e5a70c3
@ -724,7 +724,7 @@ function load_user_capability($capability='', $context ='', $userid='') {
|
|||||||
if (!empty($otheruserid)) { // we are pulling out other user's capabilities, do not write to session
|
if (!empty($otheruserid)) { // we are pulling out other user's capabilities, do not write to session
|
||||||
|
|
||||||
if (capability_prohibits($capability->capability, $context, $capability->sum, $usercap)) {
|
if (capability_prohibits($capability->capability, $context, $capability->sum, $usercap)) {
|
||||||
$usercap[$capability->id][$capability->capability] = -9000;
|
$usercap[$capability->id][$capability->capability] = CAP_PROHIBIT;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -733,7 +733,7 @@ function load_user_capability($capability='', $context ='', $userid='') {
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (capability_prohibits($capability->capability, $context, $capability->sum)) { // if any parent or parent's parent is set to prohibit
|
if (capability_prohibits($capability->capability, $context, $capability->sum)) { // if any parent or parent's parent is set to prohibit
|
||||||
$USER->capabilities[$capability->id][$capability->capability] = -9000;
|
$USER->capabilities[$capability->id][$capability->capability] = CAP_PROHIBIT;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -818,20 +818,20 @@ function check_enrolment_plugins(&$user) {
|
|||||||
function capability_prohibits($capability, $context, $sum='', $array='') {
|
function capability_prohibits($capability, $context, $sum='', $array='') {
|
||||||
global $USER;
|
global $USER;
|
||||||
|
|
||||||
if ($sum < -8000) {
|
if ($sum < (CAP_PROHIBIT/2)) {
|
||||||
// If this capability is set to prohibit.
|
// If this capability is set to prohibit.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($array)) {
|
if (!empty($array)) {
|
||||||
if (isset($array[$context->id][$capability])
|
if (isset($array[$context->id][$capability])
|
||||||
&& $array[$context->id][$capability] < -8000) {
|
&& $array[$context->id][$capability] < (CAP_PROHIBIT/2)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Else if set in session.
|
// Else if set in session.
|
||||||
if (isset($USER->capabilities[$context->id][$capability])
|
if (isset($USER->capabilities[$context->id][$capability])
|
||||||
&& $USER->capabilities[$context->id][$capability] < -8000) {
|
&& $USER->capabilities[$context->id][$capability] < (CAP_PROHIBIT/2)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user