MDL-8022 chat accessiblity
- new gui_basic that can be used as fallback or accessible option to gui_header_js - it is not compatible with chat daemon - todo: CSS styling, beeping, JS fallback code in view.php and noframes fallback in gui_header_js - minor changes in messaging language strings - minor coding style improvements
This commit is contained in:
@@ -48,7 +48,6 @@ $string['onlymycourses'] = 'Only in my courses';
|
||||
$string['onlytome'] = 'Only messages to me';
|
||||
$string['pagerefreshes'] = 'This page refreshes automatically every $a seconds';
|
||||
$string['readmessages'] = '$a read messages';
|
||||
$string['refresh'] = 'Refresh';
|
||||
$string['removecontact'] = 'Remove contact';
|
||||
$string['savemysettings'] = 'Save my settings';
|
||||
$string['search'] = 'Search';
|
||||
|
||||
@@ -1099,6 +1099,7 @@ $string['recentactivityreport'] = 'Full report of recent activity...';
|
||||
$string['recipientslist'] = 'Recipients list';
|
||||
$string['recreatedcategory'] = 'Recreated category $a';
|
||||
$string['refreshingevents'] = 'Refreshing events';
|
||||
$string['refresh'] = 'Refresh';
|
||||
$string['registration'] = 'Moodle Registration';
|
||||
$string['registrationcontact'] = 'Contact from the public';
|
||||
$string['registrationcontactno'] = 'No, I do not want a contact form in the site listing';
|
||||
@@ -1318,6 +1319,7 @@ $string['studentsandteachers'] = 'Students and teachers';
|
||||
$string['studentviewoff'] = 'Turn student view off';
|
||||
$string['studentviewon'] = 'Turn student view on';
|
||||
$string['subcategories'] = 'Sub-categories';
|
||||
$string['submit'] = 'Submit';
|
||||
$string['success'] = 'Success';
|
||||
$string['summary'] = 'Summary';
|
||||
$string['summaryof'] = 'Summary of $a';
|
||||
|
||||
@@ -175,7 +175,7 @@
|
||||
}
|
||||
echo '</div><div>';
|
||||
echo '<input type="submit" value="'.get_string('sendmessage', 'message').'" /> ';
|
||||
echo '<input type="submit" name="refresh" value="'.get_string('refresh', 'message').'" />';
|
||||
echo '<input type="submit" name="refresh" value="'.get_string('refresh').'" />';
|
||||
echo '<input type="checkbox" name="newonly" id="newonly" '.($newonly?'checked="checked" ':'').'/><label for="newonly">'.get_string('newonlymsg', 'message').'</label>';
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
|
||||
+1
-1
@@ -212,7 +212,7 @@ document.write("'.$autorefresh.'")
|
||||
//]]>
|
||||
</script>';
|
||||
echo '<noscript><div align="center">';
|
||||
echo print_single_button('index.php', false, get_string('refresh', 'message'));
|
||||
echo print_single_button('index.php', false, get_string('refresh'));
|
||||
echo '</div></noscript>';
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once('../lib.php');
|
||||
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$groupid = optional_param('groupid', 0, PARAM_INT); // only for teachers
|
||||
$message = optional_param('message', '', PARAM_CLEAN);
|
||||
$refresh = optional_param('refresh', '', PARAM_RAW); // force refresh
|
||||
$last = optional_param('last', 0, PARAM_INT); // last time refresh or sending
|
||||
$newonly = optional_param('newonly', 0, PARAM_BOOL); // show only new messages
|
||||
|
||||
if (!$chat = get_record('chat', 'id', $id)) {
|
||||
error('Could not find that chat room!');
|
||||
}
|
||||
|
||||
if (!$course = get_record('course', 'id', $chat->course)) {
|
||||
error('Could not find the course this belongs to!');
|
||||
}
|
||||
|
||||
if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) {
|
||||
error('Course Module ID was incorrect');
|
||||
}
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
require_login($course->id, false, $cm);
|
||||
require_capability('mod/chat:chat',$context);
|
||||
|
||||
/// Check to see if groups are being used here
|
||||
if ($groupmode = groupmode($course, $cm)) { // Groups are being used
|
||||
if ($groupid = get_and_set_current_group($course, $groupmode, $groupid)) {
|
||||
if (!$group = get_record('groups', 'id', $groupid)) {
|
||||
error("That group (id $groupid) doesn't exist!");
|
||||
}
|
||||
$groupname = ': '.$group->name;
|
||||
} else {
|
||||
$groupname = ': '.get_string('allparticipants');
|
||||
}
|
||||
} else {
|
||||
$groupid = 0;
|
||||
$groupname = '';
|
||||
}
|
||||
|
||||
$strchat = get_string('modulename', 'chat'); // must be before current_language() in chat_login_user() to force course language!!!
|
||||
$strchats = get_string('modulenameplural', 'chat');
|
||||
$stridle = get_String('idle', 'chat');
|
||||
if (!$chat_sid = chat_login_user($chat->id, 'basic', $groupid, $course)) {
|
||||
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);
|
||||
|
||||
if (!isset($SESSION->chatprefs)) {
|
||||
$SESSION->chatprefs = array();
|
||||
}
|
||||
if (!isset($SESSION->chatprefs[$chat->id])) {
|
||||
$SESSION->chatprefs[$chat->id] = 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();
|
||||
|
||||
if ($message!='') {
|
||||
$newmessage = new object();
|
||||
$newmessage->chatid = $chat->id;
|
||||
$newmessage->userid = $USER->id;
|
||||
$newmessage->groupid = $groupid;
|
||||
$newmessage->systrem = 0;
|
||||
$newmessage->message = $message;
|
||||
$newmessage->timestamp = time();
|
||||
if (!insert_record('chat_messages', $newmessage)) {
|
||||
error('Could not insert a chat message!');
|
||||
}
|
||||
|
||||
set_field('chat_users', 'lastmessageping', time(), 'id', $USER->id);
|
||||
|
||||
add_to_log($course->id, 'chat', 'talk', "view.php?id=$cm->id", $chat->id, $cm->id);
|
||||
}
|
||||
|
||||
redirect('index.php?id='.$id.'&newonly='.$newonly.'&last='.$last);
|
||||
}
|
||||
|
||||
|
||||
print_header($strchat.': '.format_string($chat->name));
|
||||
|
||||
echo '<div class="chat-basic">';
|
||||
echo '<h2>'.get_string('participants').'</h2>';
|
||||
echo '<div class="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>';
|
||||
echo '</li>';
|
||||
}
|
||||
echo '</ul></div>';
|
||||
echo '<div id="send">';
|
||||
echo '<form name="editing" method="post" action="index.php">';
|
||||
echo '<input type="hidden" name="id" value="'.$id.'" />';
|
||||
echo '<input type="hidden" name="groupid" value="'.$groupid.'" />';
|
||||
echo '<input type="hidden" name="last" value="'.time().'" />';
|
||||
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 '<div>';
|
||||
print_textarea(false, 2, 50, 0, 0, 'message', $refreshedmessage);
|
||||
echo '</div><div>';
|
||||
echo '<input type="submit" value="'.get_string('submit').'" /> ';
|
||||
echo '<input type="submit" name="refresh" value="'.get_string('refresh').'" />';
|
||||
echo '<input type="checkbox" name="newonly" id="newonly" '.($newonly?'checked="checked" ':'').'/><label for="newonly">'.get_string('newonlymsg', 'message').'</label>';
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div id="messages">';
|
||||
echo '<h2>'.get_string('messages', 'chat').'</h2>';
|
||||
|
||||
$allmessages = array();
|
||||
$options = new object();
|
||||
$options->para = false;
|
||||
$options->newlines = true;
|
||||
|
||||
if ($newonly) {
|
||||
$lastsql = "AND timestamp > $last";
|
||||
} else {
|
||||
$lastsql = "";
|
||||
}
|
||||
|
||||
$groupselect = $groupid ? "AND (groupid='$groupid' OR groupid='0')" : "";
|
||||
$messages = get_records_select("chat_messages",
|
||||
"chatid = '$chat->id' AND timestamp > $chatentered $lastsql $groupselect",
|
||||
"timestamp DESC");
|
||||
|
||||
if ($messages) {
|
||||
foreach ($messages as $message) {
|
||||
$allmessages[] = chat_format_message($message, $course->id, $USER);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($allmessages)) {
|
||||
echo get_string('nomessagesfound', 'message');
|
||||
} else {
|
||||
foreach ($allmessages as $message) {
|
||||
echo $message->basic;
|
||||
}
|
||||
}
|
||||
|
||||
echo '</div></div>';
|
||||
|
||||
print_footer('none');
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -38,6 +38,7 @@
|
||||
|
||||
if (!empty($chat_message)) {
|
||||
|
||||
$message = new object();
|
||||
$message->chatid = $chatuser->chatid;
|
||||
$message->userid = $chatuser->userid;
|
||||
$message->groupid = $chatuser->groupid;
|
||||
|
||||
+11
-2
@@ -402,6 +402,7 @@ function chat_login_user($chatid, $version, $groupid, $course) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$chatuser = new object();
|
||||
$chatuser->chatid = $chatid;
|
||||
$chatuser->userid = $USER->id;
|
||||
$chatuser->groupid = $groupid;
|
||||
@@ -430,6 +431,7 @@ function chat_login_user($chatid, $version, $groupid, $course) {
|
||||
if ($version == 'sockets') {
|
||||
// do not send 'enter' message, chatd will do it
|
||||
} else {
|
||||
$message = new object();
|
||||
$message->chatid = $chatuser->chatid;
|
||||
$message->userid = $chatuser->userid;
|
||||
$message->groupid = $groupid;
|
||||
@@ -452,12 +454,14 @@ function chat_delete_old_users() {
|
||||
global $CFG;
|
||||
|
||||
$timeold = time() - $CFG->chat_old_ping;
|
||||
$timeoldext = time() - ($CFG->chat_old_ping*2); // JSless basic gui needs much longer timeouts
|
||||
|
||||
$query = "lastping < '$timeold'";
|
||||
$query = "(version<>'basic' AND lastping<'$timeold') OR (version='basic' AND lastping<'$timeoldext')";
|
||||
|
||||
if ($oldusers = get_records_select('chat_users', $query) ) {
|
||||
delete_records_select('chat_users', $query);
|
||||
foreach ($oldusers as $olduser) {
|
||||
$message = new object();
|
||||
$message->chatid = $olduser->chatid;
|
||||
$message->userid = $olduser->userid;
|
||||
$message->groupid = $olduser->groupid;
|
||||
@@ -516,7 +520,7 @@ function chat_update_chat_times($chatid=0) {
|
||||
function chat_format_message_manually($message, $courseid, $sender, $currentuser, $chat_lastrow=NULL) {
|
||||
global $CFG, $USER;
|
||||
|
||||
$output = New stdClass;
|
||||
$output = new object();
|
||||
$output->beep = false; // by default
|
||||
$output->refreshusers = false; // by default
|
||||
|
||||
@@ -552,6 +556,7 @@ function chat_format_message_manually($message, $courseid, $sender, $currentuser
|
||||
$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>';
|
||||
|
||||
if($message->message == 'exit' or $message->message == 'enter') {
|
||||
$output->refreshusers = true; //force user panel refresh ASAP
|
||||
@@ -565,6 +570,7 @@ function chat_format_message_manually($message, $courseid, $sender, $currentuser
|
||||
|
||||
/// Parse the text to clean and filter it
|
||||
|
||||
$options = new object();
|
||||
$options->para = false;
|
||||
$text = format_text($text, FORMAT_MOODLE, $options, $courseid);
|
||||
// And now check for special cases
|
||||
@@ -613,6 +619,9 @@ function chat_format_message_manually($message, $courseid, $sender, $currentuser
|
||||
$output->html .= "<span class=\"title\">$outinfo</span>";
|
||||
if ($outmain) {
|
||||
$output->html .= ": $outmain";
|
||||
$output->basic = '<dl><dt>'.$outinfo.':</dt><dd>'.$outmain.'</dd></dl>';
|
||||
} else {
|
||||
$output->basic = '<dl><dt>'.$outinfo.'</dt></dl>';
|
||||
}
|
||||
$output->html .= "</td></tr></table>";
|
||||
return $output;
|
||||
|
||||
Reference in New Issue
Block a user