mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
Changes from Mad Alex to allow better error reporting when
adding or updating modules. See: http://moodle.org/mod/forum/discuss.php?d=2738 If a moderr.html file exists in the module, it is shown. If a string is returned, it's shown. Otherwise it works as before.
This commit is contained in:
parent
65a3ef30c9
commit
e02eea80e9
@ -40,11 +40,21 @@
|
||||
$addinstancefunction = $mod->modulename."_add_instance";
|
||||
$updateinstancefunction = $mod->modulename."_update_instance";
|
||||
$deleteinstancefunction = $mod->modulename."_delete_instance";
|
||||
$moderr = "$CFG->dirroot/mod/$mod->modulename/moderr.html";
|
||||
|
||||
switch ($mod->mode) {
|
||||
case "update":
|
||||
if (! $updateinstancefunction($mod)) {
|
||||
error("Could not update the $mod->modulename");
|
||||
$return = $updateinstancefunction($mod);
|
||||
if (!$return) {
|
||||
if (file_exists($moderr)) {
|
||||
$form = $mod;
|
||||
include_once($moderr);
|
||||
die;
|
||||
}
|
||||
error("Could not update the $mod->modulename", "view.php?id=$mod->course");
|
||||
}
|
||||
if (is_string($return)) {
|
||||
error($return, "view.php?id=$mod->course");
|
||||
}
|
||||
add_to_log($mod->course, "course", "update mod",
|
||||
"../mod/$mod->modulename/view.php?id=$mod->coursemodule",
|
||||
@ -52,9 +62,19 @@
|
||||
break;
|
||||
|
||||
case "add":
|
||||
if (! $mod->instance = $addinstancefunction($mod)) {
|
||||
error("Could not add a new instance of $mod->modulename");
|
||||
$return = $addinstancefunction($mod);
|
||||
if (!$return) {
|
||||
if (file_exists($moderr)) {
|
||||
$form = $mod;
|
||||
include_once($moderr);
|
||||
die;
|
||||
}
|
||||
error("Could not add a new instance of $mod->modulename", "view.php?id=$mod->course");
|
||||
}
|
||||
if (is_string($return)) {
|
||||
error($return, "view.php?id=$mod->course");
|
||||
}
|
||||
$mod->instance = $return;
|
||||
// course_modules and course_sections each contain a reference
|
||||
// to each other, so we have to update one of them twice.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user