Automatic installer.php lang files by installer_builder (20070202)
[moodle.git] / admin / enrol.php
blob61c9ed3423e6cd8ea41fdf45bed0a16dfc926453
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');
7 $enrol = optional_param('enrol', $CFG->enrol, PARAM_SAFEDIR);
8 $CFG->pagepath = 'enrol';
10 require_login();
12 if (!$site = get_site()) {
13 redirect("index.php");
16 if (!isadmin()) {
17 error("Only the admin can use this page");
20 if (!confirm_sesskey()) {
21 error(get_string('confirmsesskeybad', 'error'));
24 require_once("$CFG->dirroot/enrol/enrol.class.php"); /// Open the factory class
26 /// Save settings
28 if ($frm = data_submitted()) {
29 if (empty($frm->enable)) {
30 $frm->enable = array();
32 if (empty($frm->default)) {
33 $frm->default = '';
35 if ($frm->default && $frm->default != 'manual' && !in_array($frm->default, $frm->enable)) {
36 $frm->enable[] = $frm->default;
38 asort($frm->enable);
39 $frm->enable = array_merge(array('manual'), $frm->enable); // make sure manual plugin is called first
40 set_config('enrol_plugins_enabled', implode(',', $frm->enable));
41 set_config('enrol', $frm->default);
42 redirect("enrol.php?sesskey=$USER->sesskey", get_string("changessaved"), 1);
45 /// Print the form
47 $str = get_strings(array('enrolmentplugins', 'users', 'administration', 'settings', 'edit'));
49 print_header("$site->shortname: $str->enrolmentplugins", "$site->fullname",
50 "<a href=\"index.php\">$str->administration</a> ->
51 <a href=\"users.php\">$str->users</a> -> $str->enrolmentplugins");
53 $modules = get_list_of_plugins("enrol");
54 $options = array();
55 foreach ($modules as $module) {
56 $options[$module] = get_string("enrolname", "enrol_$module");
58 asort($options);
60 print_simple_box(get_string('configenrolmentplugins', 'admin'), 'center', '700');
62 echo "<form target=\"{$CFG->framename}\" name=\"enrolmenu\" method=\"post\" action=\"enrol.php\">";
63 echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\">";
65 $table = new stdClass();
66 $table->head = array(get_string('name'), get_string('enable'), get_string('default'), $str->settings);
67 $table->align = array('left', 'center', 'center', 'center');
68 $table->size = array('60%', '', '', '15%');
69 $table->width = '700';
70 $table->data = array();
72 $modules = get_list_of_plugins("enrol");
73 foreach ($modules as $module) {
75 // skip if directory is empty
76 if (!file_exists("$CFG->dirroot/enrol/$module/enrol.php")) {
77 continue;
80 $name = get_string("enrolname", "enrol_$module");
81 $plugin = enrolment_factory::factory($module);
82 $enable = '<input type="checkbox" name="enable[]" value="'.$module.'"';
83 if (stristr($CFG->enrol_plugins_enabled, $module) !== false) {
84 $enable .= ' checked="checked"';
86 if ($module == 'manual') {
87 $enable .= ' disabled="disabled"';
89 $enable .= ' />';
90 if (method_exists($plugin, 'print_entry')) {
91 $default = '<input type="radio" name="default" value="'.$module.'"';
92 if ($CFG->enrol == $module) {
93 $default .= ' checked="checked"';
95 $default .= ' />';
96 } else {
97 $default = '';
99 $table->data[$name] = array($name, $enable, $default,
100 '<a href="enrol_config.php?sesskey='.$USER->sesskey.'&amp;enrol='.$module.'">'.$str->edit.'</a>');
102 asort($table->data);
104 print_table($table);
106 echo "<center><input type=\"submit\" value=\"".get_string("savechanges")."\"></center>\n";
107 echo "</form>";
109 print_footer();