mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-17502 accesslib: added warning if incorrect parameters supplied to has_all_capabilities() and fixed parameters in course lib code
This commit is contained in:
parent
18af228bf2
commit
3ce50127b9
2 changed files with 12 additions and 4 deletions
|
@ -1789,11 +1789,15 @@ function make_categories_list(&$list, &$parents, $requiredcapability = '',
|
|||
}
|
||||
|
||||
// Add this category to $list, if the permissions check out.
|
||||
if ($requiredcapability) {
|
||||
ensure_context_subobj_present($category, CONTEXT_COURSECAT);
|
||||
}
|
||||
if (!$requiredcapability || has_all_capabilities($requiredcapability, $category->context)) {
|
||||
if (empty($requiredcapability)) {
|
||||
$list[$category->id] = $path;
|
||||
|
||||
} else {
|
||||
ensure_context_subobj_present($category, CONTEXT_COURSECAT);
|
||||
$requiredcapability = (array)$requiredcapability;
|
||||
if (has_all_capabilities($requiredcapability, $category->context)) {
|
||||
$list[$category->id] = $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -512,6 +512,10 @@ function has_any_capability($capabilities, $context, $userid=NULL, $doanything=t
|
|||
* @return bool
|
||||
*/
|
||||
function has_all_capabilities($capabilities, $context, $userid=NULL, $doanything=true) {
|
||||
if (!is_array($capabilities)) {
|
||||
debugging('Incorrect $capabilities parameter in has_all_capabilities() call - must be an array');
|
||||
return false;
|
||||
}
|
||||
foreach ($capabilities as $capability) {
|
||||
if (!has_capability($capability, $context, $userid, $doanything)) {
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue