diff --git a/lang/en/message.php b/lang/en/message.php index 6c8ae809c0e..aef3cfa7d09 100644 --- a/lang/en/message.php +++ b/lang/en/message.php @@ -32,7 +32,7 @@ $string['allmine'] = 'All messages to me or from me'; $string['allstudents'] = 'All messages between students in course'; $string['allusers'] = 'All messages from all users'; $string['backupmessageshelp'] = 'If enabled, then instant messages will be included in SITE automated backups'; -$string['beepnewmessage'] = 'Beep on new message'; +$string['beepnewmessage'] = 'Beep when popup notification is displayed'; $string['blockcontact'] = 'Block contact'; $string['blockedmessages'] = '{$a} message(s) to/from blocked users'; $string['blockedusers'] = 'Blocked users ({$a})'; diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 2b3b80bf45a..36178f77d86 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -10358,15 +10358,28 @@ function message_popup_window() { $strgomessage = get_string('gotomessages', 'message'); $strstaymessage = get_string('ignore','admin'); + $notificationsound = null; + $beep = get_user_preferences('message_beepnewmessage', ''); + if (!empty($beep)) { + // Browsers will work down this list until they find something they support. + $sourcetags = html_writer::empty_tag('source', array('src' => $CFG->wwwroot.'/message/bell.wav', 'type' => 'audio/wav')); + $sourcetags .= html_writer::empty_tag('source', array('src' => $CFG->wwwroot.'/message/bell.ogg', 'type' => 'audio/ogg')); + $sourcetags .= html_writer::empty_tag('source', array('src' => $CFG->wwwroot.'/message/bell.mp3', 'type' => 'audio/mpeg')); + $sourcetags .= html_writer::empty_tag('embed', array('src' => $CFG->wwwroot.'/message/bell.wav', 'autostart' => 'true', 'hidden' => 'true')); + + $notificationsound = html_writer::tag('audio', $sourcetags, array('preload' => 'auto', 'autoplay' => 'autoplay')); + } + $url = $CFG->wwwroot.'/message/index.php'; $content = html_writer::start_tag('div', array('id'=>'newmessageoverlay','class'=>'mdl-align')). html_writer::start_tag('div', array('id'=>'newmessagetext')). $strmessages. html_writer::end_tag('div'). - html_writer::start_tag('div', array('id'=>'newmessagelinks')). - html_writer::link($url, $strgomessage, array('id'=>'notificationyes')).'   '. - html_writer::link('', $strstaymessage, array('id'=>'notificationno')). + $notificationsound. + html_writer::start_tag('div', array('id' => 'newmessagelinks')). + html_writer::link($url, $strgomessage, array('id' => 'notificationyes')).'   '. + html_writer::link('', $strstaymessage, array('id' => 'notificationno')). html_writer::end_tag('div'); html_writer::end_tag('div'); diff --git a/message/bell.mp3 b/message/bell.mp3 new file mode 100644 index 00000000000..1aacdb82eaf Binary files /dev/null and b/message/bell.mp3 differ diff --git a/message/bell.ogg b/message/bell.ogg new file mode 100644 index 00000000000..e3f1a5e2d1e Binary files /dev/null and b/message/bell.ogg differ diff --git a/message/edit.php b/message/edit.php index 89c437357f8..394058aea03 100644 --- a/message/edit.php +++ b/message/edit.php @@ -117,7 +117,7 @@ if (($form = data_submitted()) && confirm_sesskey()) { //process general messaging preferences $preferences['message_blocknoncontacts'] = !empty($form->blocknoncontacts)?1:0; - //$preferences['message_beepnewmessage'] = !empty($form->beepnewmessage)?1:0; + $preferences['message_beepnewmessage'] = !empty($form->beepnewmessage)?1:0; // Save all the new preferences to the database if (!set_user_preferences($preferences, $user->id)) { @@ -155,7 +155,7 @@ foreach ($processors as $processor) { //load general messaging preferences $preferences->blocknoncontacts = get_user_preferences( 'message_blocknoncontacts', '', $user->id); -//$preferences->beepnewmessage = get_user_preferences( 'message_beepnewmessage', '', $user->id); +$preferences->beepnewmessage = get_user_preferences( 'message_beepnewmessage', '', $user->id); /// Display page header $strmessaging = get_string('messaging', 'message'); diff --git a/message/renderer.php b/message/renderer.php index 9cc07af4188..4a7be2e260d 100644 --- a/message/renderer.php +++ b/message/renderer.php @@ -352,6 +352,10 @@ class core_message_renderer extends plugin_renderer_base { $output .= html_writer::start_tag('fieldset', array('id' => 'messageprocessor_general', 'class' => 'clearfix')); $output .= html_writer::nonempty_tag('legend', get_string('generalsettings','admin'), array('class' => 'ftoggler')); + $output .= html_writer::start_tag('div'); + $output .= html_writer::checkbox('beepnewmessage', 1, $preferences->beepnewmessage, get_string('beepnewmessage', 'message')); + $output .= html_writer::end_tag('div'); + $output .= html_writer::start_tag('div'); $output .= html_writer::checkbox('blocknoncontacts', 1, $preferences->blocknoncontacts, get_string('blocknoncontacts', 'message')); $output .= html_writer::end_tag('div'); @@ -364,6 +368,7 @@ class core_message_renderer extends plugin_renderer_base { $output .= html_writer::start_tag('div', array('class' => 'mdl-align')); $output .= html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('updatemyprofile'), 'class' => 'form-submit')); $output .= html_writer::end_tag('div'); + $output .= html_writer::end_tag('form'); return $output; }