diff --git a/mod/chat/gui_header_js/chatinput.php b/mod/chat/gui_header_js/chatinput.php
index 67f53eaf489..8e718d4c7a3 100644
--- a/mod/chat/gui_header_js/chatinput.php
+++ b/mod/chat/gui_header_js/chatinput.php
@@ -11,6 +11,18 @@
error('Not logged in!');
}
+ //Get the course theme
+ $course = get_record('course','id',$chatuser->course,'','','','','id,theme');
+ //Set the global course if necessary
+ if (!empty($course->theme)) {
+ global $course;
+ }
+ //Get the user theme
+ $USER = get_record('user','id',$chatuser->userid,'','','','','id, theme');
+
+ //Adjust the prefered theme (main, course, user)
+ theme_setup();
+
chat_force_language($chatuser->lang);
ob_start();
diff --git a/mod/chat/gui_header_js/jsupdate.php b/mod/chat/gui_header_js/jsupdate.php
index 8f91c06a521..49dd0b40f80 100644
--- a/mod/chat/gui_header_js/jsupdate.php
+++ b/mod/chat/gui_header_js/jsupdate.php
@@ -7,11 +7,26 @@
$chat_sid = required_param('chat_sid', PARAM_ALPHANUM);
$chat_lasttime = optional_param('chat_lasttime', 0, PARAM_INT);
+ $chat_lastrow = optional_param('chat_lastrow', 1, PARAM_INT);
if (!$chatuser = get_record('chat_users', 'sid', $chat_sid)) {
error('Not logged in!');
}
+ //Get the course theme
+ $course = get_record('course','id',$chatuser->course,'','','','','id,theme');
+ //Set the course theme if necessary
+ if (!empty($course->theme)) {
+ if (!empty($CFG->allowcoursethemes)) {
+ $CFG->coursetheme = $course->theme;
+ }
+ }
+ //Get the user theme
+ $USER = get_record('user','id',$chatuser->userid,'','','','','id, theme');
+
+ //Adjust the prefered theme (main, course, user)
+ theme_setup();
+
chat_force_language($chatuser->lang);
// force deleting of timed out users if there is a silence in room or just entering
@@ -30,11 +45,24 @@
$chat_lasttime = time() - $CFG->chat_old_ping; //TO DO - any better value??
}
- $refreshurl = "jsupdate.php?chat_sid=$chat_sid&chat_lasttime=$chat_newlasttime"; // no & in url, does not work in header!
$timenow = time();
$groupselect = $chatuser->groupid ? " AND (groupid='".$chatuser->groupid."' OR groupid='0') " : "";
+ $messages = get_records_select("chat_messages",
+ "chatid = '$chatuser->chatid' AND timestamp > '$chat_lasttime' $groupselect",
+ "timestamp ASC");
+
+ if ($messages) {
+ $num = count($messages);
+ } else {
+ $num = 0;
+ }
+
+ $chat_newrow = ($chat_lastrow + $num) % 2;
+
+ $refreshurl = "jsupdate.php?chat_sid=$chat_sid&chat_lasttime=$chat_newlasttime&chat_lastrow=$chat_newrow"; // no & in url, does not work in header!
+
header('Expires: Sun, 28 Dec 1997 09:32:45 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-cache, must-revalidate');
@@ -49,7 +77,7 @@
}
?>
-
+
@@ -58,20 +86,18 @@
if (parent.msg.document.getElementById("msgStarted") == null) {
parent.msg.document.close();
parent.msg.document.open("text/html","replace");
+ parent.msg.document.write("");
parent.msg.document.write("");
parent.msg.document.write("\" />");
parent.msg.document.write("");
parent.msg.document.write("");
- parent.msg.document.write("
");
+ parent.msg.document.write("course ?>\" id=\"mod-chat-gui_header_js-jsupdate\">
");
}
chatid' AND timestamp > '$chat_lasttime' $groupselect",
- "timestamp ASC")) {
+ if (($chat_lasttime != $chat_newlasttime) and $messages) {
if (!$currentuser = get_record('user', 'id', $chatuser->userid)) {
error('User does not exist!');
@@ -79,7 +105,8 @@
$currentuser->description = '';
foreach ($messages as $message) {
- $formatmessage = chat_format_message($message, $chatuser->course, $currentuser);
+ $chat_lastrow = ($chat_lastrow + 1) % 2;
+ $formatmessage = chat_format_message($message, $chatuser->course, $currentuser, $chat_lastrow);
if ($formatmessage->beep) {
$beep = true;
}
diff --git a/mod/chat/gui_header_js/users.php b/mod/chat/gui_header_js/users.php
index 8a5330ba906..16474bea354 100644
--- a/mod/chat/gui_header_js/users.php
+++ b/mod/chat/gui_header_js/users.php
@@ -12,6 +12,20 @@
error('Not logged in!');
}
+ //Get the course theme
+ $course = get_record('course','id',$chatuser->course,'','','','','id,theme');
+ //Set the course theme if necessary
+ if (!empty($course->theme)) {
+ if (!empty($CFG->allowcoursethemes)) {
+ $CFG->coursetheme = $course->theme;
+ }
+ }
+ //Get the user theme
+ $USER = get_record('user','id',$chatuser->userid,'','','','','id, theme');
+
+ //Adjust the prefered theme (main, course, user)
+ theme_setup();
+
chat_force_language($chatuser->lang);
$courseid = $chatuser->course;
diff --git a/mod/chat/lib.php b/mod/chat/lib.php
index a234f3b95f3..0493234778a 100644
--- a/mod/chat/lib.php
+++ b/mod/chat/lib.php
@@ -493,7 +493,7 @@ function chat_update_chat_times($chatid=0) {
}
-function chat_format_message_manually($message, $courseid, $sender, $currentuser) {
+function chat_format_message_manually($message, $courseid, $sender, $currentuser, $chat_lastrow=NULL) {
global $CFG;
$output = New stdClass;
@@ -512,13 +512,20 @@ function chat_format_message_manually($message, $courseid, $sender, $currentuser
$message->picture = "wwwroot/user/view.php?id=$sender->id&course=$courseid\">$message->picture";
}
+ //Calculate the row class
+ if ($chat_lastrow !== NULL) {
+ $rowclass = ' class="r'.$chat_lastrow.'" ';
+ } else {
+ $rowclass = '';
+ }
+
// Start processing the message
if(!empty($message->system)) {
// System event
$output->text = $message->strtime.': '.get_string('message'.$message->message, 'chat', fullname($sender));
- $output->html = '| '.$message->picture.' | ';
- $output->html .= ''.$output->text.' |
';
+ $output->html = '| '.$message->picture.' | ';
+ $output->html .= ''.$output->text.' |
';
if($message->message == 'exit' or $message->message == 'enter') {
$output->refreshusers = true; //force user panel refresh ASAP
@@ -579,17 +586,17 @@ function chat_format_message_manually($message, $courseid, $sender, $currentuser
$output->text = strip_tags($outinfo.': '.$outmain);
- $output->html = "| $message->picture | ";
- $output->html .= "$outinfo";
+ $output->html = "| $message->picture | ";
+ $output->html .= "$outinfo";
if ($outmain) {
$output->html .= ": $outmain";
}
- $output->html .= " | ";
+ $output->html .= " |
";
return $output;
}
-function chat_format_message($message, $courseid, $currentuser) {
+function chat_format_message($message, $courseid, $currentuser, $chat_lastrow=NULL) {
/// Given a message object full of information, this function
/// formats it appropriately into text and html, then
/// returns the formatted data.
@@ -598,7 +605,7 @@ function chat_format_message($message, $courseid, $currentuser) {
return "Error finding user id = $message->userid";
}
- return chat_format_message_manually($message, $courseid, $user, $currentuser);
+ return chat_format_message_manually($message, $courseid, $user, $currentuser, $chat_lastrow);
}