示例#1
0
$header = clampmail::_s('config');
$PAGE->set_context($context);
$PAGE->set_course($course);
$PAGE->set_url('/blocks/clampmail/config.php', array('courseid' => $courseid));
$PAGE->set_title($blockname . ': ' . $header);
$PAGE->set_heading($blockname . ': ' . $header);
$PAGE->navbar->add($header);
$PAGE->set_pagetype($blockname);
$PAGE->set_pagelayout('standard');
$changed = false;
if ($reset) {
    $changed = true;
    clampmail::default_config($courseid);
}
$roles = $DB->get_records_menu('role', null, 'sortorder ASC', 'id, shortname');
$form = new config_form(null, array('courseid' => $courseid, 'roles' => $roles));
if ($data = $form->get_data()) {
    $config = get_object_vars($data);
    unset($config['save'], $config['courseid']);
    $config['roleselection'] = implode(',', $config['roleselection']);
    clampmail::save_config($courseid, $config);
    $changed = true;
}
$config = clampmail::load_config($courseid);
$config['roleselection'] = explode(',', $config['roleselection']);
$form->set_data($config);
echo $OUTPUT->header();
echo $OUTPUT->heading($header);
echo $OUTPUT->box_start();
if ($changed) {
    echo $OUTPUT->notification(get_string('changessaved'), 'notifysuccess');
示例#2
0
文件: config.php 项目: rrusso/EARS
 *   Date: 2/15/2008
 *   Louisiana State University
 *
 *   Moodle form for the Courseprefs config
 */
require_once '../../config.php';
require_once "{$CFG->dirroot}/blocks/moodleblock.class.php";
require_once 'config_form.php';
require_once $CFG->libdir . '/accesslib.php';
require_once 'classes/CoursePrefsConfig.php';
require_login();
//can user alter courseprefs config?
if (!is_siteadmin($USER->id)) {
    error(get_string('no_permission', 'block_courseprefs'));
}
$form = new config_form();
if ($form->is_cancelled()) {
    redirect("{$CFG->wwwroot}");
}
if ($data = $form->get_data()) {
    $configs = CoursePrefsConfig::findAll();
    foreach ($form->form_values as $key => $value) {
        if (!$configs[$key]) {
            $config = new CoursePrefsConfig($key, $value);
        } else {
            if ($configs[$key]) {
                $config = $configs[$key];
                $config->setValue($value);
            } else {
                continue;
            }