Fixed some issues with listing categories and other rights issues
This commit is contained in:
parent
5a88761f22
commit
29c8dd9aa4
|
@ -95,10 +95,7 @@ class courseservice extends \external_api {
|
|||
public static function map_categories($rootid = 0) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$root = \core_course_category::get($rootid);
|
||||
$context = $root->get_context();
|
||||
// Make sure the user has access to the context for editing purposes.
|
||||
webservicehelper::require_capabilities(self::CAP_EDIT, $context);
|
||||
$root = \core_course_category::get($rootid,\MUST_EXIST,true);
|
||||
|
||||
// Determine top categories from provided context.
|
||||
|
||||
|
@ -115,6 +112,7 @@ class courseservice extends \external_api {
|
|||
$children = [$root];
|
||||
}
|
||||
|
||||
$list = [];
|
||||
foreach ($children as $cat) {
|
||||
$list[] = static::map_category($cat, false);
|
||||
}
|
||||
|
@ -357,7 +355,7 @@ class courseservice extends \external_api {
|
|||
if ($ctx->contextlevel == CONTEXT_SYSTEM) {
|
||||
$cat = \core_course_category::top();
|
||||
} else if ($ctx->contextlevel == CONTEXT_COURSECAT) {
|
||||
$cat = \core_course_category::get($ctx->instanceid);
|
||||
$cat = \core_course_category::get($ctx->instanceid,\MUST_EXIST,true);
|
||||
}
|
||||
$cats[] = $cat;
|
||||
if ($operation == "edit" && $ctxid == $refctxid) {
|
||||
|
@ -458,7 +456,7 @@ class courseservice extends \external_api {
|
|||
if ($ctx->contextlevel == CONTEXT_SYSTEM) {
|
||||
$cat = \core_course_category::top();
|
||||
} else if ($ctx->contextlevel == CONTEXT_COURSECAT) {
|
||||
$cat = \core_course_category::get($ctx->instanceid);
|
||||
$cat = \core_course_category::get($ctx->instanceid,\MUST_EXIST,true);
|
||||
}
|
||||
$cats[] = $cat;
|
||||
if ($operation == "view" && $ctxid == $refctxid) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user