]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-15846 add option to prevent course welcome emails + support for searching in...
authorskodak <skodak>
Sat, 26 Jul 2008 16:50:33 +0000 (16:50 +0000)
committerskodak <skodak>
Sat, 26 Jul 2008 16:50:33 +0000 (16:50 +0000)
admin/enrol.php
admin/settings/courses.php
lang/en_utf8/admin.php
lib/adminlib.php
lib/moodlelib.php

index 14b75d6b10d09432857d55c10108c2e71560a0da..707e183b655e154380865cc95068c08aa393c802 100644 (file)
@@ -5,18 +5,23 @@
     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();
 
 ?>
index 42f804bd30b87300bc674d33232f6613d9cca6e3..60f10c5ccc92e7b3e74dd6440920d47182cb5ed2 100644 (file)
@@ -9,7 +9,7 @@ if ($hassiteconfig
 
     $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'));
index 4d794c81cd14fc703996077a957bd7ea58ee2fa2..5c9595fc6399eafe02bcca4a867734602560eba2 100644 (file)
@@ -215,6 +215,7 @@ $string['configsectionsecurity'] = 'Security';
 $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.';
@@ -643,6 +644,7 @@ $string['searchinsettings'] = 'Search in settings';
 $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';
index e5b5f49c349268e570f845952fba9a3a64699bfc..91643f85599f0fae5939f80a28ff480d84bfca42 100644 (file)
@@ -3725,6 +3725,57 @@ class admin_page_managemods extends admin_externalpage {
     }
 }
 
+/**
+ * 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
  */
index 24630a52be841043e3f4aa23b892305870833a5a..e7edc4fc062121a81e1b1bdcfaaba7cf025769a6 100644 (file)
@@ -4390,6 +4390,10 @@ function email_is_not_allowed($email) {
 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;