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

This commit is contained in:
Eloy Lafuente (stronk7) 2012-02-01 13:17:08 +01:00
commit 26ed4e73eb
6 changed files with 27 additions and 5 deletions

View File

@ -20,6 +20,8 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
$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')); $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_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('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)); $optionalsubsystems->add(new admin_setting_configcheckbox('enablerssfeeds', new lang_string('enablerssfeeds', 'admin'), new lang_string('configenablerssfeeds', 'admin'), 0));

View File

@ -242,6 +242,7 @@ $string['configmaxevents'] = 'Events to Lookahead';
$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['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['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['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['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['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.'; $string['configminpassworddigits'] = 'Passwords must have at least these many digits.';
@ -662,6 +663,7 @@ $string['mediapluginyoutube'] = 'Enable YouTube links filter';
$string['memcachedhosts'] = 'memcached hosts'; $string['memcachedhosts'] = 'memcached hosts';
$string['memcachedpconn'] = 'memcached use persistent connections'; $string['memcachedpconn'] = 'memcached use persistent connections';
$string['messaging'] = 'Enable messaging system'; $string['messaging'] = 'Enable messaging system';
$string['messagingallowemailoverride'] = 'Notification email override';
$string['messaginghidereadnotifications'] = 'Hide read notifications'; $string['messaginghidereadnotifications'] = 'Hide read notifications';
$string['messagingdeletereadnotificationsdelay'] = 'Delete read notifications'; $string['messagingdeletereadnotificationsdelay'] = 'Delete read notifications';
$string['minpassworddigits'] = 'Digits'; $string['minpassworddigits'] = 'Digits';

View File

@ -135,6 +135,16 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2012020200.03); 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; return true;
} }

View File

@ -32,6 +32,7 @@ $string['configsmtphosts'] = 'Give the full name of one or more local SMTP serve
$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['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['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['email'] = 'Send email notifications to';
$string['ifemailleftempty'] = 'Leave empty to send notifications to {$a}';
$string['mailnewline'] = 'Newline characters in mail'; $string['mailnewline'] = 'Newline characters in mail';
$string['noreplyaddress'] = 'No-reply address'; $string['noreplyaddress'] = 'No-reply address';
$string['pluginname'] = 'Email'; $string['pluginname'] = 'Email';

View File

@ -57,7 +57,10 @@ class message_output_email extends message_output {
//check if the recipient has a different email address specified in their messaging preferences Vs their user profile //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 = get_user_preferences('message_processor_email_email', null, $eventdata->userto);
$emailmessagingpreference = clean_param($emailmessagingpreference, PARAM_EMAIL); $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 //clone to avoid altering the actual user object
$recipient = clone($eventdata->userto); $recipient = clone($eventdata->userto);
$recipient->email = $emailmessagingpreference; $recipient->email = $emailmessagingpreference;
@ -74,13 +77,17 @@ class message_output_email extends message_output {
* @param object $mform preferences form class * @param object $mform preferences form class
*/ */
function config_form($preferences){ 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); $inputattributes = array('size'=>'30', 'name'=>'email_email', 'value'=>$preferences->email_email);
$string = get_string('email','message_email') . ': ' . html_writer::empty_tag('input', $inputattributes); $string = get_string('email','message_email') . ': ' . html_writer::empty_tag('input', $inputattributes);
if (empty($preferences->email_email) && !empty($preferences->userdefaultemail)) { 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)) { if (!empty($preferences->email_email) && !validate_email($preferences->email_email)) {

View File

@ -30,7 +30,7 @@
defined('MOODLE_INTERNAL') || die(); 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 // RR = release increments - 00 in DEV branches
// .XX = incremental changes // .XX = incremental changes