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';
12 if (!$site = get_site()) {
13 redirect("index.php");
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
28 if ($frm = data_submitted()) {
29 if (empty($frm->enable
)) {
30 $frm->enable
= array();
32 if (empty($frm->default)) {
35 if ($frm->default && $frm->default != 'manual' && !in_array($frm->default, $frm->enable
)) {
36 $frm->enable
[] = $frm->default;
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);
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");
55 foreach ($modules as $module) {
56 $options[$module] = get_string("enrolname", "enrol_$module");
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")) {
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"';
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"';
99 $table->data
[$name] = array($name, $enable, $default,
100 '<a href="enrol_config.php?sesskey='.$USER->sesskey
.'&enrol='.$module.'">'.$str->edit
.'</a>');
106 echo "<center><input type=\"submit\" value=\"".get_string("savechanges")."\"></center>\n";