From: skodak Date: Fri, 29 Dec 2006 18:33:41 +0000 (+0000) Subject: MDL-8022 chat accessiblity X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=6ee78ceeafe4d033de4dc729417ec5898696d379;p=moodle.git 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 --- diff --git a/lang/en_utf8/message.php b/lang/en_utf8/message.php index 07bc43167c..779fb68978 100644 --- a/lang/en_utf8/message.php +++ b/lang/en_utf8/message.php @@ -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'; diff --git a/lang/en_utf8/moodle.php b/lang/en_utf8/moodle.php index 54d8fb0dec..af211a4e29 100644 --- a/lang/en_utf8/moodle.php +++ b/lang/en_utf8/moodle.php @@ -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'; diff --git a/message/discussion.php b/message/discussion.php index 84e6c6b356..48aa0f7299 100644 --- a/message/discussion.php +++ b/message/discussion.php @@ -175,7 +175,7 @@ } echo '
'; echo ' '; - echo ''; + echo ''; echo ''; echo '
'; echo ''; diff --git a/message/lib.php b/message/lib.php index ef4a3f67a3..04b3672bc1 100644 --- a/message/lib.php +++ b/message/lib.php @@ -212,7 +212,7 @@ document.write("'.$autorefresh.'") //]]> '; echo ''; } diff --git a/mod/chat/gui_basic/index.php b/mod/chat/gui_basic/index.php new file mode 100644 index 0000000000..a7e28e0fed --- /dev/null +++ b/mod/chat/gui_basic/index.php @@ -0,0 +1,177 @@ +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 '
'; + echo '

'.get_string('participants').'

'; + echo '
    '; + foreach($chatusers as $chu) { + echo '
  • '; + 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 ''.$stridle.' '.format_time($lastping).''; + echo '
  • '; + } + echo '
'; + echo '
'; + echo '
'; + echo ''; + echo ''; + echo ''; + echo ''; + + $usehtmleditor = can_use_html_editor(); + echo '

'; + echo '
'; + print_textarea(false, 2, 50, 0, 0, 'message', $refreshedmessage); + echo '
'; + echo ' '; + echo ''; + echo ''; + echo '
'; + echo '
'; + echo '
'; + + echo '
'; + echo '

'.get_string('messages', 'chat').'

'; + + $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 '
'; + + print_footer('none'); + + + +?> diff --git a/mod/chat/gui_header_js/insert.php b/mod/chat/gui_header_js/insert.php index ef2f965ccd..6305c819d6 100644 --- a/mod/chat/gui_header_js/insert.php +++ b/mod/chat/gui_header_js/insert.php @@ -38,6 +38,7 @@ if (!empty($chat_message)) { + $message = new object(); $message->chatid = $chatuser->chatid; $message->userid = $chatuser->userid; $message->groupid = $chatuser->groupid; diff --git a/mod/chat/lib.php b/mod/chat/lib.php index 13fa0c0582..0a99b81e32 100644 --- a/mod/chat/lib.php +++ b/mod/chat/lib.php @@ -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 = '
'.$message->picture.''; $output->html .= ''.$output->text.'
'; + $output->basic = '
'.$message->strtime.': '.get_string('message'.$message->message, 'chat', fullname($sender)).'
'; 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 .= "$outinfo"; if ($outmain) { $output->html .= ": $outmain"; + $output->basic = '
'.$outinfo.':
'.$outmain.'
'; + } else { + $output->basic = '
'.$outinfo.'
'; } $output->html .= ""; return $output;