Skip to content
Permalink
Browse files

Merge branch 'MDL-29615_control_override_email2' of git://github.com/…

…andyjdavis/moodle
  • Loading branch information...
stronk7 committed Feb 1, 2012
2 parents 03a6727 + 8900213 commit 26ed4e73ebdc80f25d77756644158d4de5f852bd
@@ -20,6 +20,8 @@
$options = array(DAYSECS=>new lang_string('secondstotime86400'), WEEKSECS=>new lang_string('secondstotime604800'), 2620800=>new lang_string('nummonths', 'moodle', 1), 15724800=>new lang_string('nummonths', 'moodle', 6),0=>new lang_string('never'));
$optionalsubsystems->add(new admin_setting_configselect('messagingdeletereadnotificationsdelay', new lang_string('messagingdeletereadnotificationsdelay', 'admin'), new lang_string('configmessagingdeletereadnotificationsdelay', 'admin'), 604800, $options));
$optionalsubsystems->add(new admin_setting_configcheckbox('messagingallowemailoverride', new lang_string('messagingallowemailoverride', 'admin'), new lang_string('configmessagingallowemailoverride','admin'), 0));
$optionalsubsystems->add(new admin_setting_configcheckbox('enablestats', new lang_string('enablestats', 'admin'), new lang_string('configenablestats', 'admin'), 0));
$optionalsubsystems->add(new admin_setting_configcheckbox('enablerssfeeds', new lang_string('enablerssfeeds', 'admin'), new lang_string('configenablerssfeeds', 'admin'), 0));
@@ -45,4 +47,4 @@
$optionalsubsystems->add(new admin_setting_configcheckbox('enableplagiarism', new lang_string('enableplagiarism','plagiarism'), new lang_string('configenableplagiarism','plagiarism'), 0));
$optionalsubsystems->add(new admin_setting_configcheckbox('enablecssoptimiser', new lang_string('enablecssoptimiser','admin'), new lang_string('enablecssoptimiser_desc','admin'), 0));
}
}
@@ -242,6 +242,7 @@
$string['configmemcachedhosts'] = 'For memcached. Comma-separated list of hosts that are running the memcached daemon. Use IP addresses to avoid DNS latency. memcached does not behave well if you add/remove hosts on a running setup.';
$string['configmemcachedpconn'] = 'For memcached. Use persistent connections. Use carefully -- it can make Apache/PHP crash after a restart of the memcached daemon.';
$string['configmessaging'] = 'Should the messaging system between site users be enabled?';
$string['configmessagingallowemailoverride'] = 'Allow users to have email message notifications sent to an email address other than the email address in their profile';
$string['configmessaginghidereadnotifications'] = 'Hide read notifications of events like forum posts when viewing messaging history';
$string['configmessagingdeletereadnotificationsdelay'] = 'Read notifications can be deleted to save space. How long after a notification is read can it be deleted?';
$string['configminpassworddigits'] = 'Passwords must have at least these many digits.';
@@ -662,6 +663,7 @@
$string['memcachedhosts'] = 'memcached hosts';
$string['memcachedpconn'] = 'memcached use persistent connections';
$string['messaging'] = 'Enable messaging system';
$string['messagingallowemailoverride'] = 'Notification email override';
$string['messaginghidereadnotifications'] = 'Hide read notifications';
$string['messagingdeletereadnotificationsdelay'] = 'Delete read notifications';
$string['minpassworddigits'] = 'Digits';
@@ -135,6 +135,16 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2012020200.03);
}
if ($oldversion < 2012020200.06) {
// Previously we always allowed users to override their email address via the messaging system
// We have now added a setting to allow admins to turn this this ability on and off
// While this setting defaults to 0 (off) we're setting it to 1 (on) to maintain the behaviour for upgrading sites
set_config('messagingallowemailoverride', 1);
// Main savepoint reached
upgrade_main_savepoint(true, 2012020200.06);
}
return true;
}
@@ -32,6 +32,7 @@
$string['configsmtpmaxbulk'] = 'Maximum number of messages sent per SMTP session. Grouping messages may speed up the sending of emails. Values lower than 2 force creation of new SMTP session for each email.';
$string['configsmtpuser'] = 'If you have specified an SMTP server above, and the server requires authentication, then enter the username and password here.';
$string['email'] = 'Send email notifications to';
$string['ifemailleftempty'] = 'Leave empty to send notifications to {$a}';
$string['mailnewline'] = 'Newline characters in mail';
$string['noreplyaddress'] = 'No-reply address';
$string['pluginname'] = 'Email';
@@ -57,7 +57,10 @@ function send_message($eventdata) {
//check if the recipient has a different email address specified in their messaging preferences Vs their user profile
$emailmessagingpreference = get_user_preferences('message_processor_email_email', null, $eventdata->userto);
$emailmessagingpreference = clean_param($emailmessagingpreference, PARAM_EMAIL);
if (!empty($emailmessagingpreference)) {
// If the recipient has set an email address in their preferences use that instead of the one in their profile
// but only if overriding the notification email address is allowed
if (!empty($emailmessagingpreference) && !empty($CFG->messagingallowemailoverride)) {
//clone to avoid altering the actual user object
$recipient = clone($eventdata->userto);
$recipient->email = $emailmessagingpreference;
@@ -74,13 +77,17 @@ function send_message($eventdata) {
* @param object $mform preferences form class
*/
function config_form($preferences){
global $USER, $OUTPUT;
global $USER, $OUTPUT, $CFG;
if (empty($CFG->messagingallowemailoverride)) {
return null;
}
$inputattributes = array('size'=>'30', 'name'=>'email_email', 'value'=>$preferences->email_email);
$string = get_string('email','message_email') . ': ' . html_writer::empty_tag('input', $inputattributes);
if (empty($preferences->email_email) && !empty($preferences->userdefaultemail)) {
$string .= ' ('.get_string('default').': '.s($preferences->userdefaultemail).')';
$string .= get_string('ifemailleftempty', 'message_email', $preferences->userdefaultemail);
}
if (!empty($preferences->email_email) && !validate_email($preferences->email_email)) {
@@ -30,7 +30,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2012020200.05; // YYYYMMDD = weekly release date of this DEV branch
$version = 2012020200.06; // YYYYMMDD = weekly release date of this DEV branch
// RR = release increments - 00 in DEV branches
// .XX = incremental changes

0 comments on commit 26ed4e7

Please sign in to comment.
You can’t perform that action at this time.