function display_savenew() { $courseid = $this->optional_param('cfccourseid', 0, PARAM_INT); $target = $this->get_new_page(array('action' => 'savenew', 'cfccourseid' => $courseid)); $form = new $this->form_class($target->url); if ($form->is_cancelled()) { //go back to course and list programs $target = new coursecurriculumpage(array('id' => $courseid, 'action' => 'default', 's' => 'crscurr')); redirect($target->url); return; } $data = $form->get_data(); if ($data) { $obj = new $this->data_class(); $obj->set_from_data($data); $obj->save(); $course = new course($data->courseid); $course->add_course_to_curricula(array($obj->id)); $page = new coursecurriculumpage(); $params = array('action' => 'default', 'id' => $data->courseid); $target = $page->get_new_page($params); redirect($target->url, ucwords($obj->get_verbose_name()) . ' ' . $obj->__toString() . ' saved.'); } else { // Validation must have failed, redisplay form $form->display(); } }
function action_savenew() { $courseid = $this->required_param('courseid', PARAM_INT); $target = $this->get_new_page(array('action' => 'add')); $form = new $this->form_class($target->get_moodle_url()); if ($form->is_cancelled()) { $coursepage = new coursecurriculumpage(); $target = $coursepage->get_new_page(array('id' => $courseid)); redirect($target->get_url(), '', 0.1); } $data = $form->get_data(); if ($data) { $obj = new $this->data_class(); $obj->set_from_data($data); $obj->add(); $course = new course($data->courseid); $course->add_course_to_curricula(array($obj->id)); $coursepage = new coursepage(); $target = $coursepage->get_new_page(array('action' => 'view', 'id' => $course->id)); redirect($target->get_url(), ucwords($obj->get_verbose_name()) . ' ' . $obj->to_string() . ' saved.'); } else { // Validation must have failed, redisplay form $form->display(); } }