* @param int $size Size in pixels. Special values are (true/1 = 100px) and (false/0 = 35px) for backward compatability
* @param boolean $return If false print picture to current page, otherwise return the output as string
* @param boolean $link Enclose printed image in a link to view specified course?
+ * @param string $target link target attribute
+ * @param boolean $alttext use username or userspecified text in image alt attribute
* return string
* @todo Finish documenting this function
*/
-function print_user_picture($userid, $courseid, $picture, $size=0, $return=false, $link=true, $target='') {
+function print_user_picture($userid, $courseid, $picture, $size=0, $return=false, $link=true, $target='', $alttext=true) {
global $CFG;
if ($link) {
$class .= " defaultuserpic";
$src = "$CFG->pixpath/u/$file.png\"";
}
- if ($user = get_record('user','id',$userid)) {
+ if (!$alttext) {
+ $imagealt = '';
+ } else if ($user = get_record('user','id',$userid)) {
if (!empty($user->imagealt)) {
$imagealt = $user->imagealt;
} else {
$imagealt = get_string('pictureof','',fullname($user));
}
}
+
$output .= "<img class=\"$class\" align=\"middle\" src=\"$src".
" border=\"0\" width=\"$size\" height=\"$size\" alt=\"".s($imagealt)."\" />";
if ($link) {
error('Could not log in to chat room!!');
}
- if (!$chatuser = get_record('chat_users', 'sid', $chat_sid)) {
- error('Not logged in!');
- }
-
if (!$chatusers = chat_get_users($chat->id, $groupid)) {
error(get_string('errornousers', 'chat'));
}
- set_field('chat_users', 'lastping', time(), 'id', $USER->id);
+ set_field('chat_users', 'lastping', time(), 'sid', $chat_sid);
if (!isset($SESSION->chatprefs)) {
$SESSION->chatprefs = array();
$SESSION->chatprefs[$chat->id]['chatentered'] = time();
}
$chatentered = $SESSION->chatprefs[$chat->id]['chatentered'];
-
+
$refreshedmessage = '';
if (!empty($refresh) and data_submitted()) {
$refreshedmessage = $message;
- } else if (empty($refresh) and data_submitted() and confirm_sesskey()) {
-
chat_delete_old_users();
+ } else if (empty($refresh) and data_submitted() and confirm_sesskey()) {
+
if ($message!='') {
$newmessage = new object();
$newmessage->chatid = $chat->id;
error('Could not insert a chat message!');
}
- set_field('chat_users', 'lastmessageping', time(), 'id', $USER->id);
+ set_field('chat_users', 'lastmessageping', time(), 'sid', $chat_sid);
add_to_log($course->id, 'chat', 'talk', "view.php?id=$cm->id", $chat->id, $cm->id);
}
+ chat_delete_old_users();
+
redirect('index.php?id='.$id.'&newonly='.$newonly.'&last='.$last);
}
- print_header($strchat.': '.format_string($chat->name));
+ print_header("$strchat: $course->shortname: ".format_string($chat->name,true)."$groupname");
- echo '<div class="chat-basic">';
- echo '<h2>'.get_string('participants').'</h2>';
- echo '<div class="participants"><ul>';
+ echo '<div id="mod-chat-gui_basic">';
+ echo '<h1>'.get_string('participants').'</h1>';
+ echo '<div id="participants"><ul>';
foreach($chatusers as $chu) {
echo '<li>';
- print_user_picture($chu->id, $course->id, $chu->picture, 24, false, false);
- echo ' '.fullname($chu).' - ';
- $lastping = time() - $chatuser->lastmessageping;
- $min = (int) ($lastping/60);
- $sec = $lastping - ($min*60);
- $min = $min < 10 ? '0'.$min : $min;
- $sec = $sec < 10 ? '0'.$sec : $sec;
- $idle = $min.':'.$sec;
- echo '<span class="idle">'.$stridle.' '.format_time($lastping).'</span>';
+ print_user_picture($chu->id, $course->id, $chu->picture, 24, false, false, '', false);
+ echo '<div class="userinfo">';
+ echo fullname($chu).' ';
+ if ($idle = time() - $chu->lastmessageping) {
+ echo '<span class="idle">'.$stridle.' '.format_time($idle).'</span>';
+ } else {
+ echo '<span class="idle" />';
+ }
+ echo '</div>';
echo '</li>';
}
echo '</ul></div>';
echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
$usehtmleditor = can_use_html_editor();
- echo '<h2><label for="edit-message">'.get_string('sendmessage', 'message').'</label></h2>';
+ echo '<h1><label for="message">'.get_string('sendmessage', 'message').'</label></h1>';
echo '<div>';
- print_textarea(false, 2, 50, 0, 0, 'message', $refreshedmessage);
+ echo '<input type="text" id="message" name="message" value="'.s($refreshedmessage, true).'" size="60" />';
echo '</div><div>';
echo '<input type="submit" value="'.get_string('submit').'" /> ';
echo '<input type="submit" name="refresh" value="'.get_string('refresh').'" />';
echo '</div>';
echo '<div id="messages">';
- echo '<h2>'.get_string('messages', 'chat').'</h2>';
+ echo '<h1>'.get_string('messages', 'chat').'</h1>';
$allmessages = array();
$options = new object();
global $CFG;
$timeold = time() - $CFG->chat_old_ping;
- $timeoldext = time() - ($CFG->chat_old_ping*2); // JSless basic gui needs much longer timeouts
+ $timeoldext = time() - ($CFG->chat_old_ping*10); // JSless gui_basic needs much longer timeouts
$query = "(version<>'basic' AND lastping<'$timeold') OR (version='basic' AND lastping<'$timeoldext')";
$output->text = $message->strtime.': '.get_string('message'.$message->message, 'chat', fullname($sender));
$output->html = '<table class="chat-event"><tr'.$rowclass.'><td class="picture">'.$message->picture.'</td><td class="text">';
$output->html .= '<span class="event">'.$output->text.'</span></td></tr></table>';
- $output->basic = '<dl><dt>'.$message->strtime.': '.get_string('message'.$message->message, 'chat', fullname($sender)).'</dt></dl>';
+ $output->basic = '<dl><dt class="event">'.$message->strtime.': '.get_string('message'.$message->message, 'chat', fullname($sender)).'</dt></dl>';
if($message->message == 'exit' or $message->message == 'enter') {
$output->refreshusers = true; //force user panel refresh ASAP
$output->html .= "<span class=\"title\">$outinfo</span>";
if ($outmain) {
$output->html .= ": $outmain";
- $output->basic = '<dl><dt>'.$outinfo.':</dt><dd>'.$outmain.'</dd></dl>';
+ $output->basic = '<dl><dt class="title">'.$outinfo.':</dt><dd class="text">'.$outmain.'</dd></dl>';
} else {
- $output->basic = '<dl><dt>'.$outinfo.'</dt></dl>';
+ $output->basic = '<dl><dt class="title">'.$outinfo.'</dt></dl>';
}
$output->html .= "</td></tr></table>";
return $output;
link_to_popup_window ("/mod/chat/gui_$CFG->chat_method/index.php?id=$chat->id$groupparam",
"chat$course->id$chat->id$groupparam", "$strenterchat", 500, 700, get_string('modulename', 'chat'));
print_simple_box_end();
+ if ($CFG->chat_method == 'header_js') {
+ // show frame/js-less alternative
+ print_simple_box_start('center');
+ link_to_popup_window ("/mod/chat/gui_basic/index.php?id=$chat->id$groupparam",
+ "chat$course->id$chat->id$groupparam", '('.get_string('noframesjs', 'message').')', 500, 700, get_string('modulename', 'chat'));
+ print_simple_box_end();
+ }
} else {
/* XXX TODO
$wwwroot = $CFG->wwwroot.'/login/index.php';