libdir.'/adminlib.php');
require_once("lib.php");
$id = required_param('id', PARAM_INT);
$mode = optional_param('mode', '', PARAM_ACTION);
$url = new moodle_url('/mod/glossary/formats.php', array('id'=>$id));
if ($mode !== '') {
$url->param('mode', $mode);
}
$PAGE->set_url($url);
admin_externalpage_setup('managemodules'); // this is hacky, tehre should be a special hidden page for it
if ( !$displayformat = $DB->get_record("glossary_formats", array("id"=>$id))) {
print_error('invalidglossaryformat', 'glossary');
}
$form = data_submitted();
if ( $mode == 'visible' and confirm_sesskey()) {
if ( $displayformat ) {
if ( $displayformat->visible ) {
$displayformat->visible = 0;
} else {
$displayformat->visible = 1;
}
$DB->update_record("glossary_formats",$displayformat);
}
redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=modsettingglossary#glossary_formats_header");
die;
} elseif ( $mode == 'edit' and $form and confirm_sesskey()) {
$displayformat->popupformatname = $form->popupformatname;
$displayformat->showgroup = $form->showgroup;
$displayformat->defaultmode = $form->defaultmode;
$displayformat->defaulthook = $form->defaulthook;
$displayformat->sortkey = $form->sortkey;
$displayformat->sortorder = $form->sortorder;
$DB->update_record("glossary_formats",$displayformat);
redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=modsettingglossary#glossary_formats_header");
die;
}
$strmodulename = get_string("modulename", "glossary");
$strdisplayformats = get_string("displayformats","glossary");
echo $OUTPUT->header();
echo $OUTPUT->heading($strmodulename . ': ' . get_string("displayformats","glossary"));
echo $OUTPUT->box(get_string("configwarning", 'admin'), "generalbox boxaligncenter boxwidthnormal");
echo "
";
$yes = get_string("yes");
$no = get_string("no");
echo '