Skip to content

Commit

Permalink
messaging MDL-22320 changed message_popup_window() to work within the…
Browse files Browse the repository at this point in the history
… new plugin system
  • Loading branch information
Andrew Davis committed Jun 29, 2010
1 parent 65c7853 commit 925efca
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/moodlelib.php
Expand Up @@ -8903,13 +8903,13 @@ function moodle_request_shutdown() {
* JavaScript required to pop up the messaging window.
*/
function message_popup_window() {
global $USER, $DB, $PAGE;
global $USER, $DB, $PAGE, $CFG;

if (defined('MESSAGE_WINDOW') || empty($CFG->messaging)) {
return;
}

if (!isset($USER->id) || isguestuser()) {
if (!isloggedin() || isguestuser()) {
return;
}

Expand All @@ -8922,14 +8922,16 @@ function message_popup_window() {
return;
}

if (!get_user_preferences('message_showmessagewindow', 1)) {
return;
}
$sql = "SELECT COUNT(mw.id) FROM {message} m
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));

if ($DB->count_records_select('message', 'useridto = ? AND timecreated > ?', array($USER->id, $USER->message_lastpopup))) {
$USER->message_lastpopup = time();
$PAGE->requires->js_function_call('openpopup', array('/message/index.php', 'message',
'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500', 0));
}
}

Expand Down

0 comments on commit 925efca

Please sign in to comment.