Skip to content

Commit

Permalink
MDL-29615 message: added the ability for admins to restrict users abi…
Browse files Browse the repository at this point in the history
…lity to set where their email message notifications go
  • Loading branch information
andyjdavis committed Jan 31, 2012
1 parent 216f6d8 commit 84f533b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
4 changes: 3 additions & 1 deletion admin/settings/subsystems.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'), 1));

$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));
Expand All @@ -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));
}
}
2 changes: 2 additions & 0 deletions lang/en/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
Expand Down Expand Up @@ -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';
Expand Down
1 change: 1 addition & 0 deletions message/output/email/lang/en/message_email.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
13 changes: 10 additions & 3 deletions message/output/email/message_output_email.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)) {
Expand Down

0 comments on commit 84f533b

Please sign in to comment.