Minor fixes for XHTML compliance
[pfb-moodle.git] / admin / enrol.php
blob7a3b4e9ab46b76cb15725aeaf9cd06a4afa26f30
1 <?PHP // $Id$
2 // enrol.php - allows admin to edit all enrollment variables
3 // Yes, enrol is correct English spelling.
5 require_once('../config.php');
6 require_once($CFG->libdir.'/adminlib.php');
8 $enrol = optional_param('enrol', $CFG->enrol, PARAM_SAFEDIR);
9 $CFG->pagepath = 'enrol';
11 $adminroot = admin_get_root();
12 admin_externalpage_setup('enrolment', $adminroot);
16 require_once("$CFG->dirroot/enrol/enrol.class.php"); /// Open the factory class
18 /// Save settings
20 if ($frm = data_submitted()) {
21 if (!confirm_sesskey()) {
22 error(get_string('confirmsesskeybad', 'error'));
24 if (empty($frm->enable)) {
25 $frm->enable = array();
27 if (empty($frm->default)) {
28 $frm->default = '';
30 if ($frm->default && $frm->default != 'manual' && !in_array($frm->default, $frm->enable)) {
31 $frm->enable[] = $frm->default;
33 asort($frm->enable);
34 $frm->enable = array_merge(array('manual'), $frm->enable); // make sure manual plugin is called first
35 set_config('enrol_plugins_enabled', implode(',', $frm->enable));
36 set_config('enrol', $frm->default);
37 redirect("enrol.php", get_string("changessaved"), 1);
40 /// Print the form
42 $str = get_strings(array('enrolmentplugins', 'users', 'administration', 'settings', 'edit'));
44 admin_externalpage_print_header($adminroot);
46 $modules = get_list_of_plugins("enrol");
47 $options = array();
48 foreach ($modules as $module) {
49 $options[$module] = get_string("enrolname", "enrol_$module");
51 asort($options);
53 print_simple_box(get_string('configenrolmentplugins', 'admin'), 'center', '700');
55 echo "<form $CFG->frametarget id=\"enrolmenu\" method=\"post\" action=\"enrol.php\">";
56 echo "<div>";
57 echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\" />";
59 $table = new stdClass();
60 $table->head = array(get_string('name'), get_string('enable'), get_string('default'), $str->settings);
61 $table->align = array('left', 'center', 'center', 'center');
62 $table->size = array('60%', '', '', '15%');
63 $table->width = '700';
64 $table->data = array();
66 $modules = get_list_of_plugins("enrol");
67 $enabledplugins = explode(',', $CFG->enrol_plugins_enabled);
68 foreach ($modules as $module) {
70 // skip if directory is empty
71 if (!file_exists("$CFG->dirroot/enrol/$module/enrol.php")) {
72 continue;
75 $name = get_string("enrolname", "enrol_$module");
76 $plugin = enrolment_factory::factory($module);
77 $enable = '<input type="checkbox" name="enable[]" value="'.$module.'"';
78 if (in_array($module, $enabledplugins)) {
79 $enable .= ' checked="checked"';
81 if ($module == 'manual') {
82 $enable .= ' disabled="disabled"';
84 $enable .= ' />';
85 if (method_exists($plugin, 'print_entry')) {
86 $default = '<input type="radio" name="default" value="'.$module.'"';
87 if ($CFG->enrol == $module) {
88 $default .= ' checked="checked"';
90 $default .= ' />';
91 } else {
92 $default = '';
94 $table->data[$name] = array($name, $enable, $default,
95 '<a href="enrol_config.php?enrol='.$module.'">'.$str->edit.'</a>');
97 asort($table->data);
99 print_table($table);
101 echo "<div style=\"text-align:center\"><input type=\"submit\" value=\"".get_string("savechanges")."\" /></div>\n";
102 echo "</div>";
103 echo "</form>";
105 admin_externalpage_print_footer($adminroot);