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 $savesettings = optional_param('savesettings', 0, PARAM_BOOL
);
11 $CFG->pagepath
= 'enrol';
13 admin_externalpage_setup('enrolment');
15 if (!isset($CFG->sendcoursewelcomemessage
)) {
16 set_config('sendcoursewelcomemessage', 1);
20 require_once("$CFG->dirroot/enrol/enrol.class.php"); /// Open the factory class
24 if ($frm = data_submitted() and !$savesettings) {
25 if (!confirm_sesskey()) {
26 print_error('confirmsesskeybad', 'error');
28 if (empty($frm->enable
)) {
29 $frm->enable
= array();
31 if (empty($frm->default)) {
34 if ($frm->default && $frm->default != 'manual' && !in_array($frm->default, $frm->enable
)) {
35 $frm->enable
[] = $frm->default;
38 $frm->enable
= array_merge(array('manual'), $frm->enable
); // make sure manual plugin is called first
39 set_config('enrol_plugins_enabled', implode(',', $frm->enable
));
40 set_config('enrol', $frm->default);
41 redirect("enrol.php", get_string("changessaved"), 1);
43 } else if ($frm = data_submitted() and $savesettings) {
44 if (!confirm_sesskey()) {
45 print_error('confirmsesskeybad', 'error');
47 set_config('sendcoursewelcomemessage', required_param('sendcoursewelcomemessage', PARAM_BOOL
));
52 $str = get_strings(array('enrolmentplugins', 'users', 'administration', 'settings', 'edit'));
54 admin_externalpage_print_header();
56 $modules = get_list_of_plugins("enrol");
58 foreach ($modules as $module) {
59 $options[$module] = get_string("enrolname", "enrol_$module");
63 print_simple_box(get_string('configenrolmentplugins', 'admin'), 'center', '700');
65 echo "<form $CFG->frametarget id=\"enrolmenu\" method=\"post\" action=\"enrol.php\">";
67 echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey
."\" />";
69 $table = new stdClass();
70 $table->head
= array(get_string('name'), get_string('enable'), get_string('default'), $str->settings
);
71 $table->align
= array('left', 'center', 'center', 'center');
72 $table->size
= array('60%', '', '', '15%');
73 $table->width
= '700';
74 $table->data
= array();
76 $modules = get_list_of_plugins("enrol");
77 $enabledplugins = explode(',', $CFG->enrol_plugins_enabled
);
78 foreach ($modules as $module) {
80 // skip if directory is empty
81 if (!file_exists("$CFG->dirroot/enrol/$module/enrol.php")) {
85 $name = get_string("enrolname", "enrol_$module");
86 $plugin = enrolment_factory
::factory($module);
87 $enable = '<input type="checkbox" name="enable[]" value="'.$module.'"';
88 if (in_array($module, $enabledplugins)) {
89 $enable .= ' checked="checked"';
91 if ($module == 'manual') {
92 $enable .= ' disabled="disabled"';
95 if (method_exists($plugin, 'print_entry')) {
96 $default = '<input type="radio" name="default" value="'.$module.'"';
97 if ($CFG->enrol
== $module) {
98 $default .= ' checked="checked"';
104 $table->data
[$name] = array($name, $enable, $default,
105 '<a href="enrol_config.php?enrol='.$module.'">'.$str->edit
.'</a>');
111 echo "<div style=\"text-align:center\"><input type=\"submit\" value=\"".get_string("savechanges")."\" /></div>\n";
117 $yesnooptions = array(0=>get_string('no'), 1=>get_string('yes'));
119 echo '<form '.$CFG->frametarget
.' id="adminsettings" method="post" action="enrol.php">';
120 echo '<div class="settingsform clearfix">';
121 print_heading(get_string('commonsettings', 'admin'));
122 echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
123 echo '<input type="hidden" name="savesettings" value="1" />';
125 echo '<div class="form-item clearfix" id="admin-sendcoursewelcomemessage">';
127 echo '<div class="form-label"><label for = "menusendcoursewelcomemessage">' . get_string('sendcoursewelcomemessage', 'admin');
128 echo '<span class="form-shortname">sendcoursewelcomemessage</span>';
129 echo '</label></div>';
130 echo '<div class="form-setting"><div class="form-checkbox defaultsnext">';
131 choose_from_menu($yesnooptions, 'sendcoursewelcomemessage', $CFG->sendcoursewelcomemessage
, '');
132 echo '</div><div class="form-defaultinfo">'.get_string('defaultsettinginfo', 'admin', get_string('yes')).'</div></div>';
133 echo '<div class="form-description">' . get_string('configsendcoursewelcomemessage', 'admin') . '</div>';
138 echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges', 'admin').'" /></div>';
142 admin_externalpage_print_footer();