예제 #1
0
파일: edit.php 프로젝트: nadavkav/MoodleTAO
        } else {
            if (!update_course($data)) {
                print_error('coursenotupdated');
            }
            redirect($CFG->wwwroot . "/course/view.php?id={$course->id}");
        }
    }
}
/// Print the form
$site = get_site();
$streditcoursesettings = get_string("editcoursesettings");
$straddnewcourse = get_string("addnewcourse");
$stradministration = get_string("administration");
$strcategories = get_string("categories");
$navlinks = array();
if (!empty($course)) {
    $navlinks[] = array('name' => $streditcoursesettings, 'link' => null, 'type' => 'misc');
    $title = $streditcoursesettings;
    $fullname = $course->fullname;
} else {
    $navlinks[] = array('name' => $stradministration, 'link' => "{$CFG->wwwroot}/{$CFG->admin}/index.php", 'type' => 'misc');
    $navlinks[] = array('name' => $strcategories, 'link' => 'index.php', 'type' => 'misc');
    $navlinks[] = array('name' => $straddnewcourse, 'link' => null, 'type' => 'misc');
    $title = "{$site->shortname}: {$straddnewcourse}";
    $fullname = $site->fullname;
}
$navigation = build_navigation($navlinks);
print_header($title, $fullname, $navigation, $editform->focus());
print_heading($streditcoursesettings);
$editform->display();
print_footer($course);
        if (!isset($data->courseid) && isset($course->id)) {
            $data->courseid = $course->id;
        }
        $DB->delete_records('course_shopblockprice', array('courseid' => $data->courseid));
        foreach ($priceblocks as $priceblock) {
            $priceblock->courseid = $data->courseid;
            $priceblock->currency = $_POST["currency"];
            $DB->insert_record('course_shopblockprice', $priceblock, false, false);
        }
        // Delete course_shoptag records.
        $DB->delete_records('course_shoptag', array('courseid' => $data->courseid));
        // Find shoptag ids.
        $tags = preg_split('/\\s*,\\s*/', $data->tags);
        $newcourseshoptagrecord = new stdClass();
        $newcourseshoptagrecord->courseid = $data->courseid;
        foreach ($tags as $tag) {
            if (!($st = $DB->get_record('shoptag', array('tag' => $tag)))) {
                $st = new stdClass();
                $st->id = $DB->insert_record('shoptag', (object) array('tag' => $tag), true);
            }
            $newcourseshoptagrecord->shoptagid = $st->id;
            $DB->insert_record('course_shoptag', $newcourseshoptagrecord);
        }
        $transaction->allow_commit();
        redirect($companylist);
    } else {
        $blockpage->display_header();
        $mform->display();
        echo $OUTPUT->footer();
    }
}