mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-16369 Added error info in accesslib
This commit is contained in:
parent
6511446349
commit
f689028c7e
1 changed files with 13 additions and 5 deletions
|
@ -1015,7 +1015,7 @@ function get_user_courses_bycap($userid, $cap, $accessdata, $doanything, $sort='
|
||||||
/// Enclosing the 3-UNION into an inline_view to avoid column names conflict and making the ORDER BY cross-db
|
/// Enclosing the 3-UNION into an inline_view to avoid column names conflict and making the ORDER BY cross-db
|
||||||
/// and to allow selection of TEXT columns in the query (MSSQL and Oracle limitation). MDL-16209
|
/// and to allow selection of TEXT columns in the query (MSSQL and Oracle limitation). MDL-16209
|
||||||
$sql = "
|
$sql = "
|
||||||
SELECT $coursefields, ctxid, ctxpath, ctxdepth, ctxlevel, categorypath
|
SELECT $coursefields, ctxid, ctxpath, ctxdepth, ctxlevel, categorypath
|
||||||
FROM (
|
FROM (
|
||||||
SELECT c.id,
|
SELECT c.id,
|
||||||
ctx.id AS ctxid, ctx.path AS ctxpath,
|
ctx.id AS ctxid, ctx.path AS ctxpath,
|
||||||
|
@ -1936,6 +1936,7 @@ function create_context($contextlevel, $instanceid) {
|
||||||
$basedepth = 1;
|
$basedepth = 1;
|
||||||
|
|
||||||
$result = true;
|
$result = true;
|
||||||
|
$error_message = null;
|
||||||
|
|
||||||
switch ($contextlevel) {
|
switch ($contextlevel) {
|
||||||
case CONTEXT_COURSECAT:
|
case CONTEXT_COURSECAT:
|
||||||
|
@ -1961,6 +1962,7 @@ function create_context($contextlevel, $instanceid) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// incorrect category id
|
// incorrect category id
|
||||||
|
$error_message = "incorrect course category id ($instanceid)";
|
||||||
$result = false;
|
$result = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1991,6 +1993,7 @@ function create_context($contextlevel, $instanceid) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
// incorrect course id
|
// incorrect course id
|
||||||
|
$error_message = "incorrect course id ($instanceid)";
|
||||||
$result = false;
|
$result = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2011,10 +2014,12 @@ function create_context($contextlevel, $instanceid) {
|
||||||
$basedepth = $parent->depth;
|
$basedepth = $parent->depth;
|
||||||
} else {
|
} else {
|
||||||
// course does not exist - modules can not exist without a course
|
// course does not exist - modules can not exist without a course
|
||||||
|
$error_message = "course does not exist ($cm->course) - modules can not exist without a course";
|
||||||
$result = false;
|
$result = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// cm does not exist
|
// cm does not exist
|
||||||
|
$error_message = "cm with id $instanceic does not exist";
|
||||||
$result = false;
|
$result = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2038,10 +2043,12 @@ function create_context($contextlevel, $instanceid) {
|
||||||
$basedepth = $parent->depth;
|
$basedepth = $parent->depth;
|
||||||
} else {
|
} else {
|
||||||
// parent course does not exist - course blocks can not exist without a course
|
// parent course does not exist - course blocks can not exist without a course
|
||||||
|
$error_message = 'parent course does not exist - course blocks can not exist without a course';
|
||||||
$result = false;
|
$result = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// block does not exist
|
// block does not exist
|
||||||
|
$error_message = 'block does not exist';
|
||||||
$result = false;
|
$result = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2065,7 +2072,8 @@ function create_context($contextlevel, $instanceid) {
|
||||||
} else {
|
} else {
|
||||||
debugging('Error: could not insert new context level "'.
|
debugging('Error: could not insert new context level "'.
|
||||||
s($contextlevel).'", instance "'.
|
s($contextlevel).'", instance "'.
|
||||||
s($instanceid).'".');
|
s($instanceid).'". ' . $error_message);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4004,7 +4012,7 @@ function get_assignable_roles($context, $field='name', $rolenamedisplay=ROLENAME
|
||||||
|
|
||||||
if (!has_capability('moodle/role:assign', $context)) {
|
if (!has_capability('moodle/role:assign', $context)) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$parents = get_parent_contexts($context);
|
$parents = get_parent_contexts($context);
|
||||||
$parents[] = $context->id;
|
$parents[] = $context->id;
|
||||||
|
@ -4045,7 +4053,7 @@ function get_assignable_roles_for_switchrole($context, $field='name', $rolenamed
|
||||||
|
|
||||||
if (!has_capability('moodle/role:assign', $context)) {
|
if (!has_capability('moodle/role:assign', $context)) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$parents = get_parent_contexts($context);
|
$parents = get_parent_contexts($context);
|
||||||
$parents[] = $context->id;
|
$parents[] = $context->id;
|
||||||
|
@ -5246,7 +5254,7 @@ function build_context_path($force=false) {
|
||||||
$updatesql = "UPDATE {context}
|
$updatesql = "UPDATE {context}
|
||||||
SET path = (SELECT path FROM {context_temp} WHERE id = {context}.id),
|
SET path = (SELECT path FROM {context_temp} WHERE id = {context}.id),
|
||||||
depth = (SELECT depth FROM {context_temp} WHERE id = {context}.id)
|
depth = (SELECT depth FROM {context_temp} WHERE id = {context}.id)
|
||||||
WHERE id IN (SELECT id FROM mdl_context_temp)";
|
WHERE id IN (SELECT id FROM mdl_context_temp)";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Top level categories
|
// Top level categories
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue