Ejemplo n.º 1
0
$PAGE->navbar->add(get_string('managemodule', 'local_modules'), new moodle_url('/local/modules/index.php', array('id' => $id)));
if ($id > 0) {
    $strheading = get_string('editmodule', 'local_modules');
}
$PAGE->navbar->add($strheading);
$editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $CFG->maxbytes, 'trusttext' => false, 'noclean' => true);
$editform = new module_form(null, array('editoroptions' => $editoroptions));
$editform->set_data($tool);
if ($editform->is_cancelled()) {
    redirect($returnurl);
} else if ($data = $editform->get_data()) {
    //This is the edit form condition
    if ($data->id > 0) {
        // Update
        $data->description = $data->description['text'];
        $result = $instance->module_update_instance($data, $userid);
        $instance->success_error_msg($result, 'success_up_module', 'error_up_module', $currenturl, $data);
    } else {
        // Create new
        $data->description = $data->description['text'];
        $result = $instance->module_add_instance($data, $userid);
        $instance->success_error_msg($result, 'success_add_module', 'error_add_module', $currenturl, $data);
    }
    redirect($returnurl);
}

echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('managemodule', 'local_modules'));
if ($id < 0)
    $currenttab = "new";
else