iMath) - Computer Science Dep. of IME-USP (Brazil) * * License * - http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ global $CFG, $USER, $PAGE, $OUTPUT, $DB; require_once("../../config.php"); require_once($CFG->dirroot . '/mod/iassign/locallib.php'); require_once($CFG->dirroot . '/mod/iassign/settings_form.php'); require_login(); if (isguestuser()) { die(); } //Parameters GET e POST (parâmetros GET e POST) $ilm_id = optional_param('ilm_id', 0, PARAM_INT); $ilm_parent = optional_param('ilm_parent', 0, PARAM_INT); $status = optional_param('status', 0, PARAM_INT); $action = optional_param('action', NULL, PARAM_TEXT); $url = new moodle_url('/admin/settings.php', array('section' => 'modsettingiassign')); $from = optional_param('from', NULL, PARAM_TEXT); $contextuser = context_user::instance($USER->id); $PAGE->set_url($url); $PAGE->set_context($contextuser); $PAGE->blocks->show_only_fake_blocks(); // $PAGE->set_pagelayout('popup'); if ($action == 'edit') { $title = get_string('edit_ilm', 'iassign') . $OUTPUT->help_icon('add_ilm_iassign', 'iassign'); $PAGE->set_title($title); $param = ilm_settings::add_edit_copy_ilm($ilm_id, $action); $mform = new mod_ilm_form(); $mform->set_data($param); if ($mform->is_cancelled()) { close_window(); die; } else if ($formdata = $mform->get_submitted_data()) { ilm_settings::edit_ilm($formdata, $formdata->file); close_window(0, true); die; } print($OUTPUT->header()); print($OUTPUT->heading($title)); $mform->display(); print($OUTPUT->footer()); die; } else if ($action == 'new_version') { $title = get_string('new_version_ilm', 'iassign') . $OUTPUT->help_icon('add_ilm_iassign', 'iassign'); $PAGE->set_title($title); $param = ilm_settings::add_edit_copy_ilm($ilm_id, $action); $mform = new mod_ilm_form(); $mform->set_data($param); if ($mform->is_cancelled()) { close_window(); die; } else if ($formdata = $mform->get_data()) { ilm_settings::copy_new_version_ilm($formdata); close_window(0, true); die; } print($OUTPUT->header()); print($OUTPUT->heading($title)); $mform->display(); print($OUTPUT->footer()); die; } else if ($action == 'copy') { $title = get_string('copy_ilm', 'iassign') . $OUTPUT->help_icon('add_ilm_iassign', 'iassign'); $PAGE->set_title($title); $param = ilm_settings::add_edit_copy_ilm($ilm_id, $action); $mform = new mod_ilm_form(); $mform->set_data($param); if ($mform->is_cancelled()) { close_window(); die; } else if ($formdata = $mform->get_data()) { ilm_settings::copy_new_version_ilm($formdata); close_window(0, true); die; } print($OUTPUT->header()); print($OUTPUT->heading($title)); $mform->display(); print($OUTPUT->footer()); die; } else if ($action == 'add') { $title = get_string('add_ilm_iassign', 'iassign') . $OUTPUT->help_icon('add_ilm_iassign', 'iassign'); $PAGE->set_title($title); $param = ilm_settings::add_edit_copy_ilm($ilm_id, $action); $mform = new mod_ilm_form(); $mform->set_data($param); if ($mform->is_cancelled()) { close_window(); die; } else if ($formdata = $mform->get_data()) { $extension = explode(".", $mform->get_new_filename('file')); if ($extension[count($extension) - 1] == 'ipz') { $retorno = ilm_settings::new_ilm($formdata->file); if($retorno == true) { close_window(0, true); die; } } else print($OUTPUT->notification(get_string('error_upload_ilm', 'iassign'), 'notifyproblem')); } print($OUTPUT->header()); print($OUTPUT->heading($title)); $mform->display(); print($OUTPUT->footer()); die; } else if ($action == 'import') { $title = get_string('import_ilm', 'iassign') . $OUTPUT->help_icon('import_ilm', 'iassign'); $PAGE->set_title($title); $param = new stdClass(); $param->action = $action; $CFG->action_ilm = $action; $mform = new mod_ilm_form(); $mform->set_data($param); if ($mform->is_cancelled()) { close_window(); die; } else if ($formdata = $mform->get_data()) { $extension = explode(".", $mform->get_new_filename('file')); if ($extension[count($extension) - 1] == 'ipz') { $retorno = ilm_settings::import_ilm($formdata->file); if ($retorno == true) { close_window(5, true); die; } } else print($OUTPUT->notification(get_string('error_upload_ilm', 'iassign'), 'notifyproblem')); } print($OUTPUT->header()); print($OUTPUT->heading($title)); $mform->display(); print($OUTPUT->footer()); die; } else if ($action == 'confirm_delete_ilm') { $title = get_string('delete_ilm', 'iassign'); $PAGE->set_title($title); $PAGE->set_pagelayout('base'); $delete_ilm = ilm_settings::confirm_delete_ilm($ilm_id, $ilm_parent); print($OUTPUT->header()); print($OUTPUT->heading($title)); print($delete_ilm); print($OUTPUT->footer()); die; } else if ($action == 'delete') { $title = get_string('delete_ilm', 'iassign'); $PAGE->set_title($title); $PAGE->set_pagelayout('redirect'); $parent = ilm_settings::delete_ilm($ilm_id); if ($parent == null) { $title = get_string('delete_ilm', 'iassign'); $PAGE->set_title($title); $PAGE->set_pagelayout('base'); $delete_ilm = ilm_settings::confirm_delete_ilm($ilm_id, $ilm_parent); print($OUTPUT->header()); print($OUTPUT->heading($title)); print($OUTPUT->notification(get_string('error_folder_permission_denied', 'iassign'), 'notifyproblem')); print($delete_ilm); print($OUTPUT->footer()); die; } if ($parent == 0) redirect(new moodle_url('/admin/settings.php?', array('section' => 'modsettingiassign', 'action' => 'view'))); else redirect(new moodle_url('/admin/settings.php?', array('section' => 'modsettingiassign', 'action' => 'config', 'ilm_id' => $ilm_parent))); } else if ($action == 'confirm_default_ilm') { $title = get_string('confirm_default', 'iassign'); $PAGE->set_title($title); $PAGE->set_pagelayout('base'); $default_ilm = ilm_settings::confirm_default_ilm($ilm_id, $ilm_parent); print($OUTPUT->header()); print($default_ilm); print($OUTPUT->footer()); die; } else if ($action == 'default') { $title = get_string('default_ilm', 'iassign'); $PAGE->set_title($title); $PAGE->set_pagelayout('redirect'); ilm_settings::default_ilm($ilm_id); redirect(new moodle_url('/admin/settings.php?', array('section' => 'modsettingiassign', 'action' => 'config', 'ilm_id' => $ilm_parent))); } else if ($action == 'list') { $title = get_string('list_ilm', 'iassign'); $PAGE->set_title($title); $list_ilm = ilm_settings::list_ilm(); print($OUTPUT->header()); print($OUTPUT->heading($title . $OUTPUT->help_icon('list_ilm', 'iassign'))); print($list_ilm); print($OUTPUT->footer()); die; } else if ($action == 'upgrade') { $title = get_string('upgrade_ilm_title', 'iassign'); $PAGE->set_title($title); $PAGE->set_pagelayout('redirect'); $ilm = ilm_settings::upgrade_ilm($ilm_id); if ($ilm == 0) redirect(new moodle_url('/admin/settings.php?', array('section' => 'modsettingiassign', 'action' => 'view'))); else redirect(new moodle_url('/admin/settings.php?', array('section' => 'modsettingiassign', 'action' => 'config', 'ilm_id' => $ilm))); } else if ($action == 'view') { $iassign_ilm = $DB->get_record('iassign_ilm', array('id' => $ilm_id)); $title = get_string('view_ilm', 'iassign') . $OUTPUT->help_icon('add_ilm_iassign', 'iassign'); $PAGE->set_title($title . ': ' . $iassign_ilm->name . ' ' . $iassign_ilm->version); $view_ilm = ilm_settings::view_ilm($ilm_id, $from); print($OUTPUT->header()); print($OUTPUT->heading($title . ': ' . $iassign_ilm->name . ' ' . $iassign_ilm->version)); print($view_ilm); print($OUTPUT->footer()); die; }