Added required 'require'

This commit is contained in:
PMKuipers 2023-08-17 23:28:48 +02:00
parent d8cc45061d
commit 9fde891c94

View File

@ -1,6 +1,8 @@
<?php
namespace local_treestudyplan\local\helpers;
require_once($CFG->dirroot.'/webservice/lib.php');
class webservicehelper {
/** @var \context_system */
@ -53,19 +55,23 @@ class webservicehelper {
}
$children = $parent->get_children();
// Since the change for a category permission is greatest at the lower levels,
// we scan in two stages, to focus the search more on the lower levels instead of diving deep into the first category
// Stage one (surface check): check all children for the capability
foreach($children as $child){
// Check if we should add this category
if(has_capability($capability,$child->get_context())){
return true;
} else {
if($child->get_children_count() > 0){
if(self::has_capability_in_any_category($capability,$child)){
return true;
}
}
}
// Stage two (deep dive): recurse into the child categories
foreach($children as $child){
if($child->get_children_count() > 0){
if(self::has_capability_in_any_category($capability,$child)){
return true;
}
}
}
return false;
}