require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php');
- $enrol = optional_param('enrol', $CFG->enrol, PARAM_SAFEDIR);
+ $enrol = optional_param('enrol', $CFG->enrol, PARAM_SAFEDIR);
+ $savesettings = optional_param('savesettings', 0, PARAM_BOOL);
+
$CFG->pagepath = 'enrol';
admin_externalpage_setup('enrolment');
+ if (!isset($CFG->sendcoursewelcomemessage)) {
+ set_config('sendcoursewelcomemessage', 1);
+ }
require_once("$CFG->dirroot/enrol/enrol.class.php"); /// Open the factory class
/// Save settings
- if ($frm = data_submitted()) {
+ if ($frm = data_submitted() and !$savesettings) {
if (!confirm_sesskey()) {
print_error('confirmsesskeybad', 'error');
}
set_config('enrol_plugins_enabled', implode(',', $frm->enable));
set_config('enrol', $frm->default);
redirect("enrol.php", get_string("changessaved"), 1);
+
+ } else if ($frm = data_submitted() and $savesettings) {
+ if (!confirm_sesskey()) {
+ print_error('confirmsesskeybad', 'error');
+ }
+ set_config('sendcoursewelcomemessage', required_param('sendcoursewelcomemessage', PARAM_BOOL));
}
/// Print the form
echo "</div>";
echo "</form>";
+ echo '<hr />';
+
+ $yesnooptions = array(0=>get_string('no'), 1=>get_string('yes'));
+
+ echo '<form '.$CFG->frametarget.' id="adminsettings" method="post" action="enrol.php">';
+ echo '<div class="settingsform clearfix">';
+ print_heading(get_string('commonsettings', 'admin'));
+ echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
+ echo '<input type="hidden" name="savesettings" value="1" />';
+ echo '<fieldset>';
+ echo '<div class="form-item clearfix" id="admin-sendcoursewelcomemessage">';
+
+ echo '<div class="form-label"><label for = "menusendcoursewelcomemessage">' . get_string('sendcoursewelcomemessage', 'admin');
+ echo '<span class="form-shortname">sendcoursewelcomemessage</span>';
+ echo '</label></div>';
+ echo '<div class="form-setting"><div class="form-checkbox defaultsnext">';
+ choose_from_menu($yesnooptions, 'sendcoursewelcomemessage', $CFG->sendcoursewelcomemessage, '');
+ echo '</div><div class="form-defaultinfo">'.get_string('defaultsettinginfo', 'admin', get_string('yes')).'</div></div>';
+ echo '<div class="form-description">' . get_string('configsendcoursewelcomemessage', 'admin') . '</div>';
+ echo '</div>';
+
+ echo '</fieldset>';
+
+ echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges', 'admin').'" /></div>';
+ echo '</div>';
+ echo '</form>';
+
admin_externalpage_print_footer();
?>
$ADMIN->add('courses', new admin_externalpage('coursemgmt', get_string('coursemgmt', 'admin'), $CFG->wwwroot . '/course/index.php?categoryedit=on','moodle/category:update'));
- $ADMIN->add('courses', new admin_externalpage('enrolment', get_string('enrolments'), $CFG->wwwroot . '/'.$CFG->admin.'/enrol.php'));
+ $ADMIN->add('courses', new admin_enrolment_page());
// "courserequests" settingpage
$temp = new admin_settingpage('courserequest', get_string('courserequest'));
$string['configsectionstats'] = 'Statistics';
$string['configsectionuser'] = 'User';
$string['configsecureforms'] = 'Moodle can use an additional level of security when accepting data from web forms. If this is enabled, then the browser\'s HTTP_REFERER variable is checked against the current form address. In a very few cases this can cause problems if the user is using a firewall (eg Zonealarm) configured to strip HTTP_REFERER from their web traffic. Symptoms are getting \'stuck\' on a form. If your users are having problems with the login page (for example) you might want to disable this setting, although it might leave your site more open to brute-force password attacks. If in doubt, leave this set to \'Yes\'.';
+$string['configsendcoursewelcomemessage'] = 'If enabled users receive welcome message after they are enrolled into course.';
$string['configsessioncookie'] = 'This setting customises the name of the cookie used for Moodle sessions. This is optional, and only useful to avoid cookies being confused when there is more than one copy of Moodle running within the same web site.';
$string['configsessioncookiepath'] = 'If you need to change where browsers send the Moodle cookies, you can change this setting to specify a subdirectory of your web site. Otherwise the default \'/\' should be fine.';
$string['configsessiontimeout'] = 'If people logged in to this site are idle for a long time (without loading pages) then they are automatically logged out (their session is ended). This variable specifies how long this time should be.';
$string['sectionerror'] = 'Section Error!';
$string['secureforms'] = 'Use additional form security';
$string['security'] = 'Security';
+$string['sendcoursewelcomemessage'] = 'Send course welcome message';
$string['server'] = 'Server';
$string['serverchecks'] = 'Server Checks';
$string['serverlimit'] = 'Server Limit';
}
}
+/**
+ * Enrolment manage page
+ */
+class admin_enrolment_page extends admin_externalpage {
+ public function admin_enrolment_page() {
+ global $CFG;
+ parent::admin_externalpage('enrolment', get_string('enrolments'), $CFG->wwwroot . '/'.$CFG->admin.'/enrol.php');
+ }
+
+ function search($query) {
+ if ($result = parent::search($query)) {
+ return $result;
+ }
+
+ $found = false;
+
+ if ($modules = get_list_of_plugins('enrol')) {
+ $textlib = textlib_get_instance();
+ foreach ($modules as $plugin) {
+ if (strpos($plugin, $query) !== false) {
+ $found = true;
+ break;
+ }
+ $strmodulename = get_string('enrolname', "enrol_$plugin");
+ if (strpos($textlib->strtolower($strmodulename), $query) !== false) {
+ $found = true;
+ break;
+ }
+ }
+ }
+ //ugly harcoded hacks
+ if (strpos('sendcoursewelcomemessage', $query) !== false) {
+ $found = true;
+ } else if (strpos($textlib->strtolower(get_string('sendcoursewelcomemessage', 'admin')), $query) !== false) {
+ $found = true;
+ } else if (strpos($textlib->strtolower(get_string('configsendcoursewelcomemessage', 'admin')), $query) !== false) {
+ $found = true;
+ } else if (strpos($textlib->strtolower(get_string('configenrolmentplugins', 'admin')), $query) !== false) {
+ $found = true;
+ }
+ if ($found) {
+ $result = new object();
+ $result->page = $this;
+ $result->settings = array();
+ return array($this->name => $result);
+ } else {
+ return array();
+ }
+ }
+}
+
/**
* Blocks manage page
*/
function email_welcome_message_to_user($course, $user=NULL) {
global $CFG, $USER;
+ if (isset($CFG->sendcoursewelcomemessage) and !$CFG->sendcoursewelcomemessage) {
+ return;
+ }
+
if (empty($user)) {
if (!isloggedin()) {
return false;