Skip to content

Commit

Permalink
messaging MDL-22320 switched messaging over to using an overlay rathe…
Browse files Browse the repository at this point in the history
…r than a popup to notify the user of new messages
  • Loading branch information
Andrew Davis committed Jun 29, 2010
1 parent efba703 commit 9bd0aff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
23 changes: 18 additions & 5 deletions lib/moodlelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -8903,7 +8903,7 @@ function moodle_request_shutdown() {
* JavaScript required to pop up the messaging window.
*/
function message_popup_window() {
global $USER, $DB, $PAGE, $CFG;
global $USER, $DB, $PAGE, $CFG, $SITE;

if (defined('MESSAGE_WINDOW') || empty($CFG->messaging)) {
return;
Expand All @@ -8926,10 +8926,23 @@ function message_popup_window() {
JOIN {message_working} mw ON m.id=mw.unreadmessageid
JOIN {message_processors} p ON mw.processorid=p.id
WHERE m.useridto = :userid AND m.timecreated > :ts AND p.name='popup'";
if ($DB->count_records_sql($sql, array('userid'=>$USER->id, 'ts'=>$USER->message_lastpopup))) {

$jsobj = array('url'=>'/message/index.php?ts='.$USER->message_lastpopup, 'name'=>'message', 'options'=>'menubar=0,location=0,scrollbars,status,resizable,width=400', 'fullscreen'=>0);
$PAGE->requires->js_function_call('openpopup', array(null, $jsobj));
$count = $DB->count_records_sql($sql, array('userid'=>$USER->id, 'ts'=>$USER->message_lastpopup));
if ($count) {

$strmessages = get_string('unreadmessages', 'message', $count);
$strgomessage = get_string('gotomessages', 'message');
$strstaymessage = get_string('ignore','admin');

$content = html_writer::start_tag('div', array('id'=>'newmessageoverlay')).
html_writer::start_tag('div', array('id'=>'newmessagemessage')).
$strmessages.
html_writer::end_tag('div').
html_writer::tag('button', $strgomessage, array('id'=>'buttonreadmessage')).' '.
html_writer::tag('button', $strstaymessage, array('id'=>'buttondontreadmessage')).
html_writer::end_tag('div');

$url = $CFG->wwwroot.'/message/contacts_messages.php';
$PAGE->requires->js_init_call('M.core_message.init_notification', array('', $content, $url));

$USER->message_lastpopup = time();
}
Expand Down
2 changes: 2 additions & 0 deletions theme/standard/style/message.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,5 @@ table.message .searchresults td {padding:5px;}
.messagesearchresults {margin-bottom:40px;}
.messagesearchresults td {padding:0px 10px 0px 20px;}
.messagesearchresults td span {white-space:nowrap;}

#newmessageoverlay {background-color:LightGrey;padding:20px;}

0 comments on commit 9bd0aff

Please sign in to comment.