示例#1
0
$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');
}
$form->display();
echo $OUTPUT->box_end();
echo $OUTPUT->footer();
示例#2
0
文件: config.php 项目: rrusso/EARS
        if (!$configs[$key]) {
            $config = new CoursePrefsConfig($key, $value);
        } else {
            if ($configs[$key]) {
                $config = $configs[$key];
                $config->setValue($value);
            } else {
                continue;
            }
        }
        $config->save();
    }
    //Redirect back
    redirect("{$CFG->wwwroot}");
} else {
    if (!$form->is_submitted()) {
        //Load the form with the correct values
        $form_data = array();
        $configs = CoursePrefsConfig::findAll();
        foreach ($configs as $config) {
            $form_data[$config->getName()] = $config->getValue();
        }
        $form->set_data($form_data);
    }
}
$strcourseprefsconf = get_string('blockname', 'block_courseprefs');
$navigation = array(array('name' => $strcourseprefsconf, 'link' => '', 'type' => 'title'), array('name' => $strcourseprefsconf . ' Settings', 'link' => '', 'type' => 'title'));
print_header_simple($strcourseprefsconf, '', build_navigation($navigation));
print_heading('Configuring a ' . $strcourseprefsconf . ' block');
$form->display();
print_footer();