Skip to content

Commit

Permalink
Message windows now popup from any page
Browse files Browse the repository at this point in the history
  • Loading branch information
moodler committed Dec 30, 2004
1 parent 1693a94 commit e608ddd
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
30 changes: 30 additions & 0 deletions lib/moodlelib.php
Expand Up @@ -4628,5 +4628,35 @@ function html_entity_decode($string) {
}
}

/**
* If new messages are waiting for the current user, then return
* Javascript code to create a popup window
*
* @return string Javascript code
*/
function message_popup_window() {
global $USER;

$popuplimit = 30; // Minimum seconds between popups

if (!defined('MESSAGE_WINDOW')) {
if (isset($USER->id)) {
if (!isset($USER->message_lastpopup)) {
$USER->message_lastpopup = 0;
}
if ((time() - $USER->message_lastpopup) > $popuplimit) { /// It's been long enough
if (get_user_preferences('message_showmessagewindow', 1) == 1) {
if (count_records_select('message', 'useridto = \''.$USER->id.'\' AND timecreated > \''.$USER->message_lastpopup.'\'')) {
$USER->message_lastpopup = time();
return '<script language="JavaScript" type="text/javascript">'."\n openpopup('/message/index.php', 'message', 'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500', 0);\n</script>";
}
}
}
}
}

return '';
}

// vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140:
?>
2 changes: 2 additions & 0 deletions lib/weblib.php
Expand Up @@ -1617,6 +1617,8 @@ function print_header ($title='', $heading='', $navigation='', $focus='', $meta=
$title = strip_tags($title);

include ($CFG->dirroot .'/theme/'. $CFG->theme .'/header.html');

echo message_popup_window();
}

/**
Expand Down
1 change: 1 addition & 0 deletions message/lib.php
Expand Up @@ -3,6 +3,7 @@


define ('MESSAGE_SHORTLENGTH', 300);
define ('MESSAGE_WINDOW', true);


function message_print_contacts() {
Expand Down

0 comments on commit e608ddd

Please sign in to comment.