예제 #1
0
파일: edit.php 프로젝트: nadavkav/MoodleTAO
            $course->enrolstartdisabled = 0;
        }
        if ($course->enrolenddate) {
            $course->enrolenddisabled = 0;
        }
    }
}
/// first create the form
$editform = new course_edit_form('edit.php', compact('course', 'category'));
// now override defaults if course already exists
if (!empty($course)) {
    $course->enrolpassword = $course->password;
    // we need some other name for password field MDL-9929
    $editform->set_data($course);
}
if ($editform->is_cancelled()) {
    if (empty($course)) {
        redirect($CFG->wwwroot);
    } else {
        redirect($CFG->wwwroot . '/course/view.php?id=' . $course->id);
    }
} else {
    if ($data = $editform->get_data()) {
        $data->password = $data->enrolpassword;
        // we need some other name for password field MDL-9929
        /// process data if submitted
        //preprocess data
        if ($data->enrolstartdisabled) {
            $data->enrolstartdate = 0;
        }
        if ($data->enrolenddisabled) {
// Build the nav bar.
company_admin_fix_breadcrumb($PAGE, $linktext, $linkurl);
$title = 'edit_course_shopsettings';
if ($isadding) {
    $title = 'addnewcourse';
}
$PAGE->navbar->add(get_string($title, 'block_iomad_commerce'));
$blockpage = new blockpage($PAGE, $OUTPUT, 'iomad_commerce', 'block', $title);
$blockpage->setup($urlparams);
require_login(null, false);
// Adds to $PAGE, creates $OUTPUT.
/* next line copied from /course/edit.php */
$editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $CFG->maxbytes, 'trusttext' => false, 'noclean' => true);
$mform = new course_edit_form($PAGE->url, $isadding, $shopsettingsid, $course, $priceblocks, $editoroptions);
$mform->set_data($shopsettings);
if ($mform->is_cancelled()) {
    redirect($companylist);
} else {
    if ($data = $mform->get_data()) {
        $data->userid = $USER->id;
        $transaction = $DB->start_delegated_transaction();
        if ($isadding) {
            $shopsettingsid = $DB->insert_record('course_shopsettings', $data);
        } else {
            $data->id = $shopsettingsid;
            $DB->update_record('course_shopsettings', $data);
        }
        if (!isset($data->courseid) && isset($course->id)) {
            $data->courseid = $course->id;
        }
        $DB->delete_records('course_shopblockprice', array('courseid' => $data->courseid));