mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
MDL-46465 mod_chat: assorted coding style fixes
This commit is contained in:
parent
ec36fafc0f
commit
c52b4db52d
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@ -70,27 +69,27 @@ class moodle1_mod_chat_handler extends moodle1_mod_handler {
|
||||
public function process_chat($data) {
|
||||
global $CFG;
|
||||
|
||||
// get the course module id and context id
|
||||
// Get the course module id and context id.
|
||||
$instanceid = $data['id'];
|
||||
$cminfo = $this->get_cminfo($instanceid);
|
||||
$this->moduleid = $cminfo['id'];
|
||||
$contextid = $this->converter->get_contextid(CONTEXT_MODULE, $this->moduleid);
|
||||
|
||||
// replay the upgrade step 2010050101
|
||||
// Replay the upgrade step 2010050101.
|
||||
if ($CFG->texteditors !== 'textarea') {
|
||||
$data['intro'] = text_to_html($data['intro'], false, false, true);
|
||||
$data['introformat'] = FORMAT_HTML;
|
||||
}
|
||||
|
||||
// get a fresh new file manager for this instance
|
||||
// Get a fresh new file manager for this instance.
|
||||
$this->fileman = $this->converter->get_file_manager($contextid, 'mod_chat');
|
||||
|
||||
// convert course files embedded into the intro
|
||||
// Convert course files embedded into the intro.
|
||||
$this->fileman->filearea = 'intro';
|
||||
$this->fileman->itemid = 0;
|
||||
$data['intro'] = moodle1_converter::migrate_referenced_files($data['intro'], $this->fileman);
|
||||
|
||||
// start writing chat.xml
|
||||
// Start writing chat.xml.
|
||||
$this->open_xml_writer("activities/chat_{$this->moduleid}/chat.xml");
|
||||
$this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $this->moduleid,
|
||||
'modulename' => 'chat', 'contextid' => $contextid));
|
||||
@ -112,21 +111,20 @@ class moodle1_mod_chat_handler extends moodle1_mod_handler {
|
||||
* data available
|
||||
*/
|
||||
public function process_chat_message($data) {
|
||||
//@todo process user data
|
||||
//$this->write_xml('message', $data, array('/message/id'));
|
||||
// MDL-46466 - Should this be empty?
|
||||
}
|
||||
|
||||
/**
|
||||
* This is executed when we reach the closing </MOD> tag of our 'chat' path
|
||||
*/
|
||||
public function on_chat_end() {
|
||||
// close chat.xml
|
||||
// Close chat.xml.
|
||||
$this->xmlwriter->end_tag('messages');
|
||||
$this->xmlwriter->end_tag('chat');
|
||||
$this->xmlwriter->end_tag('activity');
|
||||
$this->close_xml_writer();
|
||||
|
||||
// write inforef.xml
|
||||
// Write inforef.xml.
|
||||
$this->open_xml_writer("activities/chat_{$this->moduleid}/inforef.xml");
|
||||
$this->xmlwriter->begin_tag('inforef');
|
||||
$this->xmlwriter->begin_tag('fileref');
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@ -55,13 +54,13 @@ class backup_chat_activity_task extends backup_activity_task {
|
||||
static public function encode_content_links($content) {
|
||||
global $CFG;
|
||||
|
||||
$base = preg_quote($CFG->wwwroot.'/mod/chat','#');
|
||||
$base = preg_quote($CFG->wwwroot . '/mod/chat', '#');
|
||||
|
||||
//Link to the list of chats
|
||||
// Link to the list of chats.
|
||||
$pattern = "#(".$base."\/index.php\?id\=)([0-9]+)#";
|
||||
$content = preg_replace($pattern, '$@CHATINDEX*$2@$', $content);
|
||||
|
||||
//Link to chat view by moduleid
|
||||
// Link to chat view by moduleid.
|
||||
$pattern = "#(".$base."\/view.php\?id\=)([0-9]+)#";
|
||||
$content = preg_replace($pattern, '$@CHATVIEWBYID*$2@$', $content);
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@ -29,7 +28,7 @@ class backup_chat_activity_structure_step extends backup_activity_structure_step
|
||||
protected function define_structure() {
|
||||
$userinfo = $this->get_setting_value('userinfo');
|
||||
|
||||
// Define each element separated
|
||||
// Define each element separated.
|
||||
$chat = new backup_nested_element('chat', array('id'), array(
|
||||
'name', 'intro', 'introformat', 'keepdays', 'studentlogs',
|
||||
'chattime', 'schedule', 'timemodified'));
|
||||
@ -38,29 +37,29 @@ class backup_chat_activity_structure_step extends backup_activity_structure_step
|
||||
$message = new backup_nested_element('message', array('id'), array(
|
||||
'userid', 'groupid', 'system', 'message_text', 'timestamp'));
|
||||
|
||||
// it is not cool to have two tags with same name, so we need to rename message field to message_text
|
||||
// It is not cool to have two tags with same name, so we need to rename message field to message_text.
|
||||
$message->set_source_alias('message', 'message_text');
|
||||
|
||||
// Build the tree
|
||||
// Build the tree.
|
||||
$chat->add_child($messages);
|
||||
$messages->add_child($message);
|
||||
|
||||
// Define sources
|
||||
// Define sources.
|
||||
$chat->set_source_table('chat', array('id' => backup::VAR_ACTIVITYID));
|
||||
|
||||
// User related messages only happen if we are including user info
|
||||
// User related messages only happen if we are including user info.
|
||||
if ($userinfo) {
|
||||
$message->set_source_table('chat_messages', array('chatid'=>backup::VAR_PARENTID));
|
||||
$message->set_source_table('chat_messages', array('chatid' => backup::VAR_PARENTID));
|
||||
}
|
||||
|
||||
// Define id annotations
|
||||
// Define id annotations.
|
||||
$message->annotate_ids('user', 'userid');
|
||||
$message->annotate_ids('group', 'groupid');
|
||||
|
||||
// Annotate the file areas in chat module
|
||||
$chat->annotate_files('mod_chat', 'intro', null); // chat_intro area don't use itemid
|
||||
// Annotate the file areas in chat module.
|
||||
$chat->annotate_files('mod_chat', 'intro', null); // The chat_intro area doesn't use itemid.
|
||||
|
||||
// Return the root element (chat), wrapped into standard activity structure
|
||||
// Return the root element (chat), wrapped into standard activity structure.
|
||||
return $this->prepare_activity_structure($chat);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@ -24,7 +23,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->dirroot . '/mod/chat/backup/moodle2/restore_chat_stepslib.php'); // Because it exists (must)
|
||||
require_once($CFG->dirroot . '/mod/chat/backup/moodle2/restore_chat_stepslib.php');
|
||||
|
||||
/**
|
||||
* chat restore task that provides all the settings and steps to perform one
|
||||
@ -36,14 +35,14 @@ class restore_chat_activity_task extends restore_activity_task {
|
||||
* Define (add) particular settings this activity can have
|
||||
*/
|
||||
protected function define_my_settings() {
|
||||
// No particular settings for this activity
|
||||
// No particular settings for this activity.
|
||||
}
|
||||
|
||||
/**
|
||||
* Define (add) particular steps this activity can have
|
||||
*/
|
||||
protected function define_my_steps() {
|
||||
// chat only has one structure step
|
||||
// Chat only has one structure step.
|
||||
$this->add_step(new restore_chat_activity_structure_step('chat_structure', 'chat.xml'));
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@ -41,7 +40,7 @@ class restore_chat_activity_structure_step extends restore_activity_structure_st
|
||||
$paths[] = new restore_path_element('chat_message', '/activity/chat/messages/message');
|
||||
}
|
||||
|
||||
// Return the paths wrapped into standard activity structure
|
||||
// Return the paths wrapped into standard activity structure.
|
||||
return $this->prepare_activity_structure($paths);
|
||||
}
|
||||
|
||||
@ -55,9 +54,9 @@ class restore_chat_activity_structure_step extends restore_activity_structure_st
|
||||
$data->chattime = $this->apply_date_offset($data->chattime);
|
||||
$data->timemodified = $this->apply_date_offset($data->timemodified);
|
||||
|
||||
// insert the chat record
|
||||
// Insert the chat record.
|
||||
$newitemid = $DB->insert_record('chat', $data);
|
||||
// immediately after inserting "activity" record, call this
|
||||
// Immediately after inserting "activity" record, call this.
|
||||
$this->apply_activity_instance($newitemid);
|
||||
}
|
||||
|
||||
@ -73,11 +72,11 @@ class restore_chat_activity_structure_step extends restore_activity_structure_st
|
||||
$data->timestamp = $this->apply_date_offset($data->timestamp);
|
||||
|
||||
$newitemid = $DB->insert_record('chat_messages', $data);
|
||||
$this->set_mapping('chat_message', $oldid, $newitemid); // because of decode
|
||||
$this->set_mapping('chat_message', $oldid, $newitemid); // Because of decode.
|
||||
}
|
||||
|
||||
protected function after_execute() {
|
||||
// Add chat related files, no need to match by itemname (just internally handled context)
|
||||
// Add chat related files, no need to match by itemname (just internally handled context).
|
||||
$this->add_related_files('mod_chat', 'intro', null);
|
||||
}
|
||||
}
|
||||
|
@ -20,24 +20,24 @@ require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
|
||||
require_once(dirname(__FILE__) . '/lib.php');
|
||||
|
||||
$action = optional_param('action', '', PARAM_ALPHANUM);
|
||||
$beep_id = optional_param('beep', '', PARAM_RAW);
|
||||
$chat_sid = required_param('chat_sid', PARAM_ALPHANUM);
|
||||
$beepid = optional_param('beep', '', PARAM_RAW);
|
||||
$chatsid = required_param('chat_sid', PARAM_ALPHANUM);
|
||||
$theme = required_param('theme', PARAM_ALPHANUMEXT);
|
||||
$chat_message = optional_param('chat_message', '', PARAM_RAW);
|
||||
$chat_lasttime = optional_param('chat_lasttime', 0, PARAM_INT);
|
||||
$chat_lastrow = optional_param('chat_lastrow', 1, PARAM_INT);
|
||||
$chatmessage = optional_param('chat_message', '', PARAM_RAW);
|
||||
$chatlasttime = optional_param('chat_lasttime', 0, PARAM_INT);
|
||||
$chatlastrow = optional_param('chat_lastrow', 1, PARAM_INT);
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
throw new moodle_exception('invalidsesskey', 'error');
|
||||
}
|
||||
|
||||
if (!$chatuser = $DB->get_record('chat_users', array('sid'=>$chat_sid))) {
|
||||
if (!$chatuser = $DB->get_record('chat_users', array('sid' => $chatsid))) {
|
||||
throw new moodle_exception('notlogged', 'chat');
|
||||
}
|
||||
if (!$chat = $DB->get_record('chat', array('id'=>$chatuser->chatid))) {
|
||||
if (!$chat = $DB->get_record('chat', array('id' => $chatuser->chatid))) {
|
||||
throw new moodle_exception('invaliduserid', 'error');
|
||||
}
|
||||
if (!$course = $DB->get_record('course', array('id'=>$chat->course))) {
|
||||
if (!$course = $DB->get_record('course', array('id' => $chat->course))) {
|
||||
throw new moodle_exception('invalidcourseid', 'error');
|
||||
}
|
||||
if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) {
|
||||
@ -48,9 +48,9 @@ if (!isloggedin()) {
|
||||
throw new moodle_exception('notlogged', 'chat');
|
||||
}
|
||||
|
||||
// setup $PAGE so that format_text will work properly
|
||||
// Set up $PAGE so that format_text will work properly.
|
||||
$PAGE->set_cm($cm, $course, $chat);
|
||||
$PAGE->set_url('/mod/chat/chat_ajax.php', array('chat_sid'=>$chat_sid));
|
||||
$PAGE->set_url('/mod/chat/chat_ajax.php', array('chat_sid' => $chatsid));
|
||||
|
||||
require_login($course, false, $cm);
|
||||
|
||||
@ -65,104 +65,104 @@ header('Pragma: no-cache');
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
|
||||
switch ($action) {
|
||||
case 'init':
|
||||
$users = chat_get_users($chatuser->chatid, $chatuser->groupid, $cm->groupingid);
|
||||
$users = chat_format_userlist($users, $course);
|
||||
$response['users'] = $users;
|
||||
echo json_encode($response);
|
||||
break;
|
||||
case 'init':
|
||||
$users = chat_get_users($chatuser->chatid, $chatuser->groupid, $cm->groupingid);
|
||||
$users = chat_format_userlist($users, $course);
|
||||
$response['users'] = $users;
|
||||
echo json_encode($response);
|
||||
break;
|
||||
|
||||
case 'chat':
|
||||
\core\session\manager::write_close();
|
||||
chat_delete_old_users();
|
||||
$chat_message = clean_text($chat_message, FORMAT_MOODLE);
|
||||
|
||||
if (!empty($beep_id)) {
|
||||
$chat_message = 'beep '.$beep_id;
|
||||
}
|
||||
|
||||
if (!empty($chat_message)) {
|
||||
|
||||
chat_send_chatmessage($chatuser, $chat_message, 0, $cm);
|
||||
|
||||
$chatuser->lastmessageping = time() - 2;
|
||||
$DB->update_record('chat_users', $chatuser);
|
||||
|
||||
// Response OK message.
|
||||
echo json_encode(true);
|
||||
ob_end_flush();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'update':
|
||||
if ((time() - $chat_lasttime) > $CFG->chat_old_ping) {
|
||||
case 'chat':
|
||||
\core\session\manager::write_close();
|
||||
chat_delete_old_users();
|
||||
}
|
||||
$chatmessage = clean_text($chatmessage, FORMAT_MOODLE);
|
||||
|
||||
if ($latest_message = chat_get_latest_message($chatuser->chatid, $chatuser->groupid)) {
|
||||
$chat_newlasttime = $latest_message->timestamp;
|
||||
} else {
|
||||
$chat_newlasttime = 0;
|
||||
}
|
||||
if (!empty($beepid)) {
|
||||
$chatmessage = 'beep '.$beepid;
|
||||
}
|
||||
|
||||
if ($chat_lasttime == 0) {
|
||||
$chat_lasttime = time() - $CFG->chat_old_ping;
|
||||
}
|
||||
if (!empty($chatmessage)) {
|
||||
|
||||
$params = array('groupid'=>$chatuser->groupid, 'chatid'=>$chatuser->chatid, 'lasttime'=>$chat_lasttime);
|
||||
chat_send_chatmessage($chatuser, $chatmessage, 0, $cm);
|
||||
|
||||
$groupselect = $chatuser->groupid ? " AND (groupid=".$chatuser->groupid." OR groupid=0) " : "";
|
||||
$chatuser->lastmessageping = time() - 2;
|
||||
$DB->update_record('chat_users', $chatuser);
|
||||
|
||||
$messages = $DB->get_records_select('chat_messages_current',
|
||||
'chatid = :chatid AND timestamp > :lasttime '.$groupselect, $params,
|
||||
'timestamp ASC');
|
||||
// Response OK message.
|
||||
echo json_encode(true);
|
||||
ob_end_flush();
|
||||
}
|
||||
break;
|
||||
|
||||
if (!empty($messages)) {
|
||||
$num = count($messages);
|
||||
} else {
|
||||
$num = 0;
|
||||
}
|
||||
$chat_newrow = ($chat_lastrow + $num) % 2;
|
||||
$send_user_list = false;
|
||||
if ($messages && ($chat_lasttime != $chat_newlasttime)) {
|
||||
foreach ($messages as $n => &$message) {
|
||||
$tmp = new stdClass();
|
||||
// when somebody enter room, user list will be updated
|
||||
if (!empty($message->system)){
|
||||
$send_user_list = true;
|
||||
}
|
||||
if ($html = chat_format_message_theme($message, $chatuser, $USER, $cm->groupingid, $theme)) {
|
||||
$message->mymessage = ($USER->id == $message->userid);
|
||||
$message->message = $html->html;
|
||||
if (!empty($html->type)) {
|
||||
$message->type = $html->type;
|
||||
case 'update':
|
||||
if ((time() - $chatlasttime) > $CFG->chat_old_ping) {
|
||||
chat_delete_old_users();
|
||||
}
|
||||
|
||||
if ($latestmessage = chat_get_latest_message($chatuser->chatid, $chatuser->groupid)) {
|
||||
$chatnewlasttime = $latestmessage->timestamp;
|
||||
} else {
|
||||
$chatnewlasttime = 0;
|
||||
}
|
||||
|
||||
if ($chatlasttime == 0) {
|
||||
$chatlasttime = time() - $CFG->chat_old_ping;
|
||||
}
|
||||
|
||||
$params = array('groupid' => $chatuser->groupid, 'chatid' => $chatuser->chatid, 'lasttime' => $chatlasttime);
|
||||
|
||||
$groupselect = $chatuser->groupid ? " AND (groupid=".$chatuser->groupid." OR groupid=0) " : "";
|
||||
|
||||
$messages = $DB->get_records_select('chat_messages_current',
|
||||
'chatid = :chatid AND timestamp > :lasttime '.$groupselect, $params,
|
||||
'timestamp ASC');
|
||||
|
||||
if (!empty($messages)) {
|
||||
$num = count($messages);
|
||||
} else {
|
||||
$num = 0;
|
||||
}
|
||||
$chatnewrow = ($chatlastrow + $num) % 2;
|
||||
$senduserlist = false;
|
||||
if ($messages && ($chatlasttime != $chatnewlasttime)) {
|
||||
foreach ($messages as $n => &$message) {
|
||||
$tmp = new stdClass();
|
||||
// When somebody enter room, user list will be updated.
|
||||
if (!empty($message->system)) {
|
||||
$senduserlist = true;
|
||||
}
|
||||
if ($html = chat_format_message_theme($message, $chatuser, $USER, $cm->groupingid, $theme)) {
|
||||
$message->mymessage = ($USER->id == $message->userid);
|
||||
$message->message = $html->html;
|
||||
if (!empty($html->type)) {
|
||||
$message->type = $html->type;
|
||||
}
|
||||
} else {
|
||||
unset($messages[$n]);
|
||||
}
|
||||
} else {
|
||||
unset($messages[$n]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($send_user_list){
|
||||
// return users when system message coming
|
||||
$users = chat_format_userlist(chat_get_users($chatuser->chatid, $chatuser->groupid, $cm->groupingid), $course);
|
||||
$response['users'] = $users;
|
||||
}
|
||||
if ($senduserlist) {
|
||||
// Return users when system message arrives.
|
||||
$users = chat_format_userlist(chat_get_users($chatuser->chatid, $chatuser->groupid, $cm->groupingid), $course);
|
||||
$response['users'] = $users;
|
||||
}
|
||||
|
||||
$DB->set_field('chat_users', 'lastping', time(), array('id'=>$chatuser->id));
|
||||
$DB->set_field('chat_users', 'lastping', time(), array('id' => $chatuser->id));
|
||||
|
||||
$response['lasttime'] = $chat_newlasttime;
|
||||
$response['lastrow'] = $chat_newrow;
|
||||
if($messages){
|
||||
$response['msgs'] = $messages;
|
||||
}
|
||||
$response['lasttime'] = $chatnewlasttime;
|
||||
$response['lastrow'] = $chatnewrow;
|
||||
if ($messages) {
|
||||
$response['msgs'] = $messages;
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
header('Content-Length: ' . ob_get_length() );
|
||||
echo json_encode($response);
|
||||
header('Content-Length: ' . ob_get_length());
|
||||
|
||||
ob_end_flush();
|
||||
break;
|
||||
ob_end_flush();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -85,7 +85,7 @@ $capabilities = array(
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'manager' => CAP_ALLOW,
|
||||
// not student - nervous about allowing this by default
|
||||
// Not student - nervous about allowing this by default.
|
||||
),
|
||||
|
||||
),
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@ -27,9 +26,9 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$logs = array(
|
||||
array('module'=>'chat', 'action'=>'view', 'mtable'=>'chat', 'field'=>'name'),
|
||||
array('module'=>'chat', 'action'=>'add', 'mtable'=>'chat', 'field'=>'name'),
|
||||
array('module'=>'chat', 'action'=>'update', 'mtable'=>'chat', 'field'=>'name'),
|
||||
array('module'=>'chat', 'action'=>'report', 'mtable'=>'chat', 'field'=>'name'),
|
||||
array('module'=>'chat', 'action'=>'talk', 'mtable'=>'chat', 'field'=>'name'),
|
||||
);
|
||||
array('module' => 'chat', 'action' => 'view', 'mtable' => 'chat', 'field' => 'name'),
|
||||
array('module' => 'chat', 'action' => 'add', 'mtable' => 'chat', 'field' => 'name'),
|
||||
array('module' => 'chat', 'action' => 'update', 'mtable' => 'chat', 'field' => 'name'),
|
||||
array('module' => 'chat', 'action' => 'report', 'mtable' => 'chat', 'field' => 'name'),
|
||||
array('module' => 'chat', 'action' => 'talk', 'mtable' => 'chat', 'field' => 'name'),
|
||||
);
|
||||
|
@ -1,46 +1,44 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// This file keeps track of upgrades to
|
||||
// the chat module
|
||||
//
|
||||
// Sometimes, changes between versions involve
|
||||
// alterations to database structures and other
|
||||
// major things that may break installations.
|
||||
//
|
||||
// The upgrade function in this file will attempt
|
||||
// to perform all the necessary actions to upgrade
|
||||
// your older installation to the current version.
|
||||
//
|
||||
// If there's something it cannot do itself, it
|
||||
// will tell you what you need to do.
|
||||
//
|
||||
// The commands in here will all be database-neutral,
|
||||
// using the methods of database_manager class
|
||||
//
|
||||
// Please do not forget to use upgrade_set_timeout()
|
||||
// before any action that may take longer time to finish.
|
||||
/**
|
||||
* Upgrade code for the chat activity
|
||||
*
|
||||
* @package mod_chat
|
||||
* @copyright 2006 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
function xmldb_chat_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Moodle v2.2.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
// Moodle v2.3.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.4.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
// Moodle v2.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
// Moodle v2.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
@ -1,29 +1,44 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once('../lib.php');
|
||||
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$groupid = optional_param('groupid', 0, PARAM_INT); //only for teachers
|
||||
$theme = optional_param('theme', 'course_theme', PARAM_SAFEDIR); //course_theme to use the current theme.
|
||||
$groupid = optional_param('groupid', 0, PARAM_INT); // Only for teachers.
|
||||
$theme = optional_param('theme', 'course_theme', PARAM_SAFEDIR); // The value course_theme == the current theme.
|
||||
|
||||
$url = new moodle_url('/mod/chat/gui_ajax/index.php', array('id'=>$id));
|
||||
$url = new moodle_url('/mod/chat/gui_ajax/index.php', array('id' => $id));
|
||||
if ($groupid !== 0) {
|
||||
$url->param('groupid', $groupid);
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
$PAGE->set_popup_notification_allowed(false); // No popup notifications in the chat window
|
||||
$PAGE->set_popup_notification_allowed(false); // No popup notifications in the chat window.
|
||||
$PAGE->requires->strings_for_js(array('coursetheme', 'bubble', 'compact'), 'mod_chat');
|
||||
|
||||
$chat = $DB->get_record('chat', array('id'=>$id), '*', MUST_EXIST);
|
||||
$course = $DB->get_record('course', array('id'=>$chat->course), '*', MUST_EXIST);
|
||||
$chat = $DB->get_record('chat', array('id' => $id), '*', MUST_EXIST);
|
||||
$course = $DB->get_record('course', array('id' => $chat->course), '*', MUST_EXIST);
|
||||
$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id, false, MUST_EXIST);
|
||||
|
||||
$context = context_module::instance($cm->id);
|
||||
require_login($course, false, $cm);
|
||||
require_capability('mod/chat:chat', $context);
|
||||
|
||||
/// Check to see if groups are being used here
|
||||
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used
|
||||
// Check to see if groups are being used here.
|
||||
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used.
|
||||
if ($groupid = groups_get_activity_group($cm)) {
|
||||
if (!$group = groups_get_group($groupid)) {
|
||||
print_error('invalidgroupid');
|
||||
@ -37,42 +52,43 @@ require_capability('mod/chat:chat', $context);
|
||||
$groupname = '';
|
||||
}
|
||||
$showcoursetheme = in_array('bootstrapbase', $PAGE->theme->parents);
|
||||
if (!$showcoursetheme && $theme === 'course_theme') { //set compact as default for non bootstrapbase based themes
|
||||
if (!$showcoursetheme && $theme === 'course_theme') { // Set compact as default for non bootstrapbase based themes.
|
||||
$theme = 'compact';
|
||||
}
|
||||
|
||||
// if requested theme doesn't exist, use default 'bubble' theme
|
||||
// If requested theme doesn't exist, use default 'bubble' theme.
|
||||
if ($theme != 'course_theme' and !file_exists(dirname(__FILE__) . '/theme/'.$theme.'/chat.css')) {
|
||||
$theme = 'compact';
|
||||
}
|
||||
|
||||
// login chat room
|
||||
if (!$chat_sid = chat_login_user($chat->id, 'ajax', $groupid, $course)) {
|
||||
// Log into the chat room.
|
||||
if (!$chatsid = chat_login_user($chat->id, 'ajax', $groupid, $course)) {
|
||||
print_error('cantlogin', 'chat');
|
||||
}
|
||||
$courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
|
||||
$module = array(
|
||||
'name' => 'mod_chat_ajax', // chat gui's are not real plugins, we have to break the naming standards for JS modules here :-(
|
||||
'name' => 'mod_chat_ajax', // Chat gui's are not real plugins, we have to break the naming standards for JS modules here.
|
||||
'fullpath' => '/mod/chat/gui_ajax/module.js',
|
||||
'requires' => array('base', 'dom', 'event', 'event-mouseenter', 'event-key', 'json-parse', 'io', 'overlay', 'yui2-resize', 'yui2-layout', 'yui2-menu'),
|
||||
'requires' => array('base', 'dom', 'event', 'event-mouseenter', 'event-key', 'json-parse', 'io', 'overlay', 'yui2-resize',
|
||||
'yui2-layout', 'yui2-menu'),
|
||||
'strings' => array(array('send', 'chat'), array('sending', 'chat'), array('inputarea', 'chat'), array('userlist', 'chat'),
|
||||
array('modulename', 'chat'), array('beep', 'chat'), array('talk', 'chat'))
|
||||
);
|
||||
$modulecfg = array(
|
||||
'home'=>$CFG->httpswwwroot.'/mod/chat/view.php?id='.$cm->id,
|
||||
'chaturl'=>$CFG->httpswwwroot.'/mod/chat/gui_ajax/index.php?id='.$id,
|
||||
'theme'=>$theme,
|
||||
'showcoursetheme'=>$showcoursetheme?1:0,
|
||||
'userid'=>$USER->id,
|
||||
'sid'=>$chat_sid,
|
||||
'timer'=>3000,
|
||||
'chat_lasttime'=>0,
|
||||
'chat_lastrow'=>null,
|
||||
'home' => $CFG->httpswwwroot.'/mod/chat/view.php?id='.$cm->id,
|
||||
'chaturl' => $CFG->httpswwwroot.'/mod/chat/gui_ajax/index.php?id='.$id,
|
||||
'theme' => $theme,
|
||||
'showcoursetheme' => $showcoursetheme ? 1 : 0,
|
||||
'userid' => $USER->id,
|
||||
'sid' => $chatsid,
|
||||
'timer' => 3000,
|
||||
'chat_lasttime' => 0,
|
||||
'chat_lastrow' => null,
|
||||
'chatroom_name' => $courseshortname . ": " . format_string($chat->name, true) . $groupname
|
||||
);
|
||||
$PAGE->requires->js_init_call('M.mod_chat_ajax.init', array($modulecfg), false, $module);
|
||||
|
||||
$PAGE->set_title(get_string('modulename', 'chat').": $courseshortname: ".format_string($chat->name,true)."$groupname");
|
||||
$PAGE->set_title(get_string('modulename', 'chat').": $courseshortname: ".format_string($chat->name, true)."$groupname");
|
||||
$PAGE->add_body_class('yui-skin-sam');
|
||||
$PAGE->set_pagelayout('embedded');
|
||||
if ( $theme != 'course_theme') {
|
||||
@ -87,7 +103,11 @@ echo $OUTPUT->box(html_writer::tag('h2', get_string('messages', 'chat'), array(
|
||||
'<ul id="messages-list"></ul>', '', 'chat-messages');
|
||||
$table = new html_table();
|
||||
$table->data = array(
|
||||
array('<label class="accesshide" for="input-message">' . get_string('entermessage', 'chat') . ' </label><input type="text" disabled="true" id="input-message" value="Loading..." /> <input type="button" id="button-send" value="'.get_string('send', 'chat').'" /> <a id="choosetheme" href="###">'.get_string('themes').' » </a>')
|
||||
array('<label class="accesshide" for="input-message">'.get_string('entermessage', 'chat').' </label>'.
|
||||
'<input type="text" disabled="true" id="input-message" value="Loading..." /> '.
|
||||
'<input type="button" id="button-send" value="'.get_string('send', 'chat').'" /> <a id="choosetheme" href="###">'.
|
||||
get_string('themes').
|
||||
' » </a>')
|
||||
);
|
||||
echo $OUTPUT->box(html_writer::tag('h2', get_string('composemessage', 'chat'), array('class' => 'accesshide')) .
|
||||
html_writer::table($table), '', 'chat-input-area');
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* NOTE: the /mod/chat/gui_header_js/ is not a real plugin,
|
||||
* ideally this code should be in /mod/chat/module.js
|
||||
@ -20,14 +19,14 @@ M.mod_chat_ajax.init = function(Y, cfg) {
|
||||
|
||||
var gui_ajax = {
|
||||
|
||||
// Properties
|
||||
api : M.cfg.wwwroot+'/mod/chat/chat_ajax.php?sesskey='+M.cfg.sesskey, // The path to the ajax callback script
|
||||
cfg : {}, // A configuration variable
|
||||
interval : null, // The interval object for refreshes
|
||||
layout : null, // A reference to the layout used in this module
|
||||
messages : [], // An array of messages
|
||||
scrollable : true, // True is scrolling should occur
|
||||
thememenu : null, // A reference to the menu for changing themes
|
||||
// Properties.
|
||||
api : M.cfg.wwwroot + '/mod/chat/chat_ajax.php?sesskey=' + M.cfg.sesskey, // The path to the ajax callback script.
|
||||
cfg : {}, // A configuration variable.
|
||||
interval : null, // The interval object for refreshes.
|
||||
layout : null, // A reference to the layout used in this module.
|
||||
messages : [], // An array of messages.
|
||||
scrollable : true, // True is scrolling should occur.
|
||||
thememenu : null, // A reference to the menu for changing themes.
|
||||
|
||||
// Elements
|
||||
messageinput : null,
|
||||
@ -59,19 +58,19 @@ M.mod_chat_ajax.init = function(Y, cfg) {
|
||||
}, this.layout);
|
||||
this.layout.render();
|
||||
|
||||
// Gather the general elements
|
||||
// Gather the general elements.
|
||||
this.messageinput = Y.one('#input-message');
|
||||
this.sendbutton = Y.one('#button-send');
|
||||
this.messagebox = Y.one('#chat-messages');
|
||||
|
||||
// Set aria attributes to messagebox and chat-userlist
|
||||
// Set aria attributes to messagebox and chat-userlist.
|
||||
this.messagebox.set('role', 'log');
|
||||
this.messagebox.set('aria-live', 'polite');
|
||||
var userlist = Y.one('#chat-userlist');
|
||||
userlist.set('aria-live', 'polite');
|
||||
userlist.set('aria-relevant', 'all');
|
||||
|
||||
// Attach the default events for this module
|
||||
// Attach the default events for this module.
|
||||
this.sendbutton.on('click', this.send, this);
|
||||
this.messagebox.on('mouseenter', function() {
|
||||
this.scrollable = false;
|
||||
@ -80,12 +79,12 @@ M.mod_chat_ajax.init = function(Y, cfg) {
|
||||
this.scrollable = true;
|
||||
}, this);
|
||||
|
||||
// Send the message when the enter key is pressed
|
||||
// Send the message when the enter key is pressed.
|
||||
Y.on('key', this.send, this.messageinput, 'press:13', this);
|
||||
|
||||
document.title = this.cfg.chatroom_name;
|
||||
|
||||
// Prepare and execute the first AJAX request of information
|
||||
// Prepare and execute the first AJAX request of information.
|
||||
Y.io(this.api,{
|
||||
method : 'POST',
|
||||
data : build_querystring({
|
||||
@ -115,25 +114,25 @@ M.mod_chat_ajax.init = function(Y, cfg) {
|
||||
scope.update_messages();
|
||||
}, this.cfg.timer, this);
|
||||
|
||||
// Create and initalise theme changing menu
|
||||
// Create and initalise theme changing menu.
|
||||
this.thememenu = new Y.YUI2.widget.Menu('basicmenu', {xy:[0,0]});
|
||||
this.thememenu.addItems([
|
||||
{text: M.util.get_string('bubble', 'mod_chat'), url: this.cfg.chaturl+'&theme=bubble'},
|
||||
{text: M.util.get_string('compact', 'mod_chat'), url: this.cfg.chaturl+'&theme=compact'}
|
||||
{text: M.util.get_string('bubble', 'mod_chat'), url: this.cfg.chaturl + '&theme=bubble'},
|
||||
{text: M.util.get_string('compact', 'mod_chat'), url: this.cfg.chaturl + '&theme=compact'}
|
||||
]);
|
||||
if (this.cfg.showcoursetheme == 1) {
|
||||
this.thememenu.addItem({text: M.util.get_string('coursetheme', 'mod_chat'), url: this.cfg.chaturl+'&theme=course_theme'});
|
||||
this.thememenu.addItem({text: M.util.get_string('coursetheme', 'mod_chat'), url: this.cfg.chaturl + '&theme=course_theme'});
|
||||
}
|
||||
this.thememenu.render(document.body);
|
||||
Y.one('#choosetheme').on('click', function(e){
|
||||
this.moveTo((e.pageX-20), (e.pageY-20));
|
||||
Y.one('#choosetheme').on('click', function(e) {
|
||||
this.moveTo((e.pageX - 20), (e.pageY - 20));
|
||||
this.show();
|
||||
}, this.thememenu);
|
||||
},
|
||||
|
||||
append_message : function(key, message, row) {
|
||||
var item = Y.Node.create('<li id="mdl-chat-entry-'+key+'">'+message.message+'</li>');
|
||||
item.addClass((message.mymessage)?'mdl-chat-my-entry':'mdl-chat-entry');
|
||||
var item = Y.Node.create('<li id="mdl-chat-entry-' + key + '">' + message.message + '</li>');
|
||||
item.addClass((message.mymessage) ? 'mdl-chat-my-entry' : 'mdl-chat-entry');
|
||||
Y.one('#messages-list').append(item);
|
||||
if (message.type && message.type == 'beep') {
|
||||
Y.one('#chat-notify').setContent('<embed src="../beep.wav" autostart="true" hidden="true" name="beep" />');
|
||||
@ -143,7 +142,7 @@ M.mod_chat_ajax.init = function(Y, cfg) {
|
||||
send : function(e, beep) {
|
||||
this.sendbutton.set('value', M.str.chat.sending);
|
||||
var data = {
|
||||
chat_message : (!beep)?this.messageinput.get('value'):'',
|
||||
chat_message : (!beep) ? this.messageinput.get('value') : '',
|
||||
chat_sid : this.cfg.sid,
|
||||
theme : this.cfg.theme
|
||||
};
|
||||
@ -179,7 +178,7 @@ M.mod_chat_ajax.init = function(Y, cfg) {
|
||||
},
|
||||
|
||||
talkto: function (e, name) {
|
||||
this.messageinput.set('value', "To "+name+": ");
|
||||
this.messageinput.set('value', "To " + name + ": ");
|
||||
this.messageinput.focus();
|
||||
},
|
||||
|
||||
@ -214,18 +213,18 @@ M.mod_chat_ajax.init = function(Y, cfg) {
|
||||
}
|
||||
this.cfg.chat_lasttime = data.lasttime;
|
||||
this.cfg.chat_lastrow = data.lastrow;
|
||||
// Update messages
|
||||
// Update messages.
|
||||
for (var key in data.msgs){
|
||||
if (!M.util.in_array(key, this.messages)) {
|
||||
this.messages.push(key);
|
||||
this.append_message(key, data.msgs[key], data.lastrow);
|
||||
}
|
||||
}
|
||||
// Update users
|
||||
// Update users.
|
||||
this.update_users(data.users);
|
||||
// Scroll to the bottom of the message list
|
||||
if (this.scrollable) {
|
||||
Y.Node.getDOMNode(this.messagebox).parentNode.scrollTop+=500;
|
||||
Y.Node.getDOMNode(this.messagebox).parentNode.scrollTop += 500;
|
||||
}
|
||||
this.messageinput.focus();
|
||||
},
|
||||
@ -237,14 +236,14 @@ M.mod_chat_ajax.init = function(Y, cfg) {
|
||||
var list = Y.one('#users-list');
|
||||
list.get('children').remove();
|
||||
for (var i in users) {
|
||||
var li = Y.Node.create('<li><table><tr><td>'+users[i].picture+'</td><td></td></tr></table></li>');
|
||||
var li = Y.Node.create('<li><table><tr><td>' + users[i].picture + '</td><td></td></tr></table></li>');
|
||||
if (users[i].id == this.cfg.userid) {
|
||||
li.all('td').item(1).append(Y.Node.create('<strong><a target="_blank" href="'+users[i].url+'">'+ users[i].name+'</a></strong>'));
|
||||
li.all('td').item(1).append(Y.Node.create('<strong><a target="_blank" href="' + users[i].url + '">' + users[i].name + '</a></strong>'));
|
||||
} else {
|
||||
li.all('td').item(1).append(Y.Node.create('<div><a target="_blank" href="'+users[i].url+'">'+users[i].name+'</a></div>'));
|
||||
var talk = Y.Node.create('<a href="###">'+M.str.chat.talk+'</a>');
|
||||
li.all('td').item(1).append(Y.Node.create('<div><a target="_blank" href="' + users[i].url + '">' + users[i].name + '</a></div>'));
|
||||
var talk = Y.Node.create('<a href="###">' + M.str.chat.talk + '</a>');
|
||||
talk.on('click', this.talkto, this, users[i].name);
|
||||
var beep = Y.Node.create('<a href="###">'+M.str.chat.beep+'</a>');
|
||||
var beep = Y.Node.create('<a href="###">' + M.str.chat.beep + '</a>');
|
||||
beep.on('click', this.send, this, users[i].id);
|
||||
li.all('td').item(1).append(Y.Node.create('<div></div>').append(talk).append(' ').append(beep));
|
||||
}
|
||||
|
@ -1,4 +1,19 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$chattheme_cfg = new stdClass();
|
||||
$chattheme_cfg->avatar = true;
|
||||
$chattheme_cfg->align = true;
|
||||
|
@ -1,4 +1,19 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$chattheme_cfg = new stdClass();
|
||||
$chattheme_cfg->avatar = false;
|
||||
$chattheme_cfg->align = false;
|
||||
|
@ -1,4 +1,19 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$chattheme_cfg = new stdClass();
|
||||
$chattheme_cfg->avatar = false;
|
||||
$chattheme_cfg->align = false;
|
||||
|
@ -1,16 +1,30 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once('../lib.php');
|
||||
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$groupid = optional_param('groupid', 0, PARAM_INT); // only for teachers
|
||||
$groupid = optional_param('groupid', 0, PARAM_INT); // Only for teachers.
|
||||
$message = optional_param('message', '', PARAM_CLEANHTML);
|
||||
$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
|
||||
$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.
|
||||
|
||||
$url = new moodle_url('/mod/chat/gui_basic/index.php', array('id'=>$id));
|
||||
$url = new moodle_url('/mod/chat/gui_basic/index.php', array('id' => $id));
|
||||
if ($groupid !== 0) {
|
||||
$url->param('groupid', $groupid);
|
||||
}
|
||||
@ -28,11 +42,11 @@ if ($newonly !== 0) {
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
|
||||
if (!$chat = $DB->get_record('chat', array('id'=>$id))) {
|
||||
if (!$chat = $DB->get_record('chat', array('id' => $id))) {
|
||||
print_error('invalidid', 'chat');
|
||||
}
|
||||
|
||||
if (!$course = $DB->get_record('course', array('id'=>$chat->course))) {
|
||||
if (!$course = $DB->get_record('course', array('id' => $chat->course))) {
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
|
||||
@ -47,7 +61,7 @@ $PAGE->set_pagelayout('popup');
|
||||
$PAGE->set_popup_notification_allowed(false);
|
||||
|
||||
// Check to see if groups are being used here.
|
||||
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used.
|
||||
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used.
|
||||
if ($groupid = groups_get_activity_group($cm)) {
|
||||
if (!$group = groups_get_group($groupid)) {
|
||||
print_error('invalidgroupid');
|
||||
@ -61,10 +75,10 @@ $PAGE->set_popup_notification_allowed(false);
|
||||
$groupname = '';
|
||||
}
|
||||
|
||||
$strchat = get_string('modulename', 'chat'); // must be before current_language() in chat_login_user() to force course language!!!
|
||||
$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)) {
|
||||
$stridle = get_string('idle', 'chat');
|
||||
if (!$chatsid = chat_login_user($chat->id, 'basic', $groupid, $course)) {
|
||||
print_error('cantlogin', 'chat');
|
||||
}
|
||||
|
||||
@ -72,7 +86,7 @@ if (!$chatusers = chat_get_users($chat->id, $groupid, $cm->groupingid)) {
|
||||
print_error('errornousers', 'chat');
|
||||
}
|
||||
|
||||
$DB->set_field('chat_users', 'lastping', time(), array('sid'=>$chat_sid));
|
||||
$DB->set_field('chat_users', 'lastping', time(), array('sid' => $chatsid));
|
||||
|
||||
if (!isset($SESSION->chatprefs)) {
|
||||
$SESSION->chatprefs = array();
|
||||
@ -92,21 +106,21 @@ if (!empty($refresh) and data_submitted()) {
|
||||
|
||||
} else if (empty($refresh) and data_submitted() and confirm_sesskey()) {
|
||||
|
||||
if ($message!='') {
|
||||
if ($message != '') {
|
||||
|
||||
$chatuser = $DB->get_record('chat_users', array('sid' => $chat_sid));
|
||||
$chatuser = $DB->get_record('chat_users', array('sid' => $chatsid));
|
||||
chat_send_chatmessage($chatuser, $message, 0, $cm);
|
||||
|
||||
$DB->set_field('chat_users', 'lastmessageping', time(), array('sid'=>$chat_sid));
|
||||
$DB->set_field('chat_users', 'lastmessageping', time(), array('sid' => $chatsid));
|
||||
}
|
||||
|
||||
chat_delete_old_users();
|
||||
|
||||
$url = new moodle_url('/mod/chat/gui_basic/index.php', array('id'=>$id, 'newonly'=>$newonly, 'last'=>$last));
|
||||
$url = new moodle_url('/mod/chat/gui_basic/index.php', array('id' => $id, 'newonly' => $newonly, 'last' => $last));
|
||||
redirect($url);
|
||||
}
|
||||
|
||||
$PAGE->set_title("$strchat: $course->shortname: ".format_string($chat->name,true)."$groupname");
|
||||
$PAGE->set_title("$strchat: $course->shortname: ".format_string($chat->name, true)."$groupname");
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->container_start(null, 'page-mod-chat-gui_basic');
|
||||
|
||||
@ -117,9 +131,9 @@ echo $OUTPUT->heading(get_string('participants'), 3);
|
||||
|
||||
echo $OUTPUT->box_start('generalbox', 'participants');
|
||||
echo '<ul>';
|
||||
foreach($chatusers as $chu) {
|
||||
foreach ($chatusers as $chu) {
|
||||
echo '<li class="clearfix">';
|
||||
echo $OUTPUT->user_picture($chu, array('size'=>24, 'courseid'=>$course->id));
|
||||
echo $OUTPUT->user_picture($chu, array('size' => 24, 'courseid' => $course->id));
|
||||
echo '<div class="userinfo">';
|
||||
echo fullname($chu).' ';
|
||||
if ($idle = time() - $chu->lastmessageping) {
|
||||
@ -145,7 +159,8 @@ echo '<input type="hidden" name="last" value="'.time().'" />';
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
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 '<input type="checkbox" name="newonly" id="newonly" '.($newonly ? 'checked="checked" ' : '').'/>';
|
||||
echo '<label for="newonly">'.get_string('newonlymsg', 'message').'</label>';
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
@ -158,7 +173,7 @@ $options = new stdClass();
|
||||
$options->para = false;
|
||||
$options->newlines = true;
|
||||
|
||||
$params = array('last'=>$last, 'groupid'=>$groupid, 'chatid'=>$chat->id, 'chatentered'=>$chatentered);
|
||||
$params = array('last' => $last, 'groupid' => $groupid, 'chatid' => $chat->id, 'chatentered' => $chatentered);
|
||||
|
||||
if ($newonly) {
|
||||
$lastsql = "AND timestamp > :last";
|
||||
|
@ -1,21 +1,35 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
define('NO_MOODLE_COOKIES', true); // session not used here
|
||||
define('NO_MOODLE_COOKIES', true); // Session not used here.
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once($CFG->dirroot.'/mod/chat/lib.php');
|
||||
|
||||
$chat_sid = required_param('chat_sid', PARAM_ALPHANUM);
|
||||
$chatsid = required_param('chat_sid', PARAM_ALPHANUM);
|
||||
$chatid = required_param('chat_id', PARAM_INT);
|
||||
|
||||
if (!$chatuser = $DB->get_record('chat_users', array('sid'=>$chat_sid))) {
|
||||
if (!$chatuser = $DB->get_record('chat_users', array('sid' => $chatsid))) {
|
||||
print_error('notlogged', 'chat');
|
||||
}
|
||||
if (!$chat = $DB->get_record('chat', array('id'=>$chatid))) {
|
||||
if (!$chat = $DB->get_record('chat', array('id' => $chatid))) {
|
||||
print_error('invalidid', 'chat');
|
||||
}
|
||||
|
||||
if (!$course = $DB->get_record('course', array('id'=>$chat->course))) {
|
||||
if (!$course = $DB->get_record('course', array('id' => $chat->course))) {
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
|
||||
@ -23,12 +37,11 @@ if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
$PAGE->set_url('/mod/chat/gui_header_js/chatinput.php', array('chat_sid'=>$chat_sid, 'chat_id'=>$chatid));
|
||||
$PAGE->set_url('/mod/chat/gui_header_js/chatinput.php', array('chat_sid' => $chatsid, 'chat_id' => $chatid));
|
||||
$PAGE->set_popup_notification_allowed(false);
|
||||
|
||||
//Get the user theme
|
||||
$USER = $DB->get_record('user', array('id'=>$chatuser->userid));
|
||||
|
||||
// Get the user theme.
|
||||
$USER = $DB->get_record('user', array('id' => $chatuser->userid));
|
||||
|
||||
$module = array(
|
||||
'name' => 'mod_chat_header',
|
||||
@ -37,23 +50,31 @@ $module = array(
|
||||
);
|
||||
$PAGE->requires->js_init_call('M.mod_chat_header.init_input', array(false), false, $module);
|
||||
|
||||
//Setup course, lang and theme
|
||||
// Setup course, lang and theme.
|
||||
$PAGE->set_course($course);
|
||||
$PAGE->set_pagelayout('embedded');
|
||||
$PAGE->set_focuscontrol('input_chat_message');
|
||||
$PAGE->set_cacheable(false);
|
||||
echo $OUTPUT->header();
|
||||
|
||||
echo html_writer::start_tag('form', array('action'=>'../empty.php', 'method'=>'post', 'target'=>'empty', 'id'=>'inputForm', 'style'=>'margin:0'));
|
||||
echo html_writer::start_tag('form', array('action' => '../empty.php',
|
||||
'method' => 'post',
|
||||
'target' => 'empty',
|
||||
'id' => 'inputForm',
|
||||
'style' => 'margin:0'));
|
||||
echo html_writer::label(get_string('entermessage', 'chat'), 'input_chat_message', false, array('class' => 'accesshide'));
|
||||
echo html_writer::empty_tag('input', array('type'=>'text', 'id'=>'input_chat_message', 'name'=>'chat_message', 'size'=>'50', 'value'=>''));
|
||||
echo html_writer::empty_tag('input', array('type'=>'checkbox', 'id'=>'auto', 'checked'=>'checked', 'value'=>''));
|
||||
echo html_writer::tag('label', get_string('autoscroll', 'chat'), array('for'=>'auto'));
|
||||
echo html_writer::empty_tag('input', array('type' => 'text',
|
||||
'id' => 'input_chat_message',
|
||||
'name' => 'chat_message',
|
||||
'size' => '50',
|
||||
'value' => ''));
|
||||
echo html_writer::empty_tag('input', array('type' => 'checkbox', 'id' => 'auto', 'checked' => 'checked', 'value' => ''));
|
||||
echo html_writer::tag('label', get_string('autoscroll', 'chat'), array('for' => 'auto'));
|
||||
echo html_writer::end_tag('form');
|
||||
|
||||
echo html_writer::start_tag('form', array('action'=>'insert.php', 'method'=>'post', 'target'=>'empty', 'id'=>'sendForm'));
|
||||
echo html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'chat_sid', 'value'=>$chat_sid));
|
||||
echo html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'chat_message', 'id'=>'insert_chat_message'));
|
||||
echo html_writer::start_tag('form', array('action' => 'insert.php', 'method' => 'post', 'target' => 'empty', 'id' => 'sendForm'));
|
||||
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'chat_sid', 'value' => $chatsid));
|
||||
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'chat_message', 'id' => 'insert_chat_message'));
|
||||
echo html_writer::end_tag('form');
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
@ -1,22 +1,36 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once('../lib.php');
|
||||
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$groupid = optional_param('groupid', 0, PARAM_INT); //only for teachers
|
||||
$groupid = optional_param('groupid', 0, PARAM_INT); // Only for teachers.
|
||||
|
||||
$url = new moodle_url('/mod/chat/gui_header_js/index.php', array('id'=>$id));
|
||||
$url = new moodle_url('/mod/chat/gui_header_js/index.php', array('id' => $id));
|
||||
if ($groupid !== 0) {
|
||||
$url->param('groupid', $groupid);
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
|
||||
if (!$chat = $DB->get_record('chat', array('id'=>$id))) {
|
||||
if (!$chat = $DB->get_record('chat', array('id' => $id))) {
|
||||
print_error('invalidid', 'chat');
|
||||
}
|
||||
|
||||
if (!$course = $DB->get_record('course', array('id'=>$chat->course))) {
|
||||
if (!$course = $DB->get_record('course', array('id' => $chat->course))) {
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
|
||||
@ -30,8 +44,8 @@ require_login($course, false, $cm);
|
||||
|
||||
require_capability('mod/chat:chat', $context);
|
||||
|
||||
/// Check to see if groups are being used here
|
||||
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used
|
||||
// Check to see if groups are being used here.
|
||||
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used.
|
||||
if ($groupid = groups_get_activity_group($cm)) {
|
||||
if (!$group = groups_get_group($groupid)) {
|
||||
print_error('invalidgroupid');
|
||||
@ -45,15 +59,15 @@ require_capability('mod/chat:chat', $context);
|
||||
$groupname = '';
|
||||
}
|
||||
|
||||
$strchat = get_string('modulename', 'chat'); // must be before current_language() in chat_login_user() to force course language!!!
|
||||
$strchat = get_string('modulename', 'chat'); // Must be before current_language() in chat_login_user() to force course language!
|
||||
|
||||
if (!$chat_sid = chat_login_user($chat->id, 'header_js', $groupid, $course)) {
|
||||
if (!$chatsid = chat_login_user($chat->id, 'header_js', $groupid, $course)) {
|
||||
print_error('cantlogin', 'chat');
|
||||
}
|
||||
|
||||
$params = "chat_id=$id&chat_sid={$chat_sid}";
|
||||
$params = "chat_id=$id&chat_sid={$chatsid}";
|
||||
|
||||
// fallback to the old jsupdate, but allow other update modes
|
||||
// Fallback to the old jsupdate, but allow other update modes.
|
||||
$updatemode = 'jsupdate';
|
||||
if (!empty($CFG->chat_normal_updatemode)) {
|
||||
$updatemode = $CFG->chat_normal_updatemode;
|
||||
@ -67,7 +81,8 @@ $courseshortname = format_string($course->shortname, true, array('context' => co
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<title>
|
||||
<?php echo "$strchat: " . $courseshortname . ": " . format_string($chat->name, true, array('context' => $context)) . "$groupname" ?>
|
||||
<?php echo "$strchat: " . $courseshortname . ": ".
|
||||
format_string($chat->name, true, array('context' => $context)) . "$groupname" ?>
|
||||
</title>
|
||||
</head>
|
||||
<frameset cols="*,200" border="5" framespacing="no" frameborder="yes" marginwidth="2" marginheight="1">
|
||||
|
@ -1,22 +1,36 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
include('../../../config.php');
|
||||
include('../lib.php');
|
||||
require_once('../../../config.php');
|
||||
require_once('../lib.php');
|
||||
|
||||
$chat_sid = required_param('chat_sid', PARAM_ALPHANUM);
|
||||
$chat_message = required_param('chat_message', PARAM_RAW);
|
||||
$chatsid = required_param('chat_sid', PARAM_ALPHANUM);
|
||||
$chatmessage = required_param('chat_message', PARAM_RAW);
|
||||
|
||||
$PAGE->set_url('/mod/chat/gui_header_js/insert.php', array('chat_sid'=>$chat_sid,'chat_message'=>$chat_message));
|
||||
$PAGE->set_url('/mod/chat/gui_header_js/insert.php', array('chat_sid' => $chatsid, 'chat_message' => $chatmessage));
|
||||
|
||||
if (!$chatuser = $DB->get_record('chat_users', array('sid'=>$chat_sid))) {
|
||||
if (!$chatuser = $DB->get_record('chat_users', array('sid' => $chatsid))) {
|
||||
print_error('notlogged', 'chat');
|
||||
}
|
||||
|
||||
if (!$chat = $DB->get_record('chat', array('id'=>$chatuser->chatid))) {
|
||||
if (!$chat = $DB->get_record('chat', array('id' => $chatuser->chatid))) {
|
||||
print_error('nochat', 'chat');
|
||||
}
|
||||
|
||||
if (!$course = $DB->get_record('course', array('id'=>$chat->course))) {
|
||||
if (!$course = $DB->get_record('course', array('id' => $chat->course))) {
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
|
||||
@ -32,19 +46,19 @@ if (isguestuser()) {
|
||||
|
||||
\core\session\manager::write_close();
|
||||
|
||||
/// Delete old users now
|
||||
// Delete old users now.
|
||||
|
||||
chat_delete_old_users();
|
||||
|
||||
/// Clean up the message
|
||||
// Clean up the message.
|
||||
|
||||
$chat_message = clean_text($chat_message, FORMAT_MOODLE); // Strip bad tags
|
||||
$chatmessage = clean_text($chatmessage, FORMAT_MOODLE); // Strip bad tags.
|
||||
|
||||
/// Add the message to the database
|
||||
// Add the message to the database.
|
||||
|
||||
if (!empty($chat_message)) {
|
||||
if (!empty($chatmessage)) {
|
||||
|
||||
chat_send_chatmessage($chatuser, $chat_message, 0, $cm);
|
||||
chat_send_chatmessage($chatuser, $chatmessage, 0, $cm);
|
||||
|
||||
$chatuser->lastmessageping = time() - 2;
|
||||
$DB->update_record('chat_users', $chatuser);
|
||||
@ -52,7 +66,7 @@ if (!empty($chat_message)) {
|
||||
|
||||
if ($chatuser->version == 'header_js') {
|
||||
|
||||
$forcerefreshasap = ($CFG->chat_normal_updatemode != 'jsupdated'); // See bug MDL-6791
|
||||
$forcerefreshasap = ($CFG->chat_normal_updatemode != 'jsupdated'); // See bug MDL-6791.
|
||||
|
||||
$module = array(
|
||||
'name' => 'mod_chat_header',
|
||||
@ -61,4 +75,4 @@ if ($chatuser->version == 'header_js') {
|
||||
$PAGE->requires->js_init_call('M.mod_chat_header.init_insert_nojsupdated', array($forcerefreshasap), true, $module);
|
||||
}
|
||||
|
||||
redirect('../empty.php');
|
||||
redirect('../empty.php');
|
||||
|
@ -1,61 +1,76 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
define('NO_MOODLE_COOKIES', true); // session not used here
|
||||
define('NO_MOODLE_COOKIES', true); // Session not used here.
|
||||
|
||||
require('../../../config.php');
|
||||
require('../lib.php');
|
||||
|
||||
$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);
|
||||
$chatsid = required_param('chat_sid', PARAM_ALPHANUM);
|
||||
$chatlasttime = optional_param('chat_lasttime', 0, PARAM_INT);
|
||||
$chatlastrow = optional_param('chat_lastrow', 1, PARAM_INT);
|
||||
|
||||
$url = new moodle_url('/mod/chat/gui_header_js/jsupdate.php', array('chat_sid'=>$chat_sid));
|
||||
if ($chat_lasttime !== 0) {
|
||||
$url->param('chat_lasttime', $chat_lasttime);
|
||||
$url = new moodle_url('/mod/chat/gui_header_js/jsupdate.php', array('chat_sid' => $chatsid));
|
||||
if ($chatlasttime !== 0) {
|
||||
$url->param('chat_lasttime', $chatlasttime);
|
||||
}
|
||||
if ($chat_lastrow !== 1) {
|
||||
$url->param('chat_lastrow', $chat_lastrow);
|
||||
if ($chatlastrow !== 1) {
|
||||
$url->param('chat_lastrow', $chatlastrow);
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
|
||||
|
||||
if (!$chatuser = $DB->get_record('chat_users', array('sid'=>$chat_sid))) {
|
||||
if (!$chatuser = $DB->get_record('chat_users', array('sid' => $chatsid))) {
|
||||
print_error('notlogged', 'chat');
|
||||
}
|
||||
|
||||
//Get the minimal course
|
||||
if (!$course = $DB->get_record('course', array('id'=>$chatuser->course))) {
|
||||
// Get the minimal course.
|
||||
if (!$course = $DB->get_record('course', array('id' => $chatuser->course))) {
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
|
||||
//Get the user theme and enough info to be used in chat_format_message() which passes it along to
|
||||
if (!$user = $DB->get_record('user', array('id'=>$chatuser->userid, 'deleted'=>0, 'suspended'=>0))) { // no optimisation here, it would break again in future!
|
||||
// Get the user theme and enough info to be used in chat_format_message() which passes it along to.
|
||||
// No optimisation here, it would break again in future!
|
||||
if (!$user = $DB->get_record('user', array('id' => $chatuser->userid, 'deleted' => 0, 'suspended' => 0))) {
|
||||
print_error('invaliduser');
|
||||
}
|
||||
\core\session\manager::set_user($user);
|
||||
|
||||
//Setup course, lang and theme
|
||||
// Setup course, lang and theme.
|
||||
$PAGE->set_course($course);
|
||||
|
||||
// force deleting of timed out users if there is a silence in room or just entering
|
||||
if ((time() - $chat_lasttime) > $CFG->chat_old_ping) {
|
||||
// must be done before chat_get_latest_message!!!
|
||||
// Force deleting of timed out users if there is a silence in room or just entering.
|
||||
if ((time() - $chatlasttime) > $CFG->chat_old_ping) {
|
||||
// Must be done before chat_get_latest_message!
|
||||
chat_delete_old_users();
|
||||
}
|
||||
|
||||
if ($message = chat_get_latest_message($chatuser->chatid, $chatuser->groupid)) {
|
||||
$chat_newlasttime = $message->timestamp;
|
||||
$chatnewlasttime = $message->timestamp;
|
||||
} else {
|
||||
$chat_newlasttime = 0;
|
||||
$chatnewlasttime = 0;
|
||||
}
|
||||
|
||||
if ($chat_lasttime == 0) { //display some previous messages
|
||||
$chat_lasttime = time() - $CFG->chat_old_ping; //TO DO - any better value??
|
||||
if ($chatlasttime == 0) { // Display some previous messages.
|
||||
$chatlasttime = time() - $CFG->chat_old_ping; // TO DO - any better value?
|
||||
}
|
||||
|
||||
$timenow = time();
|
||||
|
||||
$params = array('groupid'=>$chatuser->groupid, 'chatid'=>$chatuser->chatid, 'lasttime'=>$chat_lasttime);
|
||||
$params = array('groupid' => $chatuser->groupid, 'chatid' => $chatuser->chatid, 'lasttime' => $chatlasttime);
|
||||
|
||||
$groupselect = $chatuser->groupid ? " AND (groupid=:groupid OR groupid=0) " : "";
|
||||
|
||||
@ -69,11 +84,12 @@ if ($messages) {
|
||||
$num = 0;
|
||||
}
|
||||
|
||||
$chat_newrow = ($chat_lastrow + $num) % 2;
|
||||
$chatnewrow = ($chatlastrow + $num) % 2;
|
||||
|
||||
// no & in url, does not work in header!
|
||||
$refreshurl = "{$CFG->wwwroot}/mod/chat/gui_header_js/jsupdate.php?chat_sid=$chat_sid&chat_lasttime=$chat_newlasttime&chat_lastrow=$chat_newrow";
|
||||
$refreshurlamp = "{$CFG->wwwroot}/mod/chat/gui_header_js/jsupdate.php?chat_sid=$chat_sid&chat_lasttime=$chat_newlasttime&chat_lastrow=$chat_newrow";
|
||||
// No & in url, does not work in header!
|
||||
$baseurl = "{$CFG->wwwroot}/mod/chat/gui_header_js/jsupdate.php?";
|
||||
$refreshurl = $baseurl . "chat_sid=$chatsid&chat_lasttime=$chatnewlasttime&chat_lastrow=$chatnewrow";
|
||||
$refreshurlamp = $baseurl . "chat_sid=$chatsid&chat_lasttime=$chatnewlasttime&chat_lastrow=$chatnewrow";
|
||||
|
||||
header('Expires: Sun, 28 Dec 1997 09:32:45 GMT');
|
||||
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
|
||||
@ -82,15 +98,15 @@ header('Pragma: no-cache');
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
header("Refresh: $CFG->chat_refresh_room; url=$refreshurl");
|
||||
|
||||
/// required stylesheets
|
||||
// Required stylesheets.
|
||||
$stylesheetshtml = '';
|
||||
/*foreach ($CFG->stylesheets as $stylesheet) {
|
||||
//TODO: MDL-21120
|
||||
$stylesheetshtml .= '<link rel="stylesheet" type="text/css" href="'.$stylesheet.'" />';
|
||||
}*/
|
||||
|
||||
// use ob to be able to send Content-Length headers
|
||||
// needed for Keep-Alive to work
|
||||
// Use ob to be able to send Content-Length headers.
|
||||
// Needed for Keep-Alive to work.
|
||||
ob_start();
|
||||
|
||||
?>
|
||||
@ -104,9 +120,9 @@ ob_start();
|
||||
self.location.href= '<?php echo $refreshurl;?>';
|
||||
}
|
||||
var issafari = false;
|
||||
if(window.devicePixelRatio){
|
||||
if (window.devicePixelRatio) {
|
||||
issafari = true;
|
||||
setTimeout('safari_refresh()', <?php echo $CFG->chat_refresh_room*1000;?>);
|
||||
setTimeout('safari_refresh()', <?php echo $CFG->chat_refresh_room * 1000;?>);
|
||||
}
|
||||
if (parent.msg && parent.msg.document.getElementById("msgStarted") == null) {
|
||||
parent.msg.document.close();
|
||||
@ -118,52 +134,52 @@ ob_start();
|
||||
parent.msg.document.write("<?php echo addslashes_js($stylesheetshtml) ?>");
|
||||
parent.msg.document.write("<\/head><body class=\"mod-chat-gui_header_js course-<?php echo $chatuser->course ?>\" id=\"mod-chat-gui_header_js-jsupdate\"><div style=\"display: none\" id=\"msgStarted\"> <\/div>");
|
||||
}
|
||||
<?php
|
||||
$beep = false;
|
||||
$refreshusers = false;
|
||||
$us = array ();
|
||||
if (($chat_lasttime != $chat_newlasttime) and $messages) {
|
||||
<?php
|
||||
$beep = false;
|
||||
$refreshusers = false;
|
||||
$us = array ();
|
||||
if (($chatlasttime != $chatnewlasttime) and $messages) {
|
||||
|
||||
foreach ($messages as $message) {
|
||||
$chat_lastrow = ($chat_lastrow + 1) % 2;
|
||||
$formatmessage = chat_format_message($message, $chatuser->course, $USER, $chat_lastrow);
|
||||
if ($formatmessage->beep) {
|
||||
$beep = true;
|
||||
}
|
||||
if ($formatmessage->refreshusers) {
|
||||
$refreshusers = true;
|
||||
}
|
||||
$us[$message->userid] = $timenow - $message->timestamp;
|
||||
echo "if(parent.msg)";
|
||||
echo "parent.msg.document.write('".addslashes_js($formatmessage->html)."\\n');\n";
|
||||
}
|
||||
foreach ($messages as $message) {
|
||||
$chatlastrow = ($chatlastrow + 1) % 2;
|
||||
$formatmessage = chat_format_message($message, $chatuser->course, $USER, $chatlastrow);
|
||||
if ($formatmessage->beep) {
|
||||
$beep = true;
|
||||
}
|
||||
if ($formatmessage->refreshusers) {
|
||||
$refreshusers = true;
|
||||
}
|
||||
$us[$message->userid] = $timenow - $message->timestamp;
|
||||
echo "if(parent.msg)";
|
||||
echo "parent.msg.document.write('".addslashes_js($formatmessage->html)."\\n');\n";
|
||||
}
|
||||
}
|
||||
|
||||
$chatuser->lastping = time();
|
||||
$DB->set_field('chat_users', 'lastping', $chatuser->lastping, array('id'=>$chatuser->id));
|
||||
$chatuser->lastping = time();
|
||||
$DB->set_field('chat_users', 'lastping', $chatuser->lastping, array('id' => $chatuser->id));
|
||||
|
||||
if ($refreshusers) {
|
||||
?>
|
||||
if ($refreshusers) {
|
||||
?>
|
||||
var link = parent.users.document.getElementById('refreshLink');
|
||||
if (link != null) {
|
||||
parent.users.location.href = link.href;
|
||||
}
|
||||
<?php
|
||||
} else {
|
||||
foreach($us as $uid=>$lastping) {
|
||||
$min = (int) ($lastping/60);
|
||||
$sec = $lastping - ($min*60);
|
||||
$min = $min < 10 ? '0'.$min : $min;
|
||||
$sec = $sec < 10 ? '0'.$sec : $sec;
|
||||
$idle = $min.':'.$sec;
|
||||
echo "if (parent.users && parent.users.document.getElementById('uidle{$uid}') != null) {".
|
||||
"parent.users.document.getElementById('uidle{$uid}').innerHTML = '$idle';}\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
if(parent.input){
|
||||
<?php
|
||||
} else {
|
||||
foreach ($us as $uid => $lastping) {
|
||||
$min = (int) ($lastping / 60);
|
||||
$sec = $lastping - ($min * 60);
|
||||
$min = $min < 10 ? '0'.$min : $min;
|
||||
$sec = $sec < 10 ? '0'.$sec : $sec;
|
||||
$idle = $min.':'.$sec;
|
||||
echo "if (parent.users && parent.users.document.getElementById('uidle{$uid}') != null) {".
|
||||
"parent.users.document.getElementById('uidle{$uid}').innerHTML = '$idle';}\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
if (parent.input) {
|
||||
var autoscroll = parent.input.document.getElementById('auto');
|
||||
if(parent.msg && autoscroll && autoscroll.checked){
|
||||
if (parent.msg && autoscroll && autoscroll.checked) {
|
||||
parent.msg.scroll(1,5000000);
|
||||
}
|
||||
}
|
||||
@ -171,20 +187,18 @@ ob_start();
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
if ($beep) {
|
||||
echo '<embed src="../beep.wav" autostart="true" hidden="true" name="beep" />';
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
if ($beep) {
|
||||
echo '<embed src="../beep.wav" autostart="true" hidden="true" name="beep" />';
|
||||
}
|
||||
?>
|
||||
<a href="<?php echo $refreshurlamp ?>" name="refreshLink">Refresh link</a>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
|
||||
// support HTTP Keep-Alive
|
||||
// Support HTTP Keep-Alive.
|
||||
header("Content-Length: " . ob_get_length() );
|
||||
ob_end_flush();
|
||||
exit;
|
||||
|
||||
|
||||
?>
|
||||
|
@ -1,4 +1,18 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/** jsupdated.php - notes by Martin Langhoff <martin@catalyst.net.nz>
|
||||
**
|
||||
@ -15,77 +29,76 @@
|
||||
**
|
||||
**/
|
||||
|
||||
|
||||
define('CHAT_MAX_CLIENT_UPDATES', 1000);
|
||||
define('NO_MOODLE_COOKIES', true); // session not used here
|
||||
define('NO_MOODLE_COOKIES', true); // Session not used here.
|
||||
define('NO_OUTPUT_BUFFERING', true);
|
||||
|
||||
require('../../../config.php');
|
||||
require('../lib.php');
|
||||
|
||||
// we are going to run for a long time
|
||||
// avoid being terminated by php
|
||||
// We are going to run for a long time.
|
||||
// Avoid being terminated by php.
|
||||
core_php_time_limit::raise();
|
||||
|
||||
$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);
|
||||
$chat_lastid = optional_param('chat_lastid', 0, PARAM_INT);
|
||||
$chatsid = required_param('chat_sid', PARAM_ALPHANUM);
|
||||
$chatlasttime = optional_param('chat_lasttime', 0, PARAM_INT);
|
||||
$chatlastrow = optional_param('chat_lastrow', 1, PARAM_INT);
|
||||
$chatlastid = optional_param('chat_lastid', 0, PARAM_INT);
|
||||
|
||||
$url = new moodle_url('/mod/chat/gui_header_js/jsupdated.php', array('chat_sid'=>$chat_sid));
|
||||
if ($chat_lasttime !== 0) {
|
||||
$url->param('chat_lasttime', $chat_lasttime);
|
||||
$url = new moodle_url('/mod/chat/gui_header_js/jsupdated.php', array('chat_sid' => $chatsid));
|
||||
if ($chatlasttime !== 0) {
|
||||
$url->param('chat_lasttime', $chatlasttime);
|
||||
}
|
||||
if ($chat_lastrow !== 1) {
|
||||
$url->param('chat_lastrow', $chat_lastrow);
|
||||
if ($chatlastrow !== 1) {
|
||||
$url->param('chat_lastrow', $chatlastrow);
|
||||
}
|
||||
if ($chat_lastid !== 1) {
|
||||
$url->param('chat_lastid', $chat_lastid);
|
||||
if ($chatlastid !== 1) {
|
||||
$url->param('chat_lastid', $chatlastid);
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
|
||||
if (!$chatuser = $DB->get_record('chat_users', array('sid'=>$chat_sid))) {
|
||||
if (!$chatuser = $DB->get_record('chat_users', array('sid' => $chatsid))) {
|
||||
print_error('notlogged', 'chat');
|
||||
}
|
||||
|
||||
//Get the minimal course
|
||||
if (!$course = $DB->get_record('course', array('id'=>$chatuser->course))) {
|
||||
// Get the minimal course.
|
||||
if (!$course = $DB->get_record('course', array('id' => $chatuser->course))) {
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
|
||||
//Get the user theme and enough info to be used in chat_format_message() which passes it along to
|
||||
// Get the user theme and enough info to be used in chat_format_message() which passes it along to
|
||||
// chat_format_message_manually() -- and only id and timezone are used.
|
||||
if (!$user = $DB->get_record('user', array('id'=>$chatuser->userid, 'deleted'=>0, 'suspended'=>0))) { // no optimisation here, it would break again in future!
|
||||
// No optimisation here, it would break again in future!
|
||||
if (!$user = $DB->get_record('user', array('id' => $chatuser->userid, 'deleted' => 0, 'suspended' => 0))) {
|
||||
print_error('invaliduser');
|
||||
}
|
||||
\core\session\manager::set_user($user);
|
||||
|
||||
//Setup course, lang and theme
|
||||
// Setup course, lang and theme.
|
||||
$PAGE->set_course($course);
|
||||
|
||||
// force deleting of timed out users if there is a silence in room or just entering
|
||||
if ((time() - $chat_lasttime) > $CFG->chat_old_ping) {
|
||||
// must be done before chat_get_latest_message!!!
|
||||
// Force deleting of timed out users if there is a silence in room or just entering.
|
||||
if ((time() - $chatlasttime) > $CFG->chat_old_ping) {
|
||||
// Must be done before chat_get_latest_message!
|
||||
chat_delete_old_users();
|
||||
}
|
||||
|
||||
//
|
||||
// Time to send headers, and lay out the basic JS updater page
|
||||
//
|
||||
// Time to send headers, and lay out the basic JS updater page.
|
||||
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');
|
||||
header('Pragma: no-cache');
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
|
||||
/// required stylesheets
|
||||
// Required stylesheets.
|
||||
$stylesheetshtml = '';
|
||||
/*foreach ($CFG->stylesheets as $stylesheet) {
|
||||
//TODO: MDL-21120
|
||||
$stylesheetshtml .= '<link rel="stylesheet" type="text/css" href="'.$stylesheet.'" />';
|
||||
}*/
|
||||
|
||||
$refreshurl = "{$CFG->wwwroot}/mod/chat/gui_header_js/jsupdated.php?chat_sid=$chat_sid&chat_lasttime=$chat_lasttime&chat_lastrow=$chat_newrow&chat_lastid=$chat_lastid";
|
||||
$refreshurl = "{$CFG->wwwroot}/mod/chat/gui_header_js/jsupdated.php?".
|
||||
"chat_sid=$chatsid&chat_lasttime=$chatlasttime&chat_lastrow=$chatnewrow&chat_lastid=$chatlastid";
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html>
|
||||
@ -99,7 +112,7 @@ $refreshurl = "{$CFG->wwwroot}/mod/chat/gui_header_js/jsupdated.php?chat_sid=$ch
|
||||
var issafari = false;
|
||||
if(window.devicePixelRatio){
|
||||
issafari = true;
|
||||
setTimeout('safari_refresh()', <?php echo $CFG->chat_refresh_room*1000;?>);
|
||||
setTimeout('safari_refresh()', <?php echo $CFG->chat_refresh_room * 1000;?>);
|
||||
}
|
||||
if (parent.msg.document.getElementById("msgStarted") == null) {
|
||||
parent.msg.document.close();
|
||||
@ -118,126 +131,129 @@ $refreshurl = "{$CFG->wwwroot}/mod/chat/gui_header_js/jsupdated.php?chat_sid=$ch
|
||||
|
||||
<?php
|
||||
|
||||
// Ensure the HTML head makes it out there
|
||||
echo $CHAT_DUMMY_DATA;
|
||||
// Ensure the HTML head makes it out there.
|
||||
echo $CHAT_DUMMY_DATA;
|
||||
|
||||
for ($n=0; $n <= CHAT_MAX_CLIENT_UPDATES; $n++) {
|
||||
for ($n = 0; $n <= CHAT_MAX_CLIENT_UPDATES; $n++) {
|
||||
|
||||
// ping first so we can later shortcut as needed.
|
||||
$chatuser->lastping = time();
|
||||
$DB->set_field('chat_users', 'lastping', $chatuser->lastping, array('id'=>$chatuser->id));
|
||||
// Ping first so we can later shortcut as needed.
|
||||
$chatuser->lastping = time();
|
||||
$DB->set_field('chat_users', 'lastping', $chatuser->lastping, array('id' => $chatuser->id));
|
||||
|
||||
if ($message = chat_get_latest_message($chatuser->chatid, $chatuser->groupid)) {
|
||||
$chat_newlasttime = $message->timestamp;
|
||||
$chat_newlastid = $message->id;
|
||||
} else {
|
||||
$chat_newlasttime = 0;
|
||||
$chat_newlastid = 0;
|
||||
print " \n";
|
||||
print $CHAT_DUMMY_DATA;
|
||||
sleep($CFG->chat_refresh_room);
|
||||
continue;
|
||||
}
|
||||
|
||||
$timenow = time();
|
||||
|
||||
$params = array('groupid'=>$chatuser->groupid, 'lastid'=>$chat_lastid, 'lasttime'=>$chat_lasttime, 'chatid'=>$chatuser->chatid);
|
||||
$groupselect = $chatuser->groupid ? " AND (groupid=:groupid OR groupid=0) " : "";
|
||||
|
||||
$newcriteria = '';
|
||||
if ($chat_lastid > 0) {
|
||||
$newcriteria = "id > :lastid";
|
||||
} else {
|
||||
if ($chat_lasttime == 0) { //display some previous messages
|
||||
$chat_lasttime = $timenow - $CFG->chat_old_ping; //TO DO - any better value??
|
||||
}
|
||||
$newcriteria = "timestamp > :lasttime";
|
||||
}
|
||||
|
||||
$messages = $DB->get_records_select("chat_messages_current",
|
||||
"chatid = :chatid AND $newcriteria $groupselect", $params,
|
||||
"timestamp ASC");
|
||||
|
||||
if ($messages) {
|
||||
$num = count($messages);
|
||||
} else {
|
||||
print " \n";
|
||||
print $CHAT_DUMMY_DATA;
|
||||
sleep($CFG->chat_refresh_room);
|
||||
continue;
|
||||
$num = 0;
|
||||
}
|
||||
|
||||
print '<script type="text/javascript">' . "\n";
|
||||
print "//<![CDATA[\n\n";
|
||||
|
||||
$chat_newrow = ($chat_lastrow + $num) % 2;
|
||||
|
||||
$refreshusers = false;
|
||||
$us = array ();
|
||||
if (($chat_lasttime != $chat_newlasttime) and $messages) {
|
||||
|
||||
$beep = false;
|
||||
$refreshusers = false;
|
||||
foreach ($messages as $message) {
|
||||
$chat_lastrow = ($chat_lastrow + 1) % 2;
|
||||
$formatmessage = chat_format_message($message, $chatuser->course, $USER, $chat_lastrow);
|
||||
if ($formatmessage->beep) {
|
||||
$beep = true;
|
||||
}
|
||||
if ($formatmessage->refreshusers) {
|
||||
$refreshusers = true;
|
||||
}
|
||||
$us[$message->userid] = $timenow - $message->timestamp;
|
||||
echo "parent.msg.document.write('".addslashes_js($formatmessage->html )."\\n');\n";
|
||||
|
||||
}
|
||||
// from the last message printed...
|
||||
// a strange case where lack of closures is useful!
|
||||
$chat_lasttime = $message->timestamp;
|
||||
$chat_lastid = $message->id;
|
||||
}
|
||||
|
||||
if ($refreshusers) {
|
||||
echo "if (parent.users.document.anchors[0] != null) {" .
|
||||
"parent.users.location.href = parent.users.document.anchors[0].href;}\n";
|
||||
} else {
|
||||
foreach($us as $uid=>$lastping) {
|
||||
$min = (int) ($lastping/60);
|
||||
$sec = $lastping - ($min*60);
|
||||
$min = $min < 10 ? '0'.$min : $min;
|
||||
$sec = $sec < 10 ? '0'.$sec : $sec;
|
||||
$idle = $min.':'.$sec;
|
||||
echo "if (parent.users.document.getElementById('uidle{$uid}') != null) {".
|
||||
"parent.users.document.getElementById('uidle{$uid}').innerHTML = '$idle';}\n";
|
||||
}
|
||||
}
|
||||
|
||||
print <<<EOD
|
||||
if(parent.input){
|
||||
var autoscroll = parent.input.document.getElementById('auto');
|
||||
if(parent.msg && autoscroll && autoscroll.checked){
|
||||
parent.msg.scroll(1,5000000);
|
||||
}
|
||||
}
|
||||
EOD;
|
||||
print "//]]>\n";
|
||||
print '</script>' . "\n\n";
|
||||
if ($beep) {
|
||||
print '<embed src="../beep.wav" autostart="true" hidden="true" name="beep" />';
|
||||
}
|
||||
if ($message = chat_get_latest_message($chatuser->chatid, $chatuser->groupid)) {
|
||||
$chatnewlasttime = $message->timestamp;
|
||||
$chatnewlastid = $message->id;
|
||||
} else {
|
||||
$chatnewlasttime = 0;
|
||||
$chatnewlastid = 0;
|
||||
print " \n";
|
||||
print $CHAT_DUMMY_DATA;
|
||||
sleep($CFG->chat_refresh_room);
|
||||
} // here ends the for() loop
|
||||
continue;
|
||||
}
|
||||
|
||||
$timenow = time();
|
||||
|
||||
$params = array('groupid' => $chatuser->groupid,
|
||||
'lastid' => $chatlastid,
|
||||
'lasttime' => $chatlasttime,
|
||||
'chatid' => $chatuser->chatid);
|
||||
$groupselect = $chatuser->groupid ? " AND (groupid=:groupid OR groupid=0) " : "";
|
||||
|
||||
$newcriteria = '';
|
||||
if ($chatlastid > 0) {
|
||||
$newcriteria = "id > :lastid";
|
||||
} else {
|
||||
if ($chatlasttime == 0) { // Display some previous messages.
|
||||
$chatlasttime = $timenow - $CFG->chat_old_ping; // TO DO - any better value?
|
||||
}
|
||||
$newcriteria = "timestamp > :lasttime";
|
||||
}
|
||||
|
||||
$messages = $DB->get_records_select("chat_messages_current",
|
||||
"chatid = :chatid AND $newcriteria $groupselect", $params,
|
||||
"timestamp ASC");
|
||||
|
||||
if ($messages) {
|
||||
$num = count($messages);
|
||||
} else {
|
||||
print " \n";
|
||||
print $CHAT_DUMMY_DATA;
|
||||
sleep($CFG->chat_refresh_room);
|
||||
continue;
|
||||
}
|
||||
|
||||
// here & should be written & :-D
|
||||
$refreshurl = "{$CFG->wwwroot}/mod/chat/gui_header_js/jsupdated.php?chat_sid=$chat_sid&chat_lasttime=$chat_lasttime&chat_lastrow=$chat_newrow&chat_lastid=$chat_lastid";
|
||||
print '<script type="text/javascript">' . "\n";
|
||||
print "//<![CDATA[ \n\n";
|
||||
print "location.href = '$refreshurl';\n";
|
||||
print "//<![CDATA[\n\n";
|
||||
|
||||
$chatnewrow = ($chatlastrow + $num) % 2;
|
||||
|
||||
$refreshusers = false;
|
||||
$us = array ();
|
||||
if (($chatlasttime != $chatnewlasttime) and $messages) {
|
||||
|
||||
$beep = false;
|
||||
$refreshusers = false;
|
||||
foreach ($messages as $message) {
|
||||
$chatlastrow = ($chatlastrow + 1) % 2;
|
||||
$formatmessage = chat_format_message($message, $chatuser->course, $USER, $chatlastrow);
|
||||
if ($formatmessage->beep) {
|
||||
$beep = true;
|
||||
}
|
||||
if ($formatmessage->refreshusers) {
|
||||
$refreshusers = true;
|
||||
}
|
||||
$us[$message->userid] = $timenow - $message->timestamp;
|
||||
echo "parent.msg.document.write('".addslashes_js($formatmessage->html )."\\n');\n";
|
||||
|
||||
}
|
||||
// From the last message printed.
|
||||
// A strange case where lack of closures is useful!
|
||||
$chatlasttime = $message->timestamp;
|
||||
$chatlastid = $message->id;
|
||||
}
|
||||
|
||||
if ($refreshusers) {
|
||||
echo "if (parent.users.document.anchors[0] != null) {" .
|
||||
"parent.users.location.href = parent.users.document.anchors[0].href;}\n";
|
||||
} else {
|
||||
foreach ($us as $uid => $lastping) {
|
||||
$min = (int) ($lastping / 60);
|
||||
$sec = $lastping - ($min * 60);
|
||||
$min = $min < 10 ? '0'.$min : $min;
|
||||
$sec = $sec < 10 ? '0'.$sec : $sec;
|
||||
$idle = $min.':'.$sec;
|
||||
echo "if (parent.users.document.getElementById('uidle{$uid}') != null) {".
|
||||
"parent.users.document.getElementById('uidle{$uid}').innerHTML = '$idle';}\n";
|
||||
}
|
||||
}
|
||||
|
||||
print <<<EOD
|
||||
if(parent.input){
|
||||
var autoscroll = parent.input.document.getElementById('auto');
|
||||
if(parent.msg && autoscroll && autoscroll.checked){
|
||||
parent.msg.scroll(1,5000000);
|
||||
}
|
||||
}
|
||||
EOD;
|
||||
print "//]]>\n";
|
||||
print '</script>' . "\n\n";
|
||||
if ($beep) {
|
||||
print '<embed src="../beep.wav" autostart="true" hidden="true" name="beep" />';
|
||||
}
|
||||
print $CHAT_DUMMY_DATA;
|
||||
sleep($CFG->chat_refresh_room);
|
||||
} // Here ends the for() loop.
|
||||
|
||||
// Here & should be written & :-D.
|
||||
$refreshurl = "{$CFG->wwwroot}/mod/chat/gui_header_js/jsupdated.php?";
|
||||
$refreshurl .= "chat_sid=$chatsid&chat_lasttime=$chatlasttime&chat_lastrow=$chatnewrow&chat_lastid=$chatlastid";
|
||||
|
||||
print '<script type="text/javascript">' . "\n";
|
||||
print "//<![CDATA[ \n\n";
|
||||
print "location.href = '$refreshurl';\n";
|
||||
print "//]]>\n";
|
||||
print '</script>' . "\n\n";
|
||||
?>
|
||||
|
||||
</body>
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* NOTE: the /mod/chat/gui_header_js/ is not a real plugin,
|
||||
* ideally this code should be in /mod/chat/module.js
|
||||
@ -116,7 +115,7 @@ M.mod_chat_header.init_users = function(Y, users) {
|
||||
start : function() {
|
||||
this.timer = setTimeout(function(self) {
|
||||
self.update();
|
||||
}, this.timeout*1000, this);
|
||||
}, this.timeout * 1000, this);
|
||||
},
|
||||
/**
|
||||
* Stops the update timeout
|
||||
@ -134,11 +133,11 @@ M.mod_chat_header.init_users = function(Y, users) {
|
||||
*/
|
||||
update : function() {
|
||||
for (var i in this.users) {
|
||||
var el = Y.one('#uidle'+this.users[i]);
|
||||
var el = Y.one('#uidle' + this.users[i]);
|
||||
if (el) {
|
||||
var parts = el.get('innerHTML').split(':');
|
||||
var time = this.timeout + (parseInt(parts[0], 10)*60) + parseInt(parts[1], 10);
|
||||
var min = Math.floor(time/60);
|
||||
var time = this.timeout + (parseInt(parts[0], 10) * 60) + parseInt(parts[1], 10);
|
||||
var min = Math.floor(time / 60);
|
||||
var sec = time % 60;
|
||||
el.set('innerHTML', ((min < 10) ? "0" : "") + min + ":" + ((sec < 10) ? "0" : "") + sec);
|
||||
}
|
||||
|
@ -1,34 +1,49 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
define('NO_MOODLE_COOKIES', true); // session not used here
|
||||
define('NO_MOODLE_COOKIES', true); // Session not used here.
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once($CFG->dirroot.'/mod/chat/lib.php');
|
||||
|
||||
$chat_sid = required_param('chat_sid', PARAM_ALPHANUM);
|
||||
$beep = optional_param('beep', 0, PARAM_INT); // beep target
|
||||
$chatsid = required_param('chat_sid', PARAM_ALPHANUM);
|
||||
$beep = optional_param('beep', 0, PARAM_INT); // Beep target.
|
||||
|
||||
$PAGE->set_url('/mod/chat/gui_header_js/users.php', array('chat_sid'=>$chat_sid));
|
||||
$PAGE->set_url('/mod/chat/gui_header_js/users.php', array('chat_sid' => $chatsid));
|
||||
$PAGE->set_popup_notification_allowed(false);
|
||||
|
||||
if (!$chatuser = $DB->get_record('chat_users', array('sid'=>$chat_sid))) {
|
||||
if (!$chatuser = $DB->get_record('chat_users', array('sid' => $chatsid))) {
|
||||
print_error('notlogged', 'chat');
|
||||
}
|
||||
|
||||
//Get the minimal course
|
||||
if (!$course = $DB->get_record('course', array('id'=>$chatuser->course))) {
|
||||
// Get the minimal course.
|
||||
if (!$course = $DB->get_record('course', array('id' => $chatuser->course))) {
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
|
||||
//Get the user theme and enough info to be used in chat_format_message() which passes it along to
|
||||
if (!$user = $DB->get_record('user', array('id'=>$chatuser->userid, 'deleted'=>0, 'suspended'=>0))) { // no optimisation here, it would break again in future!
|
||||
// Get the user theme and enough info to be used in chat_format_message() which passes it along to.
|
||||
// No optimisation here, it would break again in future!
|
||||
if (!$user = $DB->get_record('user', array('id' => $chatuser->userid, 'deleted' => 0, 'suspended' => 0))) {
|
||||
print_error('invaliduser');
|
||||
}
|
||||
\core\session\manager::set_user($user);
|
||||
|
||||
$PAGE->set_pagelayout('embedded');
|
||||
|
||||
//Setup course, lang and theme
|
||||
// Setup course, lang and theme.
|
||||
$PAGE->set_course($course);
|
||||
|
||||
$courseid = $chatuser->course;
|
||||
@ -39,15 +54,15 @@ if (!$cm = get_coursemodule_from_instance('chat', $chatuser->chatid, $courseid))
|
||||
|
||||
if ($beep) {
|
||||
chat_send_chatmessage($chatuser, "beep $beep", 0, $cm);
|
||||
$chatuser->lastmessageping = time(); // A beep is a ping ;-)
|
||||
$chatuser->lastmessageping = time(); // A beep is a ping.
|
||||
}
|
||||
|
||||
$chatuser->lastping = time();
|
||||
$DB->set_field('chat_users', 'lastping', $chatuser->lastping, array('id'=>$chatuser->id));
|
||||
$DB->set_field('chat_users', 'lastping', $chatuser->lastping, array('id' => $chatuser->id));
|
||||
|
||||
$refreshurl = "users.php?chat_sid=$chat_sid";
|
||||
$refreshurl = "users.php?chat_sid=$chatsid";
|
||||
|
||||
/// Get list of users
|
||||
// Get list of users.
|
||||
|
||||
if (!$chatusers = chat_get_users($chatuser->chatid, $chatuser->groupid, $cm->groupingid)) {
|
||||
print_error('errornousers', 'chat');
|
||||
@ -65,7 +80,7 @@ $module = array(
|
||||
);
|
||||
$PAGE->requires->js_init_call('M.mod_chat_header.init_users', array($uidles), false, $module);
|
||||
|
||||
/// Print user panel body
|
||||
// Print user panel body.
|
||||
$timenow = time();
|
||||
$stridle = get_string('idle', 'chat');
|
||||
$strbeep = get_string('beep', 'chat');
|
||||
@ -75,19 +90,24 @@ $table->width = '100%';
|
||||
$table->data = array();
|
||||
foreach ($chatusers as $chatuser) {
|
||||
$lastping = $timenow - $chatuser->lastmessageping;
|
||||
$min = (int) ($lastping/60);
|
||||
$sec = $lastping - ($min*60);
|
||||
$min = (int) ($lastping / 60);
|
||||
$sec = $lastping - ($min * 60);
|
||||
$min = $min < 10 ? '0'.$min : $min;
|
||||
$sec = $sec < 10 ? '0'.$sec : $sec;
|
||||
$idle = $min.':'.$sec;
|
||||
|
||||
$row = array();
|
||||
$row[0] = $OUTPUT->user_picture($chatuser, array('courseid'=>$courseid, 'popup'=>true));
|
||||
$row[0] = $OUTPUT->user_picture($chatuser, array('courseid' => $courseid, 'popup' => true));
|
||||
$row[1] = html_writer::start_tag('p');
|
||||
$row[1] .= html_writer::start_tag('font', array('size'=>'1'));
|
||||
$row[1] .= html_writer::start_tag('font', array('size' => '1'));
|
||||
$row[1] .= fullname($chatuser).'<br />';
|
||||
$row[1] .= html_writer::tag('span', $stridle . html_writer::tag('span', $idle, array('name'=>'uidles', 'id'=>'uidle'.$chatuser->id)), array('class'=>'dimmed_text')).' ';
|
||||
$row[1] .= html_writer::tag('a', $strbeep, array('href'=>new moodle_url('/mod/chat/gui_header_js/users.php', array('chat_sid'=>$chat_sid, 'beep'=>$chatuser->id))));
|
||||
$row[1] .= html_writer::tag('span', $stridle . html_writer::tag('span',
|
||||
$idle,
|
||||
array('name' => 'uidles', 'id' => 'uidle'.$chatuser->id)),
|
||||
array('class' => 'dimmed_text')) . ' ';
|
||||
$row[1] .= html_writer::tag('a', $strbeep, array('href' => new moodle_url('/mod/chat/gui_header_js/users.php',
|
||||
array('chat_sid' => $chatsid,
|
||||
'beep' => $chatuser->id))));
|
||||
$row[1] .= html_writer::end_tag('font');
|
||||
$row[1] .= html_writer::end_tag('p');
|
||||
$table->data[] = $row;
|
||||
@ -95,11 +115,12 @@ foreach ($chatusers as $chatuser) {
|
||||
|
||||
ob_start();
|
||||
echo $OUTPUT->header();
|
||||
echo html_writer::tag('div', html_writer::tag('a', 'Refresh link', array('href'=>$refreshurl, 'id'=>'refreshLink')), array('style'=>'display:none')); //TODO: localize
|
||||
// TODO MDL-46477 localize the following string.
|
||||
echo html_writer::tag('div', html_writer::tag('a', 'Refresh link', array('href' => $refreshurl, 'id' => 'refreshLink')),
|
||||
array('style' => 'display:none'));
|
||||
echo html_writer::table($table);
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
//
|
||||
// Support HTTP Keep-Alive by printing Content-Length
|
||||
//
|
||||
// If the user pane is refreshing often, using keepalives
|
||||
@ -117,5 +138,5 @@ if ($CFG->chat_refresh_userlist < 15) {
|
||||
ob_end_flush();
|
||||
}
|
||||
|
||||
exit; // no further output
|
||||
exit; // No further output.
|
||||
|
||||
|
@ -4,11 +4,11 @@ function empty_field_and_submit() {
|
||||
var inpf = document.getElementById('inputform');
|
||||
cf.chat_msgidnr.value = parseInt(cf.chat_msgidnr.value) + 1;
|
||||
cf.chat_message.value = inpf.chat_message.value;
|
||||
inpf.chat_message.value='';
|
||||
inpf.chat_message.value = '';
|
||||
cf.submit();
|
||||
inpf.chat_message.focus();
|
||||
return false;
|
||||
}
|
||||
function setfocus() {
|
||||
document.getElementsByName("chat_message")[0].focus();
|
||||
}
|
||||
}
|
||||
|
@ -1,23 +1,37 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
define('NO_MOODLE_COOKIES', true); // session not used here
|
||||
define('NO_MOODLE_COOKIES', true); // Session not used here.
|
||||
|
||||
require('../../../config.php');
|
||||
require('../lib.php');
|
||||
|
||||
$chat_sid = required_param('chat_sid', PARAM_ALPHANUM);
|
||||
$chatsid = required_param('chat_sid', PARAM_ALPHANUM);
|
||||
|
||||
$PAGE->set_url('/mod/chat/gui_sockets/chatinput.php', array('chat_sid'=>$chat_sid));
|
||||
$PAGE->set_url('/mod/chat/gui_sockets/chatinput.php', array('chat_sid' => $chatsid));
|
||||
$PAGE->set_popup_notification_allowed(false);
|
||||
|
||||
if (!$chatuser = $DB->get_record('chat_users', array('sid'=>$chat_sid))) {
|
||||
if (!$chatuser = $DB->get_record('chat_users', array('sid' => $chatsid))) {
|
||||
print_error('notlogged', 'chat');
|
||||
}
|
||||
|
||||
//Get the user theme
|
||||
$USER = $DB->get_record('user', array('id'=>$chatuser->userid));
|
||||
// Get the user theme.
|
||||
$USER = $DB->get_record('user', array('id' => $chatuser->userid));
|
||||
|
||||
//Setup course, lang and theme
|
||||
// Setup course, lang and theme.
|
||||
$PAGE->set_pagelayout('embedded');
|
||||
$PAGE->set_course($DB->get_record('course', array('id' => $chatuser->course)));
|
||||
$PAGE->requires->js('/mod/chat/gui_sockets/chat_gui_sockets.js', true);
|
||||
@ -38,8 +52,8 @@ echo $OUTPUT->header();
|
||||
<input type="hidden" name="win" value="message" />
|
||||
<input type="hidden" name="chat_message" value="" />
|
||||
<input type="hidden" name="chat_msgidnr" value="0" />
|
||||
<input type="hidden" name="chat_sid" value="<?php echo $chat_sid ?>" />
|
||||
<input type="hidden" name="chat_sid" value="<?php echo $chatsid ?>" />
|
||||
</form>
|
||||
<?php
|
||||
echo $OUTPUT->footer();
|
||||
?>
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
|
@ -1,22 +1,36 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once('../lib.php');
|
||||
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$groupid = optional_param('groupid', 0, PARAM_INT); //only for teachers
|
||||
$groupid = optional_param('groupid', 0, PARAM_INT); // Only for teachers.
|
||||
|
||||
$url = new moodle_url('/mod/chat/gui_sockets/index.php', array('id'=>$id));
|
||||
$url = new moodle_url('/mod/chat/gui_sockets/index.php', array('id' => $id));
|
||||
if ($groupid !== 0) {
|
||||
$url->param('groupid', $groupid);
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
|
||||
if (!$chat = $DB->get_record('chat', array('id'=>$id))) {
|
||||
if (!$chat = $DB->get_record('chat', array('id' => $id))) {
|
||||
print_error('invalidid', 'chat');
|
||||
}
|
||||
|
||||
if (!$course = $DB->get_record('course', array('id'=>$chat->course))) {
|
||||
if (!$course = $DB->get_record('course', array('id' => $chat->course))) {
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
|
||||
@ -28,8 +42,8 @@ require_login($course, false, $cm);
|
||||
$context = context_module::instance($cm->id);
|
||||
require_capability('mod/chat:chat', $context);
|
||||
|
||||
/// Check to see if groups are being used here
|
||||
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used
|
||||
// Check to see if groups are being used here
|
||||
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used.
|
||||
if ($groupid = groups_get_activity_group($cm)) {
|
||||
if (!$group = groups_get_group($groupid)) {
|
||||
print_error('invalidgroupid');
|
||||
@ -43,30 +57,34 @@ require_capability('mod/chat:chat', $context);
|
||||
$groupname = '';
|
||||
}
|
||||
|
||||
$strchat = get_string('modulename', 'chat'); // must be before current_language() in chat_login_user() to force course language!!!
|
||||
$strchat = get_string('modulename', 'chat'); // Must be before current_language() in chat_login_user() to force course language!
|
||||
|
||||
if (!$chat_sid = chat_login_user($chat->id, 'sockets', $groupid, $course)) {
|
||||
if (!$chatsid = chat_login_user($chat->id, 'sockets', $groupid, $course)) {
|
||||
print_error('cantlogin');
|
||||
}
|
||||
|
||||
$params = "chat_sid=$chat_sid";
|
||||
$params = "chat_sid=$chatsid";
|
||||
$courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
|
||||
|
||||
$chatname = format_string($chat->name, true, array('context' => $context));
|
||||
$winchaturl = "http://$CFG->chat_serverhost:$CFG->chat_serverport?win=chat&$params";
|
||||
$winusersurl = "http://$CFG->chat_serverhost:$CFG->chat_serverport?win=users&$params"
|
||||
|
||||
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<title>
|
||||
<?php echo "$strchat: " . $courseshortname . ": " . format_string($chat->name, true, array('context' => $context)) . "$groupname" ?>
|
||||
<?php echo "$strchat: " . $courseshortname . ": " . $chatname . "$groupname" ?>
|
||||
</title>
|
||||
</head>
|
||||
<frameset cols="*,200" border="5" framespacing="no" frameborder="yes" marginwidth="2" marginheight="1">
|
||||
<frameset rows="0,*,70" border="0" framespacing="no" frameborder="no" marginwidth="2" marginheight="1">
|
||||
<frame src="../empty.php" name="empty" scrolling="auto" noresize marginwidth="2" marginheight="0">
|
||||
<frame src="<?php echo "http://$CFG->chat_serverhost:$CFG->chat_serverport?win=chat&$params"; ?>" scrolling="auto" name="msg" noresize marginwidth="2" marginheight="0">
|
||||
<frame src="<?php echo $winchaturl; ?>" scrolling="auto" name="msg" noresize marginwidth="2" marginheight="0">
|
||||
<frame src="chatinput.php?<?php echo $params ?>" name="input" scrolling="no" marginwidth="2" marginheight="1">
|
||||
</frameset>
|
||||
<frame src="<?php echo "http://$CFG->chat_serverhost:$CFG->chat_serverport?win=users&$params"; ?>" name="users" scrolling="auto" marginwidth="5" marginheight="5">
|
||||
<frame src="<?php echo $winusersurl; ?>" name="users" scrolling="auto" marginwidth="5" marginheight="5">
|
||||
</frameset>
|
||||
<noframes>
|
||||
Sorry, this version of Moodle Chat needs a browser that handles frames.
|
||||
|
@ -1,13 +1,27 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once('lib.php');
|
||||
|
||||
$id = required_param('id', PARAM_INT); // course
|
||||
$id = required_param('id', PARAM_INT); // Course.
|
||||
|
||||
$PAGE->set_url('/mod/chat/index.php', array('id'=>$id));
|
||||
$PAGE->set_url('/mod/chat/index.php', array('id' => $id));
|
||||
|
||||
if (! $course = $DB->get_record('course', array('id'=>$id))) {
|
||||
if (! $course = $DB->get_record('course', array('id' => $id))) {
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
|
||||
@ -21,21 +35,18 @@ $event = \mod_chat\event\course_module_instance_list_viewed::create($params);
|
||||
$event->add_record_snapshot('course', $course);
|
||||
$event->trigger();
|
||||
|
||||
/// Get all required strings
|
||||
|
||||
// Get all required strings.
|
||||
$strchats = get_string('modulenameplural', 'chat');
|
||||
$strchat = get_string('modulename', 'chat');
|
||||
|
||||
|
||||
/// Print the header
|
||||
// Print the header.
|
||||
$PAGE->navbar->add($strchats);
|
||||
$PAGE->set_title($strchats);
|
||||
$PAGE->set_heading($course->fullname);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($strchats, 2);
|
||||
|
||||
/// Get all the appropriate data
|
||||
|
||||
// Get all the appropriate data.
|
||||
if (! $chats = get_all_instances_in_course('chat', $course)) {
|
||||
notice(get_string('thereareno', 'moodle', $strchats), "../../course/view.php?id=$course->id");
|
||||
die();
|
||||
@ -43,7 +54,7 @@ if (! $chats = get_all_instances_in_course('chat', $course)) {
|
||||
|
||||
$usesections = course_format_uses_sections($course->format);
|
||||
|
||||
/// Print the list of instances (your module will probably extend this)
|
||||
// Print the list of instances (your module will probably extend this).
|
||||
|
||||
$timenow = time();
|
||||
$strname = get_string('name');
|
||||
@ -62,11 +73,11 @@ if ($usesections) {
|
||||
$currentsection = '';
|
||||
foreach ($chats as $chat) {
|
||||
if (!$chat->visible) {
|
||||
//Show dimmed if the mod is hidden
|
||||
$link = "<a class=\"dimmed\" href=\"view.php?id=$chat->coursemodule\">".format_string($chat->name,true)."</a>";
|
||||
// Show dimmed if the mod is hidden.
|
||||
$link = "<a class=\"dimmed\" href=\"view.php?id=$chat->coursemodule\">".format_string($chat->name, true)."</a>";
|
||||
} else {
|
||||
//Show normal if the mod is visible
|
||||
$link = "<a href=\"view.php?id=$chat->coursemodule\">".format_string($chat->name,true)."</a>";
|
||||
// Show normal if the mod is visible.
|
||||
$link = "<a href=\"view.php?id=$chat->coursemodule\">".format_string($chat->name, true)."</a>";
|
||||
}
|
||||
$printsection = '';
|
||||
if ($chat->section !== $currentsection) {
|
||||
@ -89,8 +100,7 @@ echo '<br />';
|
||||
|
||||
echo html_writer::table($table);
|
||||
|
||||
/// Finish the page
|
||||
// Finish the page.
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
393
mod/chat/lib.php
393
mod/chat/lib.php
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@ -25,17 +24,17 @@
|
||||
|
||||
require_once($CFG->dirroot.'/calendar/lib.php');
|
||||
|
||||
// The HTML head for the message window to start with (<!-- nix --> is used to get some browsers starting with output
|
||||
// The HTML head for the message window to start with (<!-- nix --> is used to get some browsers starting with output.
|
||||
global $CHAT_HTMLHEAD;
|
||||
$CHAT_HTMLHEAD = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\"><html><head></head>\n<body>\n\n".padding(200);
|
||||
|
||||
// The HTML head for the message window to start with (with js scrolling)
|
||||
// The HTML head for the message window to start with (with js scrolling).
|
||||
global $CHAT_HTMLHEAD_JS;
|
||||
$CHAT_HTMLHEAD_JS = <<<EOD
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html><head><script type="text/javascript">
|
||||
//<![CDATA[
|
||||
function move(){
|
||||
function move() {
|
||||
if (scroll_active)
|
||||
window.scroll(1,400000);
|
||||
window.setTimeout("move()",100);
|
||||
@ -50,15 +49,15 @@ EOD;
|
||||
global $CHAT_HTMLHEAD_JS;
|
||||
$CHAT_HTMLHEAD_JS .= padding(200);
|
||||
|
||||
// The HTML code for standard empty pages (e.g. if a user was kicked out)
|
||||
// The HTML code for standard empty pages (e.g. if a user was kicked out).
|
||||
global $CHAT_HTMLHEAD_OUT;
|
||||
$CHAT_HTMLHEAD_OUT = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\"><html><head><title>You are out!</title></head><body></body></html>";
|
||||
|
||||
// The HTML head for the message input page
|
||||
// The HTML head for the message input page.
|
||||
global $CHAT_HTMLHEAD_MSGINPUT;
|
||||
$CHAT_HTMLHEAD_MSGINPUT = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\"><html><head><title>Message Input</title></head><body>";
|
||||
|
||||
// The HTML code for the message input page, with JavaScript
|
||||
// The HTML code for the message input page, with JavaScript.
|
||||
global $CHAT_HTMLHEAD_MSGINPUT_JS;
|
||||
$CHAT_HTMLHEAD_MSGINPUT_JS = <<<EOD
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
@ -67,7 +66,7 @@ $CHAT_HTMLHEAD_MSGINPUT_JS = <<<EOD
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
scroll_active = true;
|
||||
function empty_field_and_submit(){
|
||||
function empty_field_and_submit() {
|
||||
document.fdummy.arsc_message.value=document.f.arsc_message.value;
|
||||
document.fdummy.submit();
|
||||
document.f.arsc_message.focus();
|
||||
@ -79,7 +78,7 @@ $CHAT_HTMLHEAD_MSGINPUT_JS = <<<EOD
|
||||
</head><body OnLoad="document.f.arsc_message.focus();document.f.arsc_message.select();">;
|
||||
EOD;
|
||||
|
||||
// Dummy data that gets output to the browser as needed, in order to make it show output
|
||||
// Dummy data that gets output to the browser as needed, in order to make it show output.
|
||||
global $CHAT_DUMMY_DATA;
|
||||
$CHAT_DUMMY_DATA = padding(200);
|
||||
|
||||
@ -87,10 +86,10 @@ $CHAT_DUMMY_DATA = padding(200);
|
||||
* @param int $n
|
||||
* @return string
|
||||
*/
|
||||
function padding($n){
|
||||
function padding($n) {
|
||||
$str = '';
|
||||
for($i=0; $i<$n; $i++){
|
||||
$str.="<!-- nix -->\n";
|
||||
for ($i = 0; $i < $n; $i++) {
|
||||
$str .= "<!-- nix -->\n";
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
@ -144,12 +143,11 @@ function chat_update_instance($chat) {
|
||||
$chat->timemodified = time();
|
||||
$chat->id = $chat->instance;
|
||||
|
||||
|
||||
$DB->update_record("chat", $chat);
|
||||
|
||||
$event = new stdClass();
|
||||
|
||||
if ($event->id = $DB->get_field('event', 'id', array('modulename'=>'chat', 'instance'=>$chat->id))) {
|
||||
if ($event->id = $DB->get_field('event', 'id', array('modulename' => 'chat', 'instance' => $chat->id))) {
|
||||
|
||||
$event->name = $chat->name;
|
||||
$event->description = format_module_intro('chat', $chat, $chat->coursemodule);
|
||||
@ -174,29 +172,28 @@ function chat_update_instance($chat) {
|
||||
function chat_delete_instance($id) {
|
||||
global $DB;
|
||||
|
||||
|
||||
if (! $chat = $DB->get_record('chat', array('id'=>$id))) {
|
||||
if (! $chat = $DB->get_record('chat', array('id' => $id))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = true;
|
||||
|
||||
// Delete any dependent records here
|
||||
// Delete any dependent records here.
|
||||
|
||||
if (! $DB->delete_records('chat', array('id'=>$chat->id))) {
|
||||
if (! $DB->delete_records('chat', array('id' => $chat->id))) {
|
||||
$result = false;
|
||||
}
|
||||
if (! $DB->delete_records('chat_messages', array('chatid'=>$chat->id))) {
|
||||
if (! $DB->delete_records('chat_messages', array('chatid' => $chat->id))) {
|
||||
$result = false;
|
||||
}
|
||||
if (! $DB->delete_records('chat_messages_current', array('chatid'=>$chat->id))) {
|
||||
if (! $DB->delete_records('chat_messages_current', array('chatid' => $chat->id))) {
|
||||
$result = false;
|
||||
}
|
||||
if (! $DB->delete_records('chat_users', array('chatid'=>$chat->id))) {
|
||||
if (! $DB->delete_records('chat_users', array('chatid' => $chat->id))) {
|
||||
$result = false;
|
||||
}
|
||||
|
||||
if (! $DB->delete_records('event', array('modulename'=>'chat', 'instance'=>$chat->id))) {
|
||||
if (! $DB->delete_records('event', array('modulename' => 'chat', 'instance' => $chat->id))) {
|
||||
$result = false;
|
||||
}
|
||||
|
||||
@ -218,7 +215,7 @@ function chat_delete_instance($id) {
|
||||
function chat_print_recent_activity($course, $viewfullnames, $timestart) {
|
||||
global $CFG, $USER, $DB, $OUTPUT;
|
||||
|
||||
// this is approximate only, but it is really fast ;-)
|
||||
// This is approximate only, but it is really fast.
|
||||
$timeout = $CFG->chat_old_ping * 10;
|
||||
|
||||
if (!$mcms = $DB->get_records_sql("SELECT cm.id, MAX(chm.timestamp) AS lasttime
|
||||
@ -234,9 +231,9 @@ function chat_print_recent_activity($course, $viewfullnames, $timestart) {
|
||||
|
||||
$past = array();
|
||||
$current = array();
|
||||
$modinfo = get_fast_modinfo($course); // reference needed because we might load the groups
|
||||
$modinfo = get_fast_modinfo($course); // Reference needed because we might load the groups.
|
||||
|
||||
foreach ($mcms as $cmid=>$mcm) {
|
||||
foreach ($mcms as $cmid => $mcm) {
|
||||
if (!array_key_exists($cmid, $modinfo->cms)) {
|
||||
continue;
|
||||
}
|
||||
@ -256,13 +253,13 @@ function chat_print_recent_activity($course, $viewfullnames, $timestart) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// verify groups in separate mode
|
||||
// Verify groups in separate mode.
|
||||
if (!$mygroupids = $modinfo->get_groups($cm->groupingid)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// ok, last post was not for my group - we have to query db to get last message from one of my groups
|
||||
// only minor problem is that the order will not be correct
|
||||
// Ok, last post was not for my group - we have to query db to get last message from one of my groups.
|
||||
// The only minor problem is that the order will not be correct.
|
||||
$mygroupids = implode(',', $mygroupids);
|
||||
|
||||
if (!$mcm = $DB->get_record_sql("SELECT cm.id, MAX(chm.timestamp) AS lasttime
|
||||
@ -296,26 +293,26 @@ function chat_print_recent_activity($course, $viewfullnames, $timestart) {
|
||||
$link = $CFG->wwwroot.'/mod/chat/view.php?id='.$cm->id;
|
||||
$date = userdate($mcms[$cm->id]->lasttime, $strftimerecent);
|
||||
echo '<div class="head"><div class="date">'.$date.'</div></div>';
|
||||
echo '<div class="info"><a href="'.$link.'">'.format_string($cm->name,true).'</a></div>';
|
||||
echo '<div class="info"><a href="'.$link.'">'.format_string($cm->name, true).'</a></div>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($current) {
|
||||
echo $OUTPUT->heading(get_string("currentchats", 'chat').':', 3);
|
||||
|
||||
$oldest = floor((time()-$CFG->chat_old_ping)/10)*10; // better db caching
|
||||
$oldest = floor((time() - $CFG->chat_old_ping) / 10) * 10; // Better db caching.
|
||||
|
||||
$timeold = time() - $CFG->chat_old_ping;
|
||||
$timeold = floor($timeold/10)*10; // better db caching
|
||||
$timeoldext = time() - ($CFG->chat_old_ping*10); // JSless gui_basic needs much longer timeouts
|
||||
$timeoldext = floor($timeoldext/10)*10; // better db caching
|
||||
$timeold = floor($timeold / 10) * 10; // Better db caching.
|
||||
$timeoldext = time() - ($CFG->chat_old_ping * 10); // JSless gui_basic needs much longer timeouts.
|
||||
$timeoldext = floor($timeoldext / 10) * 10; // Better db caching.
|
||||
|
||||
$params = array('timeold'=>$timeold, 'timeoldext'=>$timeoldext, 'cmid'=>$cm->id);
|
||||
$params = array('timeold' => $timeold, 'timeoldext' => $timeoldext, 'cmid' => $cm->id);
|
||||
|
||||
$timeout = "AND ((chu.version<>'basic' AND chu.lastping>:timeold) OR (chu.version='basic' AND chu.lastping>:timeoldext))";
|
||||
|
||||
foreach ($current as $cm) {
|
||||
//count users first
|
||||
// Count users first.
|
||||
$mygroupids = $modinfo->groups[$cm->groupingid];
|
||||
if (!empty($mygroupids)) {
|
||||
list($subquery, $subparams) = $DB->get_in_or_equal($mygroupids, SQL_PARAMS_NAMED, 'gid');
|
||||
@ -339,13 +336,13 @@ function chat_print_recent_activity($course, $viewfullnames, $timestart) {
|
||||
$date = userdate($mcms[$cm->id]->lasttime, $strftimerecent);
|
||||
|
||||
echo '<div class="head"><div class="date">'.$date.'</div></div>';
|
||||
echo '<div class="info"><a href="'.$link.'">'.format_string($cm->name,true).'</a></div>';
|
||||
echo '<div class="info"><a href="'.$link.'">'.format_string($cm->name, true).'</a></div>';
|
||||
echo '<div class="userlist">';
|
||||
if ($users) {
|
||||
echo '<ul>';
|
||||
foreach ($users as $user) {
|
||||
echo '<li>'.fullname($user, $viewfullnames).'</li>';
|
||||
}
|
||||
foreach ($users as $user) {
|
||||
echo '<li>'.fullname($user, $viewfullnames).'</li>';
|
||||
}
|
||||
echo '</ul>';
|
||||
}
|
||||
echo '</div>';
|
||||
@ -370,8 +367,7 @@ function chat_cron () {
|
||||
|
||||
chat_delete_old_users();
|
||||
|
||||
/// Delete old messages with a
|
||||
/// single SQL query.
|
||||
// Delete old messages with a single SQL query.
|
||||
$subselect = "SELECT c.keepdays
|
||||
FROM {chat} c
|
||||
WHERE c.id = {chat_messages}.chatid";
|
||||
@ -406,7 +402,7 @@ function chat_refresh_events($courseid = 0) {
|
||||
global $DB;
|
||||
|
||||
if ($courseid) {
|
||||
if (! $chats = $DB->get_records("chat", array("course"=>$courseid))) {
|
||||
if (! $chats = $DB->get_records("chat", array("course" => $courseid))) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
@ -414,7 +410,7 @@ function chat_refresh_events($courseid = 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$moduleid = $DB->get_field('modules', 'id', array('name'=>'chat'));
|
||||
$moduleid = $DB->get_field('modules', 'id', array('name' => 'chat'));
|
||||
|
||||
foreach ($chats as $chat) {
|
||||
$cm = get_coursemodule_from_id('chat', $chat->id);
|
||||
@ -423,7 +419,7 @@ function chat_refresh_events($courseid = 0) {
|
||||
$event->description = format_module_intro('chat', $chat, $cm->id);
|
||||
$event->timestart = $chat->chattime;
|
||||
|
||||
if ($event->id = $DB->get_field('event', 'id', array('modulename'=>'chat', 'instance'=>$chat->id))) {
|
||||
if ($event->id = $DB->get_field('event', 'id', array('modulename' => 'chat', 'instance' => $chat->id))) {
|
||||
$calendarevent = calendar_event::load($event->id);
|
||||
$calendarevent->update($event);
|
||||
} else {
|
||||
@ -434,7 +430,7 @@ function chat_refresh_events($courseid = 0) {
|
||||
$event->instance = $chat->id;
|
||||
$event->eventtype = 'chattime';
|
||||
$event->timeduration = 0;
|
||||
$event->visible = $DB->get_field('course_modules', 'visible', array('module'=>$moduleid, 'instance'=>$chat->id));
|
||||
$event->visible = $DB->get_field('course_modules', 'visible', array('module' => $moduleid, 'instance' => $chat->id));
|
||||
|
||||
calendar_event::create($event);
|
||||
}
|
||||
@ -442,9 +438,7 @@ function chat_refresh_events($courseid = 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
/// Functions that require some SQL
|
||||
// Functions that require some SQL.
|
||||
|
||||
/**
|
||||
* @global object
|
||||
@ -456,7 +450,7 @@ function chat_refresh_events($courseid = 0) {
|
||||
function chat_get_users($chatid, $groupid=0, $groupingid=0) {
|
||||
global $DB;
|
||||
|
||||
$params = array('chatid'=>$chatid, 'groupid'=>$groupid, 'groupingid'=>$groupingid);
|
||||
$params = array('chatid' => $chatid, 'groupid' => $groupid, 'groupingid' => $groupingid);
|
||||
|
||||
if ($groupid) {
|
||||
$groupselect = " AND (c.groupid=:groupid OR c.groupid='0')";
|
||||
@ -489,7 +483,7 @@ function chat_get_users($chatid, $groupid=0, $groupingid=0) {
|
||||
function chat_get_latest_message($chatid, $groupid=0) {
|
||||
global $DB;
|
||||
|
||||
$params = array('chatid'=>$chatid, 'groupid'=>$groupid);
|
||||
$params = array('chatid' => $chatid, 'groupid' => $groupid);
|
||||
|
||||
if ($groupid) {
|
||||
$groupselect = "AND (groupid=:groupid OR groupid=0)";
|
||||
@ -501,14 +495,10 @@ function chat_get_latest_message($chatid, $groupid=0) {
|
||||
FROM {chat_messages_current} WHERE chatid = :chatid $groupselect
|
||||
ORDER BY timestamp DESC";
|
||||
|
||||
// return the lastest one message
|
||||
// Return the lastest one message.
|
||||
return $DB->get_record_sql($sql, $params, true);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// login if not already logged in
|
||||
|
||||
/**
|
||||
* login if not already logged in
|
||||
*
|
||||
@ -523,16 +513,17 @@ function chat_get_latest_message($chatid, $groupid=0) {
|
||||
function chat_login_user($chatid, $version, $groupid, $course) {
|
||||
global $USER, $DB;
|
||||
|
||||
if (($version != 'sockets') and $chatuser = $DB->get_record('chat_users', array('chatid'=>$chatid, 'userid'=>$USER->id, 'groupid'=>$groupid))) {
|
||||
// this will update logged user information
|
||||
if (($version != 'sockets') and $chatuser = $DB->get_record('chat_users', array('chatid' => $chatid,
|
||||
'userid' => $USER->id,
|
||||
'groupid' => $groupid))) {
|
||||
// This will update logged user information.
|
||||
$chatuser->version = $version;
|
||||
$chatuser->ip = $USER->lastip;
|
||||
$chatuser->lastping = time();
|
||||
$chatuser->lang = current_language();
|
||||
|
||||
// Sometimes $USER->lastip is not setup properly
|
||||
// during login. Update with current value if possible
|
||||
// or provide a dummy value for the db
|
||||
// Sometimes $USER->lastip is not setup properly during login.
|
||||
// Update with current value if possible or provide a dummy value for the db.
|
||||
if (empty($chatuser->ip)) {
|
||||
$chatuser->ip = getremoteaddr();
|
||||
}
|
||||
@ -551,21 +542,19 @@ function chat_login_user($chatid, $version, $groupid, $course) {
|
||||
$chatuser->ip = $USER->lastip;
|
||||
$chatuser->lastping = $chatuser->firstping = $chatuser->lastmessageping = time();
|
||||
$chatuser->sid = random_string(32);
|
||||
$chatuser->course = $course->id; //caching - needed for current_language too
|
||||
$chatuser->lang = current_language(); //caching - to resource intensive to find out later
|
||||
$chatuser->course = $course->id; // Caching - needed for current_language too.
|
||||
$chatuser->lang = current_language(); // Caching - to resource intensive to find out later.
|
||||
|
||||
// Sometimes $USER->lastip is not setup properly
|
||||
// during login. Update with current value if possible
|
||||
// or provide a dummy value for the db
|
||||
// Sometimes $USER->lastip is not setup properly during login.
|
||||
// Update with current value if possible or provide a dummy value for the db.
|
||||
if (empty($chatuser->ip)) {
|
||||
$chatuser->ip = getremoteaddr();
|
||||
}
|
||||
|
||||
|
||||
$DB->insert_record('chat_users', $chatuser);
|
||||
|
||||
if ($version == 'sockets') {
|
||||
// do not send 'enter' message, chatd will do it
|
||||
// Do not send 'enter' message, chatd will do it.
|
||||
} else {
|
||||
chat_send_chatmessage($chatuser, 'enter', true);
|
||||
}
|
||||
@ -581,11 +570,11 @@ function chat_login_user($chatid, $version, $groupid, $course) {
|
||||
* @global object
|
||||
*/
|
||||
function chat_delete_old_users() {
|
||||
// Delete the old and in the way
|
||||
// Delete the old and in the way.
|
||||
global $CFG, $DB;
|
||||
|
||||
$timeold = time() - $CFG->chat_old_ping;
|
||||
$timeoldext = time() - ($CFG->chat_old_ping*10); // JSless gui_basic needs much longer timeouts
|
||||
$timeoldext = time() - ($CFG->chat_old_ping * 10); // JSless gui_basic needs much longer timeouts.
|
||||
|
||||
$query = "(version<>'basic' AND lastping<?) OR (version='basic' AND lastping<?)";
|
||||
$params = array($timeold, $timeoldext);
|
||||
@ -606,12 +595,12 @@ function chat_delete_old_users() {
|
||||
* @return void
|
||||
*/
|
||||
function chat_update_chat_times($chatid=0) {
|
||||
/// Updates chat records so that the next chat time is correct
|
||||
// Updates chat records so that the next chat time is correct.
|
||||
global $DB;
|
||||
|
||||
$timenow = time();
|
||||
|
||||
$params = array('timenow'=>$timenow, 'chatid'=>$chatid);
|
||||
$params = array('timenow' => $timenow, 'chatid' => $chatid);
|
||||
|
||||
if ($chatid) {
|
||||
if (!$chats[] = $DB->get_record_select("chat", "id = :chatid AND chattime <= :timenow AND schedule > 0", $params)) {
|
||||
@ -625,27 +614,27 @@ function chat_update_chat_times($chatid=0) {
|
||||
|
||||
foreach ($chats as $chat) {
|
||||
switch ($chat->schedule) {
|
||||
case 1: // Single event - turn off schedule and disable
|
||||
$chat->chattime = 0;
|
||||
$chat->schedule = 0;
|
||||
break;
|
||||
case 2: // Repeat daily
|
||||
while ($chat->chattime <= $timenow) {
|
||||
$chat->chattime += 24 * 3600;
|
||||
}
|
||||
break;
|
||||
case 3: // Repeat weekly
|
||||
while ($chat->chattime <= $timenow) {
|
||||
$chat->chattime += 7 * 24 * 3600;
|
||||
}
|
||||
break;
|
||||
case 1: // Single event - turn off schedule and disable.
|
||||
$chat->chattime = 0;
|
||||
$chat->schedule = 0;
|
||||
break;
|
||||
case 2: // Repeat daily.
|
||||
while ($chat->chattime <= $timenow) {
|
||||
$chat->chattime += 24 * 3600;
|
||||
}
|
||||
break;
|
||||
case 3: // Repeat weekly.
|
||||
while ($chat->chattime <= $timenow) {
|
||||
$chat->chattime += 7 * 24 * 3600;
|
||||
}
|
||||
break;
|
||||
}
|
||||
$DB->update_record("chat", $chat);
|
||||
|
||||
$event = new stdClass(); // Update calendar too
|
||||
$event = new stdClass(); // Update calendar too.
|
||||
|
||||
$cond = "modulename='chat' AND instance = :chatid AND timestart <> :chattime";
|
||||
$params = array('chattime'=>$chat->chattime, 'chatid'=>$chatid);
|
||||
$params = array('chattime' => $chat->chattime, 'chatid' => $chatid);
|
||||
|
||||
if ($event->id = $DB->get_field_select('event', 'id', $cond, $params)) {
|
||||
$event->timestart = $chat->chattime;
|
||||
@ -707,20 +696,20 @@ function chat_send_chatmessage($chatuser, $messagetext, $system = false, $cm = n
|
||||
* @param int $courseid
|
||||
* @param object $sender
|
||||
* @param object $currentuser
|
||||
* @param string $chat_lastrow
|
||||
* @param string $chatlastrow
|
||||
* @return bool|string Returns HTML or false
|
||||
*/
|
||||
function chat_format_message_manually($message, $courseid, $sender, $currentuser, $chat_lastrow=NULL) {
|
||||
function chat_format_message_manually($message, $courseid, $sender, $currentuser, $chatlastrow = null) {
|
||||
global $CFG, $USER, $OUTPUT;
|
||||
|
||||
$output = new stdClass();
|
||||
$output->beep = false; // by default
|
||||
$output->refreshusers = false; // by default
|
||||
$output->beep = false; // By default.
|
||||
$output->refreshusers = false; // By default.
|
||||
|
||||
// Use get_user_timezone() to find the correct timezone for displaying this message:
|
||||
// It's either the current user's timezone or else decided by some Moodle config setting
|
||||
// Use get_user_timezone() to find the correct timezone for displaying this message.
|
||||
// It's either the current user's timezone or else decided by some Moodle config setting.
|
||||
// First, "reset" $USER->timezone (which could have been set by a previous call to here)
|
||||
// because otherwise the value for the previous $currentuser will take precedence over $CFG->timezone
|
||||
// because otherwise the value for the previous $currentuser will take precedence over $CFG->timezone.
|
||||
$USER->timezone = 99;
|
||||
$tz = get_user_timezone($currentuser->timezone);
|
||||
|
||||
@ -730,78 +719,78 @@ function chat_format_message_manually($message, $courseid, $sender, $currentuser
|
||||
$USER->timezone = $tz;
|
||||
$message->strtime = userdate($message->timestamp, get_string('strftimemessage', 'chat'), $tz);
|
||||
|
||||
$message->picture = $OUTPUT->user_picture($sender, array('size'=>false, 'courseid'=>$courseid, 'link'=>false));
|
||||
$message->picture = $OUTPUT->user_picture($sender, array('size' => false, 'courseid' => $courseid, 'link' => false));
|
||||
|
||||
if ($courseid) {
|
||||
$message->picture = "<a onclick=\"window.open('$CFG->wwwroot/user/view.php?id=$sender->id&course=$courseid')\" href=\"$CFG->wwwroot/user/view.php?id=$sender->id&course=$courseid\">$message->picture</a>";
|
||||
$message->picture = "<a onclick=\"window.open('$CFG->wwwroot/user/view.php?id=$sender->id&course=$courseid')\"".
|
||||
$message->picture .= " href=\"$CFG->wwwroot/user/view.php?id=$sender->id&course=$courseid\">$message->picture</a>";
|
||||
}
|
||||
|
||||
//Calculate the row class
|
||||
if ($chat_lastrow !== NULL) {
|
||||
$rowclass = ' class="r'.$chat_lastrow.'" ';
|
||||
// Calculate the row class.
|
||||
if ($chatlastrow !== null) {
|
||||
$rowclass = ' class="r'.$chatlastrow.'" ';
|
||||
} else {
|
||||
$rowclass = '';
|
||||
}
|
||||
|
||||
// Start processing the message
|
||||
// Start processing the message.
|
||||
|
||||
if(!empty($message->system)) {
|
||||
// System event
|
||||
if (!empty($message->system)) {
|
||||
// System event.
|
||||
$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->html = '<table class="chat-event"><tr'.$rowclass.'><td class="picture">'.$message->picture.'</td>';
|
||||
$output->html .= '<td class="text"><span class="event">'.$output->text.'</span></td></tr></table>';
|
||||
$output->basic = '<tr class="r1">
|
||||
<th scope="row" class="cell c1 title"></th>
|
||||
<td class="cell c2 text">' . get_string('message'.$message->message, 'chat', fullname($sender)) . '</td>
|
||||
<td class="cell c3">' . $message->strtime . '</td>
|
||||
</tr>';
|
||||
if($message->message == 'exit' or $message->message == 'enter') {
|
||||
$output->refreshusers = true; //force user panel refresh ASAP
|
||||
if ($message->message == 'exit' or $message->message == 'enter') {
|
||||
$output->refreshusers = true; // Force user panel refresh ASAP.
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
// It's not a system event
|
||||
// It's not a system event.
|
||||
$text = trim($message->message);
|
||||
|
||||
/// Parse the text to clean and filter it
|
||||
// Parse the text to clean and filter it.
|
||||
$options = new stdClass();
|
||||
$options->para = false;
|
||||
$text = format_text($text, FORMAT_MOODLE, $options, $courseid);
|
||||
|
||||
// And now check for special cases
|
||||
$patternTo = '#^\s*To\s([^:]+):(.*)#';
|
||||
// And now check for special cases.
|
||||
$patternto = '#^\s*To\s([^:]+):(.*)#';
|
||||
$special = false;
|
||||
|
||||
if (substr($text, 0, 5) == 'beep ') {
|
||||
/// It's a beep!
|
||||
// It's a beep!
|
||||
$special = true;
|
||||
$beepwho = trim(substr($text, 5));
|
||||
|
||||
if ($beepwho == 'all') { // everyone
|
||||
if ($beepwho == 'all') { // Everyone.
|
||||
$outinfobasic = get_string('messagebeepseveryone', 'chat', fullname($sender));
|
||||
$outinfo = $message->strtime . ': ' . $outinfobasic;
|
||||
$outmain = '';
|
||||
|
||||
$output->beep = true; // (eventually this should be set to
|
||||
// to a filename uploaded by the user)
|
||||
$output->beep = true; // Eventually this should be set to a filename uploaded by the user.
|
||||
|
||||
} else if ($beepwho == $currentuser->id) { // current user
|
||||
} else if ($beepwho == $currentuser->id) { // Current user.
|
||||
$outinfobasic = get_string('messagebeepsyou', 'chat', fullname($sender));
|
||||
$outinfo = $message->strtime . ': ' . $outinfobasic;
|
||||
$outmain = '';
|
||||
$output->beep = true;
|
||||
|
||||
} else { //something is not caught?
|
||||
} else { // Something is not caught?
|
||||
return false;
|
||||
}
|
||||
} else if (substr($text, 0, 1) == '/') { /// It's a user command
|
||||
} else if (substr($text, 0, 1) == '/') { // It's a user command.
|
||||
$special = true;
|
||||
$pattern = '#(^\/)(\w+).*#';
|
||||
preg_match($pattern, $text, $matches);
|
||||
$command = isset($matches[2]) ? $matches[2] : false;
|
||||
// Support some IRC commands.
|
||||
switch ($command){
|
||||
switch ($command) {
|
||||
case 'me':
|
||||
$outinfo = $message->strtime;
|
||||
$outmain = '*** <b>'.$sender->firstname.' '.substr($text, 4).'</b>';
|
||||
@ -811,10 +800,10 @@ function chat_format_message_manually($message, $courseid, $sender, $currentuser
|
||||
$special = false;
|
||||
break;
|
||||
}
|
||||
} else if (preg_match($patternTo, $text)) {
|
||||
} else if (preg_match($patternto, $text)) {
|
||||
$special = true;
|
||||
$matches = array();
|
||||
preg_match($patternTo, $text, $matches);
|
||||
preg_match($patternto, $text, $matches);
|
||||
if (isset($matches[1]) && isset($matches[2])) {
|
||||
$outinfo = $message->strtime;
|
||||
$outmain = $sender->firstname.' '.get_string('saidto', 'chat').' <i>'.$matches[1].'</i>: '.$matches[2];
|
||||
@ -824,17 +813,17 @@ function chat_format_message_manually($message, $courseid, $sender, $currentuser
|
||||
}
|
||||
}
|
||||
|
||||
if(!$special) {
|
||||
if (!$special) {
|
||||
$outinfo = $message->strtime.' '.$sender->firstname;
|
||||
$outmain = $text;
|
||||
}
|
||||
|
||||
/// Format the message as a small table
|
||||
// Format the message as a small table.
|
||||
|
||||
$output->text = strip_tags($outinfo.': '.$outmain);
|
||||
|
||||
$output->html = "<table class=\"chat-message\"><tr$rowclass><td class=\"picture\" valign=\"top\">$message->picture</td><td class=\"text\">";
|
||||
$output->html .= "<span class=\"title\">$outinfo</span>";
|
||||
$output->html = "<table class=\"chat-message\"><tr$rowclass><td class=\"picture\" valign=\"top\">$message->picture</td>";
|
||||
$output->html .= "<td class=\"text\"><span class=\"title\">$outinfo</span>";
|
||||
if ($outmain) {
|
||||
$output->html .= ": $outmain";
|
||||
$output->basic = '<tr class="r0">
|
||||
@ -854,29 +843,27 @@ function chat_format_message_manually($message, $courseid, $sender, $currentuser
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a message object this function formats it appropriately into text and html then returns the formatted data
|
||||
* @global object
|
||||
* @param object $message
|
||||
* @param int $courseid
|
||||
* @param object $currentuser
|
||||
* @param string $chat_lastrow
|
||||
* @param string $chatlastrow
|
||||
* @return bool|string Returns HTML or false
|
||||
*/
|
||||
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.
|
||||
function chat_format_message($message, $courseid, $currentuser, $chatlastrow=null) {
|
||||
global $DB;
|
||||
|
||||
static $users; // Cache user lookups
|
||||
static $users; // Cache user lookups.
|
||||
|
||||
if (isset($users[$message->userid])) {
|
||||
$user = $users[$message->userid];
|
||||
} else if ($user = $DB->get_record('user', array('id'=>$message->userid), user_picture::fields())) {
|
||||
} else if ($user = $DB->get_record('user', array('id' => $message->userid), user_picture::fields())) {
|
||||
$users[$message->userid] = $user;
|
||||
} else {
|
||||
return NULL;
|
||||
return null;
|
||||
}
|
||||
return chat_format_message_manually($message, $courseid, $user, $currentuser, $chat_lastrow);
|
||||
return chat_format_message_manually($message, $courseid, $user, $currentuser, $chatlastrow);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -892,7 +879,7 @@ function chat_format_message_theme ($message, $chatuser, $currentuser, $grouping
|
||||
global $CFG, $USER, $OUTPUT, $COURSE, $DB, $PAGE;
|
||||
require_once($CFG->dirroot.'/mod/chat/locallib.php');
|
||||
|
||||
static $users; // Cache user lookups
|
||||
static $users; // Cache user lookups.
|
||||
|
||||
$result = new stdClass();
|
||||
|
||||
@ -902,10 +889,10 @@ function chat_format_message_theme ($message, $chatuser, $currentuser, $grouping
|
||||
|
||||
if (isset($users[$message->userid])) {
|
||||
$sender = $users[$message->userid];
|
||||
} else if ($sender = $DB->get_record('user', array('id'=>$message->userid), user_picture::fields())) {
|
||||
} else if ($sender = $DB->get_record('user', array('id' => $message->userid), user_picture::fields())) {
|
||||
$users[$message->userid] = $sender;
|
||||
} else {
|
||||
return NULL;
|
||||
return null;
|
||||
}
|
||||
|
||||
$USER->timezone = 99;
|
||||
@ -919,12 +906,13 @@ function chat_format_message_theme ($message, $chatuser, $currentuser, $grouping
|
||||
}
|
||||
|
||||
$message->strtime = userdate($message->timestamp, get_string('strftimemessage', 'chat'), $tz);
|
||||
$message->picture = $OUTPUT->user_picture($sender, array('courseid'=>$courseid));
|
||||
$message->picture = $OUTPUT->user_picture($sender, array('courseid' => $courseid));
|
||||
|
||||
$message->picture = "<a target='_blank' href=\"$CFG->wwwroot/user/view.php?id=$sender->id&course=$courseid\">$message->picture</a>";
|
||||
$message->picture = "<a target='_blank'".
|
||||
$message->picture .= " href=\"$CFG->wwwroot/user/view.php?id=$sender->id&course=$courseid\">$message->picture</a>";
|
||||
|
||||
// Start processing the message
|
||||
if(!empty($message->system)) {
|
||||
// Start processing the message.
|
||||
if (!empty($message->system)) {
|
||||
$result->type = 'system';
|
||||
|
||||
$senderprofile = $CFG->wwwroot.'/user/view.php?id='.$sender->id.'&course='.$courseid;
|
||||
@ -937,53 +925,53 @@ function chat_format_message_theme ($message, $chatuser, $currentuser, $grouping
|
||||
return $result;
|
||||
}
|
||||
|
||||
// It's not a system event
|
||||
// It's not a system event.
|
||||
$text = trim($message->message);
|
||||
|
||||
/// Parse the text to clean and filter it
|
||||
// Parse the text to clean and filter it.
|
||||
$options = new stdClass();
|
||||
$options->para = false;
|
||||
$text = format_text($text, FORMAT_MOODLE, $options, $courseid);
|
||||
|
||||
// And now check for special cases
|
||||
// And now check for special cases.
|
||||
$special = false;
|
||||
$outtime = $message->strtime;
|
||||
|
||||
// Initialise variables.
|
||||
$outmain = '';
|
||||
$patternTo = '#^\s*To\s([^:]+):(.*)#';
|
||||
$patternto = '#^\s*To\s([^:]+):(.*)#';
|
||||
|
||||
if (substr($text, 0, 5) == 'beep ') {
|
||||
$special = true;
|
||||
/// It's a beep!
|
||||
// It's a beep!
|
||||
$result->type = 'beep';
|
||||
$beepwho = trim(substr($text, 5));
|
||||
|
||||
if ($beepwho == 'all') { // everyone
|
||||
$outmain = get_string('messagebeepseveryone', 'chat', fullname($sender));
|
||||
} else if ($beepwho == $currentuser->id) { // current user
|
||||
if ($beepwho == 'all') { // Everyone.
|
||||
$outmain = get_string('messagebeepseveryone', 'chat', fullname($sender));
|
||||
} else if ($beepwho == $currentuser->id) { // Current user.
|
||||
$outmain = get_string('messagebeepsyou', 'chat', fullname($sender));
|
||||
} else if ($sender->id == $currentuser->id) { //something is not caught?
|
||||
//allow beep for a active chat user only, else user can beep anyone and get fullname
|
||||
} else if ($sender->id == $currentuser->id) { // Something is not caught?
|
||||
// Allow beep for a active chat user only, else user can beep anyone and get fullname.
|
||||
if (!empty($chatuser) && is_numeric($beepwho)) {
|
||||
$chatusers = chat_get_users($chatuser->chatid, $chatuser->groupid, $groupingid);
|
||||
if (array_key_exists($beepwho, $chatusers)) {
|
||||
$outmain = get_string('messageyoubeep', 'chat', fullname($chatusers[$beepwho]));
|
||||
} else {
|
||||
$outmain = get_string('messageyoubeep', 'chat', $beepwho);
|
||||
}
|
||||
$chatusers = chat_get_users($chatuser->chatid, $chatuser->groupid, $groupingid);
|
||||
if (array_key_exists($beepwho, $chatusers)) {
|
||||
$outmain = get_string('messageyoubeep', 'chat', fullname($chatusers[$beepwho]));
|
||||
} else {
|
||||
$outmain = get_string('messageyoubeep', 'chat', $beepwho);
|
||||
}
|
||||
} else {
|
||||
$outmain = get_string('messageyoubeep', 'chat', $beepwho);
|
||||
}
|
||||
}
|
||||
} else if (substr($text, 0, 1) == '/') { /// It's a user command
|
||||
} else if (substr($text, 0, 1) == '/') { // It's a user command.
|
||||
$special = true;
|
||||
$result->type = 'command';
|
||||
$pattern = '#(^\/)(\w+).*#';
|
||||
preg_match($pattern, $text, $matches);
|
||||
$command = isset($matches[2]) ? $matches[2] : false;
|
||||
// Support some IRC commands.
|
||||
switch ($command){
|
||||
switch ($command) {
|
||||
case 'me':
|
||||
$outmain = '*** <b>'.$sender->firstname.' '.substr($text, 4).'</b>';
|
||||
break;
|
||||
@ -992,11 +980,11 @@ function chat_format_message_theme ($message, $chatuser, $currentuser, $grouping
|
||||
$special = false;
|
||||
break;
|
||||
}
|
||||
} else if (preg_match($patternTo, $text)) {
|
||||
} else if (preg_match($patternto, $text)) {
|
||||
$special = true;
|
||||
$result->type = 'dialogue';
|
||||
$matches = array();
|
||||
preg_match($patternTo, $text, $matches);
|
||||
preg_match($patternto, $text, $matches);
|
||||
if (isset($matches[1]) && isset($matches[2])) {
|
||||
$outmain = $sender->firstname.' <b>'.get_string('saidto', 'chat').'</b> <i>'.$matches[1].'</i>: '.$matches[2];
|
||||
} else {
|
||||
@ -1017,12 +1005,13 @@ function chat_format_message_theme ($message, $chatuser, $currentuser, $grouping
|
||||
}
|
||||
|
||||
$senderprofile = $CFG->wwwroot.'/user/view.php?id='.$sender->id.'&course='.$courseid;
|
||||
$usermessage = new user_message($senderprofile, fullname($sender), $message->picture, $mymessageclass, $outtime, $outmain, $theme);
|
||||
$usermessage = new user_message($senderprofile, fullname($sender), $message->picture,
|
||||
$mymessageclass, $outtime, $outmain, $theme);
|
||||
|
||||
$output = $PAGE->get_renderer('mod_chat');
|
||||
$result->html = $output->render($usermessage);
|
||||
|
||||
//When user beeps other user, then don't show any timestamp to other users in chat.
|
||||
// When user beeps other user, then don't show any timestamp to other users in chat.
|
||||
if (('' === $outmain) && $special) {
|
||||
return false;
|
||||
} else {
|
||||
@ -1042,7 +1031,7 @@ function chat_format_message_theme ($message, $chatuser, $currentuser, $grouping
|
||||
function chat_format_userlist($users, $course) {
|
||||
global $CFG, $DB, $COURSE, $OUTPUT;
|
||||
$result = array();
|
||||
foreach($users as $user){
|
||||
foreach ($users as $user) {
|
||||
$item = array();
|
||||
$item['name'] = fullname($user);
|
||||
$item['url'] = $CFG->wwwroot.'/user/view.php?id='.$user->id.'&course='.$course->id;
|
||||
@ -1080,7 +1069,7 @@ function chat_print_error($level, $msg) {
|
||||
* @return array
|
||||
*/
|
||||
function chat_get_view_actions() {
|
||||
return array('view','view all','report');
|
||||
return array('view', 'view all', 'report');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1110,7 +1099,7 @@ function chat_print_overview($courses, &$htmlarray) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if (!$chats = get_all_instances_in_courses('chat',$courses)) {
|
||||
if (!$chats = get_all_instances_in_courses('chat', $courses)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1118,9 +1107,9 @@ function chat_print_overview($courses, &$htmlarray) {
|
||||
$strnextsession = get_string('nextsession', 'chat');
|
||||
|
||||
foreach ($chats as $chat) {
|
||||
if ($chat->chattime and $chat->schedule) { // A chat is scheduled
|
||||
if ($chat->chattime and $chat->schedule) { // A chat is scheduled.
|
||||
$str = '<div class="chat overview"><div class="name">'.
|
||||
$strchat.': <a '.($chat->visible?'':' class="dimmed"').
|
||||
$strchat.': <a '.($chat->visible ? '' : ' class="dimmed"').
|
||||
' href="'.$CFG->wwwroot.'/mod/chat/view.php?id='.$chat->coursemodule.'">'.
|
||||
$chat->name.'</a></div>';
|
||||
$str .= '<div class="info">'.$strnextsession.': '.userdate($chat->chattime).'</div></div>';
|
||||
@ -1143,7 +1132,7 @@ function chat_print_overview($courses, &$htmlarray) {
|
||||
*/
|
||||
function chat_reset_course_form_definition(&$mform) {
|
||||
$mform->addElement('header', 'chatheader', get_string('modulenameplural', 'chat'));
|
||||
$mform->addElement('advcheckbox', 'reset_chat', get_string('removemessages','chat'));
|
||||
$mform->addElement('advcheckbox', 'reset_chat', get_string('removemessages', 'chat'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1153,7 +1142,7 @@ function chat_reset_course_form_definition(&$mform) {
|
||||
* @return array
|
||||
*/
|
||||
function chat_reset_course_form_defaults($course) {
|
||||
return array('reset_chat'=>1);
|
||||
return array('reset_chat' => 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1180,13 +1169,13 @@ function chat_reset_userdata($data) {
|
||||
$DB->delete_records_select('chat_messages', "chatid IN ($chatessql)", $params);
|
||||
$DB->delete_records_select('chat_messages_current', "chatid IN ($chatessql)", $params);
|
||||
$DB->delete_records_select('chat_users', "chatid IN ($chatessql)", $params);
|
||||
$status[] = array('component'=>$componentstr, 'item'=>get_string('removemessages', 'chat'), 'error'=>false);
|
||||
$status[] = array('component' => $componentstr, 'item' => get_string('removemessages', 'chat'), 'error' => false);
|
||||
}
|
||||
|
||||
/// updating dates - shift may be negative too
|
||||
// Updating dates - shift may be negative too.
|
||||
if ($data->timeshift) {
|
||||
shift_course_mod_dates('chat', array('chattime'), $data->timeshift, $data->courseid);
|
||||
$status[] = array('component'=>$componentstr, 'item'=>get_string('datechanged'), 'error'=>false);
|
||||
$status[] = array('component' => $componentstr, 'item' => get_string('datechanged'), 'error' => false);
|
||||
}
|
||||
|
||||
return $status;
|
||||
@ -1208,17 +1197,26 @@ function chat_get_extra_capabilities() {
|
||||
*/
|
||||
function chat_supports($feature) {
|
||||
switch($feature) {
|
||||
case FEATURE_GROUPS: return true;
|
||||
case FEATURE_GROUPINGS: return true;
|
||||
case FEATURE_GROUPMEMBERSONLY: return true;
|
||||
case FEATURE_MOD_INTRO: return true;
|
||||
case FEATURE_BACKUP_MOODLE2: return true;
|
||||
case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
|
||||
case FEATURE_GRADE_HAS_GRADE: return false;
|
||||
case FEATURE_GRADE_OUTCOMES: return true;
|
||||
case FEATURE_SHOW_DESCRIPTION: return true;
|
||||
|
||||
default: return null;
|
||||
case FEATURE_GROUPS:
|
||||
return true;
|
||||
case FEATURE_GROUPINGS:
|
||||
return true;
|
||||
case FEATURE_GROUPMEMBERSONLY:
|
||||
return true;
|
||||
case FEATURE_MOD_INTRO:
|
||||
return true;
|
||||
case FEATURE_BACKUP_MOODLE2:
|
||||
return true;
|
||||
case FEATURE_COMPLETION_TRACKS_VIEWS:
|
||||
return true;
|
||||
case FEATURE_GRADE_HAS_GRADE:
|
||||
return false;
|
||||
case FEATURE_GRADE_OUTCOMES:
|
||||
return true;
|
||||
case FEATURE_SHOW_DESCRIPTION:
|
||||
return true;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1231,7 +1229,7 @@ function chat_extend_navigation($navigation, $course, $module, $cm) {
|
||||
$strenterchat = get_string('enterchat', 'chat');
|
||||
|
||||
$target = $CFG->wwwroot.'/mod/chat/';
|
||||
$params = array('id'=>$cm->instance);
|
||||
$params = array('id' => $cm->instance);
|
||||
|
||||
if ($currentgroup) {
|
||||
$params['groupid'] = $currentgroup;
|
||||
@ -1240,24 +1238,27 @@ function chat_extend_navigation($navigation, $course, $module, $cm) {
|
||||
$links = array();
|
||||
|
||||
$url = new moodle_url($target.'gui_'.$CFG->chat_method.'/index.php', $params);
|
||||
$action = new popup_action('click', $url, 'chat'.$course->id.$cm->instance.$currentgroup, array('height' => 500, 'width' => 700));
|
||||
$action = new popup_action('click', $url, 'chat'.$course->id.$cm->instance.$currentgroup,
|
||||
array('height' => 500, 'width' => 700));
|
||||
$links[] = new action_link($url, $strenterchat, $action);
|
||||
|
||||
$url = new moodle_url($target.'gui_basic/index.php', $params);
|
||||
$action = new popup_action('click', $url, 'chat'.$course->id.$cm->instance.$currentgroup, array('height' => 500, 'width' => 700));
|
||||
$action = new popup_action('click', $url, 'chat'.$course->id.$cm->instance.$currentgroup,
|
||||
array('height' => 500, 'width' => 700));
|
||||
$links[] = new action_link($url, get_string('noframesjs', 'message'), $action);
|
||||
|
||||
foreach ($links as $link) {
|
||||
$navigation->add($link->text, $link, navigation_node::TYPE_SETTING, null ,null, new pix_icon('i/group' , ''));
|
||||
$navigation->add($link->text, $link, navigation_node::TYPE_SETTING, null , null, new pix_icon('i/group' , ''));
|
||||
}
|
||||
}
|
||||
|
||||
$chatusers = chat_get_users($cm->instance, $currentgroup, $cm->groupingid);
|
||||
if (is_array($chatusers) && count($chatusers)>0) {
|
||||
if (is_array($chatusers) && count($chatusers) > 0) {
|
||||
$users = $navigation->add(get_string('currentusers', 'chat'));
|
||||
foreach ($chatusers as $chatuser) {
|
||||
$userlink = new moodle_url('/user/view.php', array('id'=>$chatuser->id,'course'=>$course->id));
|
||||
$users->add(fullname($chatuser).' '.format_time(time() - $chatuser->lastmessageping), $userlink, navigation_node::TYPE_USER, null, null, new pix_icon('i/user', ''));
|
||||
$userlink = new moodle_url('/user/view.php', array('id' => $chatuser->id, 'course' => $course->id));
|
||||
$users->add(fullname($chatuser).' '.format_time(time() - $chatuser->lastmessageping),
|
||||
$userlink, navigation_node::TYPE_USER, null, null, new pix_icon('i/user', ''));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1273,7 +1274,9 @@ function chat_extend_settings_navigation(settings_navigation $settings, navigati
|
||||
$chat = $DB->get_record("chat", array("id" => $PAGE->cm->instance));
|
||||
|
||||
if ($chat->chattime && $chat->schedule) {
|
||||
$nextsessionnode = $chatnode->add(get_string('nextsession', 'chat').': '.userdate($chat->chattime).' ('.usertimezone($USER->timezone));
|
||||
$nextsessionnode = $chatnode->add(get_string('nextsession', 'chat').
|
||||
': '.userdate($chat->chattime).
|
||||
' ('.usertimezone($USER->timezone));
|
||||
$nextsessionnode->add_class('note');
|
||||
}
|
||||
|
||||
@ -1284,9 +1287,9 @@ function chat_extend_settings_navigation(settings_navigation $settings, navigati
|
||||
$groupselect = '';
|
||||
}
|
||||
|
||||
if ($chat->studentlogs || has_capability('mod/chat:readlog',$PAGE->cm->context)) {
|
||||
if ($chat->studentlogs || has_capability('mod/chat:readlog', $PAGE->cm->context)) {
|
||||
if ($DB->get_records_select('chat_messages', "chatid = ? $groupselect", array($chat->id))) {
|
||||
$chatnode->add(get_string('viewreport', 'chat'), new moodle_url('/mod/chat/report.php', array('id'=>$PAGE->cm->id)));
|
||||
$chatnode->add(get_string('viewreport', 'chat'), new moodle_url('/mod/chat/report.php', array('id' => $PAGE->cm->id)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1309,6 +1312,6 @@ function chat_user_logout(\core\event\user_loggedout $event) {
|
||||
* @param stdClass $currentcontext Current context of block
|
||||
*/
|
||||
function chat_page_type_list($pagetype, $parentcontext, $currentcontext) {
|
||||
$module_pagetype = array('mod-chat-*'=>get_string('page-mod-chat-x', 'chat'));
|
||||
return $module_pagetype;
|
||||
$modulepagetype = array('mod-chat-*' => get_string('page-mod-chat-x', 'chat'));
|
||||
return $modulepagetype;
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@ -149,9 +148,7 @@ class chat_portfolio_caller extends portfolio_module_caller_base {
|
||||
global $CFG;
|
||||
|
||||
return $CFG->wwwroot . '/mod/chat/report.php?id='
|
||||
. $this->cm->id . ((isset($this->start))
|
||||
? '&start=' . $this->start . '&end=' . $this->end
|
||||
: '');
|
||||
. $this->cm->id . ((isset($this->start)) ? '&start=' . $this->start . '&end=' . $this->end : '');
|
||||
}
|
||||
}
|
||||
|
||||
@ -187,7 +184,7 @@ class event_message implements renderable {
|
||||
* @param string $time Ready to display event time
|
||||
* @param string $theme The chat theme name
|
||||
*/
|
||||
function __construct($senderprofile, $sendername, $time, $event, $theme) {
|
||||
public function __construct($senderprofile, $sendername, $time, $event, $theme) {
|
||||
|
||||
$this->senderprofile = $senderprofile;
|
||||
$this->sendername = $sendername;
|
||||
@ -238,7 +235,7 @@ class user_message implements renderable {
|
||||
* @param string $message The message
|
||||
* @param string $theme The name of the chat theme to use
|
||||
*/
|
||||
function __construct($senderprofile, $sendername, $avatar, $mymessageclass, $time, $message, $theme) {
|
||||
public function __construct($senderprofile, $sendername, $avatar, $mymessageclass, $time, $message, $theme) {
|
||||
|
||||
$this->sendername = $sendername;
|
||||
$this->avatar = $avatar;
|
||||
|
@ -1,21 +1,38 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
die('Direct access to this script is forbidden.'); // It must be included from a Moodle page.
|
||||
}
|
||||
|
||||
require_once ($CFG->dirroot.'/course/moodleform_mod.php');
|
||||
require_once($CFG->dirroot.'/course/moodleform_mod.php');
|
||||
|
||||
class mod_chat_mod_form extends moodleform_mod {
|
||||
|
||||
function definition() {
|
||||
/**
|
||||
* Define the chat activity settings form
|
||||
*/
|
||||
public function definition() {
|
||||
global $CFG;
|
||||
|
||||
$mform = $this->_form;
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
$mform->addElement('header', 'general', get_string('general', 'form'));
|
||||
|
||||
$mform->addElement('text', 'name', get_string('chatname', 'chat'), array('size'=>'64'));
|
||||
$mform->addElement('text', 'name', get_string('chatname', 'chat'), array('size' => '64'));
|
||||
if (!empty($CFG->formatstringstriptags)) {
|
||||
$mform->setType('name', PARAM_TEXT);
|
||||
} else {
|
||||
@ -31,14 +48,14 @@ class mod_chat_mod_form extends moodleform_mod {
|
||||
|
||||
$mform->addElement('date_time_selector', 'chattime', get_string('chattime', 'chat'));
|
||||
|
||||
$options=array();
|
||||
$options = array();
|
||||
$options[0] = get_string('donotusechattime', 'chat');
|
||||
$options[1] = get_string('repeatnone', 'chat');
|
||||
$options[2] = get_string('repeatdaily', 'chat');
|
||||
$options[3] = get_string('repeatweekly', 'chat');
|
||||
$mform->addElement('select', 'schedule', get_string('repeattimes', 'chat'), $options);
|
||||
|
||||
$options=array();
|
||||
$options = array();
|
||||
$options[0] = get_string('neverdeletemessages', 'chat');
|
||||
$options[365] = get_string('numdays', '', 365);
|
||||
$options[180] = get_string('numdays', '', 180);
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
|
@ -1,291 +1,314 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/// This page prints reports and info about chats
|
||||
// This page prints reports and info about chats.
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once('lib.php');
|
||||
require_once('../../config.php');
|
||||
require_once('lib.php');
|
||||
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$start = optional_param('start', 0, PARAM_INT); // Start of period
|
||||
$end = optional_param('end', 0, PARAM_INT); // End of period
|
||||
$deletesession = optional_param('deletesession', 0, PARAM_BOOL);
|
||||
$confirmdelete = optional_param('confirmdelete', 0, PARAM_BOOL);
|
||||
$show_all = optional_param('show_all', 0, PARAM_BOOL);
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$start = optional_param('start', 0, PARAM_INT); // Start of period.
|
||||
$end = optional_param('end', 0, PARAM_INT); // End of period.
|
||||
$deletesession = optional_param('deletesession', 0, PARAM_BOOL);
|
||||
$confirmdelete = optional_param('confirmdelete', 0, PARAM_BOOL);
|
||||
$showall = optional_param('show_all', 0, PARAM_BOOL);
|
||||
|
||||
$url = new moodle_url('/mod/chat/report.php', array('id'=>$id));
|
||||
if ($start !== 0) {
|
||||
$url->param('start', $start);
|
||||
}
|
||||
if ($end !== 0) {
|
||||
$url->param('end', $end);
|
||||
}
|
||||
if ($deletesession !== 0) {
|
||||
$url->param('deletesession', $deletesession);
|
||||
}
|
||||
if ($confirmdelete !== 0) {
|
||||
$url->param('confirmdelete', $confirmdelete);
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
$url = new moodle_url('/mod/chat/report.php', array('id' => $id));
|
||||
if ($start !== 0) {
|
||||
$url->param('start', $start);
|
||||
}
|
||||
if ($end !== 0) {
|
||||
$url->param('end', $end);
|
||||
}
|
||||
if ($deletesession !== 0) {
|
||||
$url->param('deletesession', $deletesession);
|
||||
}
|
||||
if ($confirmdelete !== 0) {
|
||||
$url->param('confirmdelete', $confirmdelete);
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
|
||||
if (! $cm = get_coursemodule_from_id('chat', $id)) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
if (! $chat = $DB->get_record('chat', array('id'=>$cm->instance))) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
if (! $course = $DB->get_record('course', array('id'=>$chat->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
if (! $cm = get_coursemodule_from_id('chat', $id)) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
if (! $chat = $DB->get_record('chat', array('id' => $cm->instance))) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
if (! $course = $DB->get_record('course', array('id' => $chat->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
|
||||
$context = context_module::instance($cm->id);
|
||||
$PAGE->set_context($context);
|
||||
$PAGE->set_heading($course->fullname);
|
||||
$context = context_module::instance($cm->id);
|
||||
$PAGE->set_context($context);
|
||||
$PAGE->set_heading($course->fullname);
|
||||
|
||||
require_login($course, false, $cm);
|
||||
require_login($course, false, $cm);
|
||||
|
||||
if (empty($chat->studentlogs) && !has_capability('mod/chat:readlog', $context)) {
|
||||
notice(get_string('nopermissiontoseethechatlog', 'chat'));
|
||||
}
|
||||
if (empty($chat->studentlogs) && !has_capability('mod/chat:readlog', $context)) {
|
||||
notice(get_string('nopermissiontoseethechatlog', 'chat'));
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'context' => $context,
|
||||
'objectid' => $chat->id,
|
||||
'other' => array(
|
||||
'start' => $start,
|
||||
'end' => $end
|
||||
)
|
||||
);
|
||||
$event = \mod_chat\event\sessions_viewed::create($params);
|
||||
$event->add_record_snapshot('chat', $chat);
|
||||
$event->trigger();
|
||||
$params = array(
|
||||
'context' => $context,
|
||||
'objectid' => $chat->id,
|
||||
'other' => array(
|
||||
'start' => $start,
|
||||
'end' => $end
|
||||
)
|
||||
);
|
||||
$event = \mod_chat\event\sessions_viewed::create($params);
|
||||
$event->add_record_snapshot('chat', $chat);
|
||||
$event->trigger();
|
||||
|
||||
$strchats = get_string('modulenameplural', 'chat');
|
||||
$strchat = get_string('modulename', 'chat');
|
||||
$strchatreport = get_string('chatreport', 'chat');
|
||||
$strseesession = get_string('seesession', 'chat');
|
||||
$strdeletesession = get_string('deletesession', 'chat');
|
||||
$strchats = get_string('modulenameplural', 'chat');
|
||||
$strchat = get_string('modulename', 'chat');
|
||||
$strchatreport = get_string('chatreport', 'chat');
|
||||
$strseesession = get_string('seesession', 'chat');
|
||||
$strdeletesession = get_string('deletesession', 'chat');
|
||||
|
||||
$navlinks = array();
|
||||
$navlinks = array();
|
||||
|
||||
$canexportsess = has_capability('mod/chat:exportsession', $context);
|
||||
$canexportsess = has_capability('mod/chat:exportsession', $context);
|
||||
|
||||
/// Print a session if one has been specified
|
||||
// Print a session if one has been specified.
|
||||
|
||||
if ($start and $end and !$confirmdelete) { // Show a full transcript
|
||||
$PAGE->navbar->add($strchatreport);
|
||||
$PAGE->set_title(format_string($chat->name).": $strchatreport");
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(format_string($chat->name), 2);
|
||||
|
||||
/// Check to see if groups are being used here
|
||||
$groupmode = groups_get_activity_groupmode($cm);
|
||||
$currentgroup = groups_get_activity_group($cm, true);
|
||||
groups_print_activity_menu($cm, $CFG->wwwroot . "/mod/chat/report.php?id=$cm->id");
|
||||
|
||||
$params = array('currentgroup'=>$currentgroup, 'chatid'=>$chat->id, 'start'=>$start, 'end'=>$end);
|
||||
|
||||
// If the user is allocated to a group, only show messages from people
|
||||
// in the same group, or no group
|
||||
if ($currentgroup) {
|
||||
$groupselect = " AND (groupid = :currentgroup OR groupid = 0)";
|
||||
} else {
|
||||
$groupselect = "";
|
||||
}
|
||||
|
||||
if ($deletesession and has_capability('mod/chat:deletelog', $context)) {
|
||||
echo $OUTPUT->confirm(get_string('deletesessionsure', 'chat'),
|
||||
"report.php?id=$cm->id&deletesession=1&confirmdelete=1&start=$start&end=$end",
|
||||
"report.php?id=$cm->id");
|
||||
}
|
||||
|
||||
if (!$messages = $DB->get_records_select('chat_messages', "chatid = :chatid AND timestamp >= :start AND timestamp <= :end $groupselect", $params, "timestamp ASC")) {
|
||||
echo $OUTPUT->heading(get_string('nomessages', 'chat'));
|
||||
|
||||
} else {
|
||||
echo '<p class="boxaligncenter">'.userdate($start).' --> '. userdate($end).'</p>';
|
||||
|
||||
echo $OUTPUT->box_start('center');
|
||||
$participates = array();
|
||||
foreach ($messages as $message) { // We are walking FORWARDS through messages
|
||||
if (!isset($participates[$message->userid])) {
|
||||
$participates[$message->userid] = true;
|
||||
}
|
||||
$formatmessage = chat_format_message($message, $course->id, $USER);
|
||||
if (isset($formatmessage->html)) {
|
||||
echo $formatmessage->html;
|
||||
}
|
||||
}
|
||||
$participatedcap = array_key_exists($USER->id, $participates) && has_capability('mod/chat:exportparticipatedsession', $context);
|
||||
if (!empty($CFG->enableportfolios) && ($canexportsess || $participatedcap)) {
|
||||
require_once($CFG->libdir . '/portfoliolib.php');
|
||||
$buttonoptions = array(
|
||||
'id' => $cm->id,
|
||||
'start' => $start,
|
||||
'end' => $end,
|
||||
);
|
||||
$button = new portfolio_add_button();
|
||||
$button->set_callback_options('chat_portfolio_caller', $buttonoptions, 'mod_chat');
|
||||
$button->render();
|
||||
}
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
|
||||
if (!$deletesession or !has_capability('mod/chat:deletelog', $context)) {
|
||||
echo $OUTPUT->continue_button("report.php?id=$cm->id");
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/// Print the Sessions display
|
||||
if ($start and $end and !$confirmdelete) { // Show a full transcript.
|
||||
$PAGE->navbar->add($strchatreport);
|
||||
$PAGE->set_title(format_string($chat->name).": $strchatreport");
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(format_string($chat->name), 2);
|
||||
|
||||
echo $OUTPUT->heading(format_string($chat->name).': '.get_string('sessions', 'chat'), 2);
|
||||
// Check to see if groups are being used here.
|
||||
$groupmode = groups_get_activity_groupmode($cm);
|
||||
$currentgroup = groups_get_activity_group($cm, true);
|
||||
groups_print_activity_menu($cm, $CFG->wwwroot . "/mod/chat/report.php?id=$cm->id");
|
||||
|
||||
/// Check to see if groups are being used here
|
||||
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used
|
||||
$currentgroup = groups_get_activity_group($cm, true);
|
||||
groups_print_activity_menu($cm, $CFG->wwwroot . "/mod/chat/report.php?id=$cm->id");
|
||||
} else {
|
||||
$currentgroup = false;
|
||||
}
|
||||
$params = array('currentgroup' => $currentgroup, 'chatid' => $chat->id, 'start' => $start, 'end' => $end);
|
||||
|
||||
$params = array('currentgroup'=>$currentgroup, 'chatid'=>$chat->id, 'start'=>$start, 'end'=>$end);
|
||||
|
||||
// If the user is allocated to a group, only show discussions with people in
|
||||
// the same group, or no group
|
||||
if (!empty($currentgroup)) {
|
||||
// If the user is allocated to a group, only show messages from people
|
||||
// in the same group, or no group.
|
||||
if ($currentgroup) {
|
||||
$groupselect = " AND (groupid = :currentgroup OR groupid = 0)";
|
||||
} else {
|
||||
$groupselect = "";
|
||||
}
|
||||
|
||||
/// Delete a session if one has been specified
|
||||
|
||||
if ($deletesession and has_capability('mod/chat:deletelog', $context) and $confirmdelete and $start and $end and confirm_sesskey()) {
|
||||
$DB->delete_records_select('chat_messages', "chatid = :chatid AND timestamp >= :start AND
|
||||
timestamp <= :end $groupselect", $params);
|
||||
$strdeleted = get_string('deleted');
|
||||
echo $OUTPUT->notification("$strdeleted: ".userdate($start).' --> '. userdate($end));
|
||||
unset($deletesession);
|
||||
if ($deletesession and has_capability('mod/chat:deletelog', $context)) {
|
||||
echo $OUTPUT->confirm(get_string('deletesessionsure', 'chat'),
|
||||
"report.php?id=$cm->id&deletesession=1&confirmdelete=1&start=$start&end=$end",
|
||||
"report.php?id=$cm->id");
|
||||
}
|
||||
|
||||
if (!$messages = $DB->get_records_select('chat_messages',
|
||||
"chatid = :chatid AND timestamp >= :start AND timestamp <= :end $groupselect",
|
||||
$params,
|
||||
"timestamp ASC")) {
|
||||
|
||||
/// Get the messages
|
||||
if (empty($messages)) { /// May have already got them above
|
||||
if (!$messages = $DB->get_records_select('chat_messages', "chatid = :chatid $groupselect", $params, "timestamp DESC")) {
|
||||
echo $OUTPUT->heading(get_string('nomessages', 'chat'), 3);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
echo $OUTPUT->heading(get_string('nomessages', 'chat'));
|
||||
|
||||
} else {
|
||||
echo '<p class="boxaligncenter">'.userdate($start).' --> '. userdate($end).'</p>';
|
||||
|
||||
echo $OUTPUT->box_start('center');
|
||||
$participates = array();
|
||||
foreach ($messages as $message) { // We are walking FORWARDS through messages.
|
||||
if (!isset($participates[$message->userid])) {
|
||||
$participates[$message->userid] = true;
|
||||
}
|
||||
$formatmessage = chat_format_message($message, $course->id, $USER);
|
||||
if (isset($formatmessage->html)) {
|
||||
echo $formatmessage->html;
|
||||
}
|
||||
}
|
||||
$participatedcap = array_key_exists($USER->id, $participates)
|
||||
&& has_capability('mod/chat:exportparticipatedsession', $context);
|
||||
|
||||
if (!empty($CFG->enableportfolios) && ($canexportsess || $participatedcap)) {
|
||||
require_once($CFG->libdir . '/portfoliolib.php');
|
||||
$buttonoptions = array(
|
||||
'id' => $cm->id,
|
||||
'start' => $start,
|
||||
'end' => $end,
|
||||
);
|
||||
$button = new portfolio_add_button();
|
||||
$button->set_callback_options('chat_portfolio_caller', $buttonoptions, 'mod_chat');
|
||||
$button->render();
|
||||
}
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
|
||||
if ($show_all) {
|
||||
$headingstr = get_string('listing_all_sessions', 'chat') . ' ';
|
||||
$headingstr .= html_writer::link("report.php?id={$cm->id}&show_all=0", get_string('list_complete_sessions', 'chat'));
|
||||
echo $OUTPUT->heading($headingstr, 3);
|
||||
if (!$deletesession or !has_capability('mod/chat:deletelog', $context)) {
|
||||
echo $OUTPUT->continue_button("report.php?id=$cm->id");
|
||||
}
|
||||
|
||||
/// Show all the sessions
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
$sessiongap = 5 * 60; // 5 minutes silence means a new session
|
||||
$sessionend = 0;
|
||||
$sessionstart = 0;
|
||||
$sessionusers = array();
|
||||
$lasttime = 0;
|
||||
$complete_sessions = 0;
|
||||
|
||||
$messagesleft = count($messages);
|
||||
// Print the Sessions display.
|
||||
$PAGE->navbar->add($strchatreport);
|
||||
$PAGE->set_title(format_string($chat->name).": $strchatreport");
|
||||
echo $OUTPUT->header();
|
||||
|
||||
foreach ($messages as $message) { // We are walking BACKWARDS through the messages
|
||||
echo $OUTPUT->heading(format_string($chat->name).': '.get_string('sessions', 'chat'), 2);
|
||||
|
||||
$messagesleft --; // Countdown
|
||||
// Check to see if groups are being used here
|
||||
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used.
|
||||
$currentgroup = groups_get_activity_group($cm, true);
|
||||
groups_print_activity_menu($cm, $CFG->wwwroot . "/mod/chat/report.php?id=$cm->id");
|
||||
} else {
|
||||
$currentgroup = false;
|
||||
}
|
||||
|
||||
if (!$lasttime) {
|
||||
$lasttime = $message->timestamp;
|
||||
}
|
||||
if (!$sessionend) {
|
||||
$sessionend = $message->timestamp;
|
||||
}
|
||||
if ((($lasttime - $message->timestamp) < $sessiongap) and $messagesleft) { // Same session
|
||||
if ($message->userid and !$message->system) { // Remember user and count messages
|
||||
if (empty($sessionusers[$message->userid])) {
|
||||
$sessionusers[$message->userid] = 1;
|
||||
} else {
|
||||
$sessionusers[$message->userid] ++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$sessionstart = $lasttime;
|
||||
$params = array('currentgroup' => $currentgroup, 'chatid' => $chat->id, 'start' => $start, 'end' => $end);
|
||||
|
||||
$is_complete = ($sessionend - $sessionstart > 60 and count($sessionusers) > 1);
|
||||
if ($show_all or $is_complete) {
|
||||
// If the user is allocated to a group, only show discussions with people in
|
||||
// the same group, or no group.
|
||||
if (!empty($currentgroup)) {
|
||||
$groupselect = " AND (groupid = :currentgroup OR groupid = 0)";
|
||||
} else {
|
||||
$groupselect = "";
|
||||
}
|
||||
|
||||
echo '<p align="center">'.userdate($sessionstart).' --> '. userdate($sessionend).'</p>';
|
||||
// Delete a session if one has been specified.
|
||||
|
||||
echo $OUTPUT->box_start();
|
||||
if ($deletesession and has_capability('mod/chat:deletelog', $context)
|
||||
and $confirmdelete and $start and $end and confirm_sesskey()) {
|
||||
|
||||
arsort($sessionusers);
|
||||
foreach ($sessionusers as $sessionuser => $usermessagecount) {
|
||||
if ($user = $DB->get_record('user', array('id'=>$sessionuser))) {
|
||||
$OUTPUT->user_picture($user, array('courseid'=>$course->id));
|
||||
echo ' '.fullname($user, true); // XXX TODO use capability instead of true
|
||||
echo " ($usermessagecount)<br />";
|
||||
}
|
||||
}
|
||||
$DB->delete_records_select('chat_messages', "chatid = :chatid AND timestamp >= :start AND
|
||||
timestamp <= :end $groupselect", $params);
|
||||
$strdeleted = get_string('deleted');
|
||||
echo $OUTPUT->notification("$strdeleted: ".userdate($start).' --> '. userdate($end));
|
||||
unset($deletesession);
|
||||
}
|
||||
|
||||
echo '<p align="right">';
|
||||
echo "<a href=\"report.php?id=$cm->id&start=$sessionstart&end=$sessionend\">$strseesession</a>";
|
||||
$participatedcap = (array_key_exists($USER->id, $sessionusers) && has_capability('mod/chat:exportparticipatedsession', $context));
|
||||
if (!empty($CFG->enableportfolios) && ($canexportsess || $participatedcap)) {
|
||||
require_once($CFG->libdir . '/portfoliolib.php');
|
||||
$buttonoptions = array(
|
||||
'id' => $cm->id,
|
||||
'start' => $sessionstart,
|
||||
'end' => $sessionend,
|
||||
);
|
||||
$button = new portfolio_add_button();
|
||||
$button->set_callback_options('chat_portfolio_caller', $buttonoptions, 'mod_chat');
|
||||
$portfoliobutton = $button->to_html(PORTFOLIO_ADD_TEXT_LINK);
|
||||
if (!empty($portfoliobutton)) {
|
||||
echo '<br />' . $portfoliobutton;
|
||||
}
|
||||
}
|
||||
if (has_capability('mod/chat:deletelog', $context)) {
|
||||
echo "<br /><a href=\"report.php?id=$cm->id&start=$sessionstart&end=$sessionend&deletesession=1\">$strdeletesession</a>";
|
||||
}
|
||||
echo '</p>';
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
if ($is_complete) {
|
||||
$complete_sessions++;
|
||||
}
|
||||
// Get the messages.
|
||||
if (empty($messages)) { // May have already got them above.
|
||||
if (!$messages = $DB->get_records_select('chat_messages', "chatid = :chatid $groupselect", $params, "timestamp DESC")) {
|
||||
echo $OUTPUT->heading(get_string('nomessages', 'chat'), 3);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$sessionend = $message->timestamp;
|
||||
$sessionusers = array();
|
||||
$sessionusers[$message->userid] = 1;
|
||||
}
|
||||
if ($showall) {
|
||||
$headingstr = get_string('listing_all_sessions', 'chat') . ' ';
|
||||
$headingstr .= html_writer::link("report.php?id={$cm->id}&show_all=0", get_string('list_complete_sessions', 'chat'));
|
||||
echo $OUTPUT->heading($headingstr, 3);
|
||||
}
|
||||
|
||||
// Show all the sessions.
|
||||
|
||||
$sessiongap = 5 * 60; // 5 minutes silence means a new session.
|
||||
$sessionend = 0;
|
||||
$sessionstart = 0;
|
||||
$sessionusers = array();
|
||||
$lasttime = 0;
|
||||
$completesessions = 0;
|
||||
|
||||
$messagesleft = count($messages);
|
||||
|
||||
foreach ($messages as $message) { // We are walking BACKWARDS through the messages.
|
||||
|
||||
$messagesleft --; // Countdown.
|
||||
|
||||
if (!$lasttime) {
|
||||
$lasttime = $message->timestamp;
|
||||
}
|
||||
|
||||
if (!empty($CFG->enableportfolios) && $canexportsess) {
|
||||
require_once($CFG->libdir . '/portfoliolib.php');
|
||||
$button = new portfolio_add_button();
|
||||
$button->set_callback_options('chat_portfolio_caller', array('id' => $cm->id), 'mod_chat');
|
||||
$button->render(null, get_string('addalltoportfolio', 'portfolio'));
|
||||
if (!$sessionend) {
|
||||
$sessionend = $message->timestamp;
|
||||
}
|
||||
if ((($lasttime - $message->timestamp) < $sessiongap) and $messagesleft) { // Same session.
|
||||
if ($message->userid and !$message->system) { // Remember user and count messages.
|
||||
if (empty($sessionusers[$message->userid])) {
|
||||
$sessionusers[$message->userid] = 1;
|
||||
} else {
|
||||
$sessionusers[$message->userid] ++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$sessionstart = $lasttime;
|
||||
|
||||
$iscomplete = ($sessionend - $sessionstart > 60 and count($sessionusers) > 1);
|
||||
if ($showall or $iscomplete) {
|
||||
|
||||
if (!$show_all and $complete_sessions == 0) {
|
||||
echo html_writer::start_tag('p');
|
||||
echo get_string('no_complete_sessions_found', 'chat') . ' ';
|
||||
echo html_writer::link('report.php?id='.$cm->id.'&show_all=1', get_string('list_all_sessions', 'chat'));
|
||||
echo html_writer::end_tag('p');
|
||||
echo '<p align="center">'.userdate($sessionstart).' --> '. userdate($sessionend).'</p>';
|
||||
|
||||
echo $OUTPUT->box_start();
|
||||
|
||||
arsort($sessionusers);
|
||||
foreach ($sessionusers as $sessionuser => $usermessagecount) {
|
||||
if ($user = $DB->get_record('user', array('id' => $sessionuser))) {
|
||||
$OUTPUT->user_picture($user, array('courseid' => $course->id));
|
||||
echo ' '.fullname($user, true); // XXX TODO use capability instead of true.
|
||||
echo " ($usermessagecount)<br />";
|
||||
}
|
||||
}
|
||||
|
||||
echo '<p align="right">';
|
||||
echo "<a href=\"report.php?id=$cm->id&start=$sessionstart&end=$sessionend\">$strseesession</a>";
|
||||
$participatedcap = (array_key_exists($USER->id, $sessionusers)
|
||||
&& has_capability('mod/chat:exportparticipatedsession', $context));
|
||||
if (!empty($CFG->enableportfolios) && ($canexportsess || $participatedcap)) {
|
||||
require_once($CFG->libdir . '/portfoliolib.php');
|
||||
$buttonoptions = array(
|
||||
'id' => $cm->id,
|
||||
'start' => $sessionstart,
|
||||
'end' => $sessionend,
|
||||
);
|
||||
$button = new portfolio_add_button();
|
||||
$button->set_callback_options('chat_portfolio_caller', $buttonoptions, 'mod_chat');
|
||||
$portfoliobutton = $button->to_html(PORTFOLIO_ADD_TEXT_LINK);
|
||||
if (!empty($portfoliobutton)) {
|
||||
echo '<br />' . $portfoliobutton;
|
||||
}
|
||||
}
|
||||
if (has_capability('mod/chat:deletelog', $context)) {
|
||||
$deleteurl = "report.php?id=$cm->id&start=$sessionstart&end=$sessionend&deletesession=1";
|
||||
echo "<br /><a href=\"$deleteurl\">$strdeletesession</a>";
|
||||
}
|
||||
echo '</p>';
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
if ($iscomplete) {
|
||||
$completesessions++;
|
||||
}
|
||||
|
||||
$sessionend = $message->timestamp;
|
||||
$sessionusers = array();
|
||||
$sessionusers[$message->userid] = 1;
|
||||
}
|
||||
$lasttime = $message->timestamp;
|
||||
}
|
||||
|
||||
/// Finish the page
|
||||
echo $OUTPUT->footer();
|
||||
if (!empty($CFG->enableportfolios) && $canexportsess) {
|
||||
require_once($CFG->libdir . '/portfoliolib.php');
|
||||
$button = new portfolio_add_button();
|
||||
$button->set_callback_options('chat_portfolio_caller', array('id' => $cm->id), 'mod_chat');
|
||||
$button->render(null, get_string('addalltoportfolio', 'portfolio'));
|
||||
}
|
||||
|
||||
|
||||
if (!$showall and $completesessions == 0) {
|
||||
echo html_writer::start_tag('p');
|
||||
echo get_string('no_complete_sessions_found', 'chat') . ' ';
|
||||
echo html_writer::link('report.php?id='.$cm->id.'&show_all=1', get_string('list_all_sessions', 'chat'));
|
||||
echo html_writer::end_tag('p');
|
||||
}
|
||||
|
||||
// Finish the page.
|
||||
echo $OUTPUT->footer();
|
||||
|
@ -1,4 +1,18 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
@ -19,7 +33,6 @@ if ($ADMIN->fulltree) {
|
||||
$settings->add(new admin_setting_configtext('chat_old_ping', get_string('oldping', 'chat'),
|
||||
get_string('configoldping', 'chat'), 35, PARAM_INT));
|
||||
|
||||
|
||||
$settings->add(new admin_setting_heading('chat_normal_heading', get_string('methodnormal', 'chat'),
|
||||
get_string('explainmethodnormal', 'chat')));
|
||||
|
||||
@ -32,7 +45,6 @@ if ($ADMIN->fulltree) {
|
||||
$settings->add(new admin_setting_configselect('chat_normal_updatemode', get_string('updatemethod', 'chat'),
|
||||
get_string('confignormalupdatemode', 'chat'), 'jsupdate', $options));
|
||||
|
||||
|
||||
$settings->add(new admin_setting_heading('chat_daemon_heading', get_string('methoddaemon', 'chat'),
|
||||
get_string('explainmethoddaemon', 'chat')));
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2014051200; // The current module version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2014050800; // Requires this Moodle version
|
||||
$plugin->component = 'mod_chat'; // Full name of the plugin (used for diagnostics)
|
||||
$plugin->version = 2014051200; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2014050800; // Requires this Moodle version.
|
||||
$plugin->component = 'mod_chat'; // Full name of the plugin (used for diagnostics).
|
||||
$plugin->cron = 300;
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@ -15,7 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/// This page prints a particular instance of chat
|
||||
// This page prints a particular instance of chat.
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
|
||||
require_once($CFG->dirroot . '/mod/chat/lib.php');
|
||||
@ -30,23 +29,23 @@ if ($id) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (! $course = $DB->get_record('course', array('id'=>$cm->course))) {
|
||||
if (! $course = $DB->get_record('course', array('id' => $cm->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
|
||||
chat_update_chat_times($cm->instance);
|
||||
|
||||
if (! $chat = $DB->get_record('chat', array('id'=>$cm->instance))) {
|
||||
if (! $chat = $DB->get_record('chat', array('id' => $cm->instance))) {
|
||||
print_error('invalidid', 'chat');
|
||||
}
|
||||
|
||||
} else {
|
||||
chat_update_chat_times($c);
|
||||
|
||||
if (! $chat = $DB->get_record('chat', array('id'=>$c))) {
|
||||
if (! $chat = $DB->get_record('chat', array('id' => $c))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
if (! $course = $DB->get_record('course', array('id'=>$chat->course))) {
|
||||
if (! $course = $DB->get_record('course', array('id' => $chat->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
if (! $cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) {
|
||||
@ -59,7 +58,7 @@ require_course_login($course, true, $cm);
|
||||
$context = context_module::instance($cm->id);
|
||||
$PAGE->set_context($context);
|
||||
|
||||
// show some info for guests
|
||||
// Show some info for guests.
|
||||
if (isguestuser()) {
|
||||
$PAGE->set_title($chat->name);
|
||||
echo $OUTPUT->header();
|
||||
@ -88,23 +87,23 @@ $strnextsession = get_string('nextsession', 'chat');
|
||||
$courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
|
||||
$title = $courseshortname . ': ' . format_string($chat->name);
|
||||
|
||||
// Mark viewed by user (if required)
|
||||
// Mark viewed by user (if required).
|
||||
$completion = new completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
// Initialize $PAGE
|
||||
// Initialize $PAGE.
|
||||
$PAGE->set_url('/mod/chat/view.php', array('id' => $cm->id));
|
||||
$PAGE->set_title($title);
|
||||
$PAGE->set_heading($course->fullname);
|
||||
|
||||
/// Print the page header
|
||||
// Print the page header.
|
||||
echo $OUTPUT->header();
|
||||
|
||||
/// Check to see if groups are being used here
|
||||
// Check to see if groups are being used here.
|
||||
$groupmode = groups_get_activity_groupmode($cm);
|
||||
$currentgroup = groups_get_activity_group($cm, true);
|
||||
|
||||
// url parameters
|
||||
// URL parameters.
|
||||
$params = array();
|
||||
if ($currentgroup) {
|
||||
$groupselect = " AND groupid = '$currentgroup'";
|
||||
@ -124,12 +123,12 @@ if ($chat->intro) {
|
||||
groups_print_activity_menu($cm, $CFG->wwwroot . "/mod/chat/view.php?id=$cm->id");
|
||||
|
||||
if (has_capability('mod/chat:chat', $context)) {
|
||||
/// Print the main part of the page
|
||||
// Print the main part of the page.
|
||||
echo $OUTPUT->box_start('generalbox', 'enterlink');
|
||||
|
||||
$now = time();
|
||||
$span = $chat->chattime - $now;
|
||||
if ($chat->chattime and $chat->schedule and ($span>0)) { // A chat is scheduled
|
||||
if ($chat->chattime and $chat->schedule and ($span > 0)) { // A chat is scheduled.
|
||||
echo '<p>';
|
||||
echo get_string('sessionstart', 'chat', format_time($span));
|
||||
echo '</p>';
|
||||
@ -138,25 +137,30 @@ if (has_capability('mod/chat:chat', $context)) {
|
||||
$params['id'] = $chat->id;
|
||||
$chattarget = new moodle_url("/mod/chat/gui_$CFG->chat_method/index.php", $params);
|
||||
echo '<p>';
|
||||
echo $OUTPUT->action_link($chattarget, $strenterchat, new popup_action('click', $chattarget, "chat{$course->id}_{$chat->id}{$groupparam}", array('height' => 500, 'width' => 700)));
|
||||
echo $OUTPUT->action_link($chattarget,
|
||||
$strenterchat,
|
||||
new popup_action('click', $chattarget, "chat{$course->id}_{$chat->id}{$groupparam}",
|
||||
array('height' => 500, 'width' => 700)));
|
||||
echo '</p>';
|
||||
|
||||
$params['id'] = $chat->id;
|
||||
$link = new moodle_url('/mod/chat/gui_basic/index.php', $params);
|
||||
$action = new popup_action('click', $link, "chat{$course->id}_{$chat->id}{$groupparam}", array('height' => 500, 'width' => 700));
|
||||
$action = new popup_action('click', $link, "chat{$course->id}_{$chat->id}{$groupparam}",
|
||||
array('height' => 500, 'width' => 700));
|
||||
echo '<p>';
|
||||
echo $OUTPUT->action_link($link, get_string('noframesjs', 'message'), $action, array('title'=>get_string('modulename', 'chat')));
|
||||
echo $OUTPUT->action_link($link, get_string('noframesjs', 'message'), $action,
|
||||
array('title' => get_string('modulename', 'chat')));
|
||||
echo '</p>';
|
||||
|
||||
if ($chat->studentlogs or has_capability('mod/chat:readlog', $context)) {
|
||||
if ($msg = $DB->get_records_select('chat_messages', "chatid = ? $groupselect", array($chat->id))) {
|
||||
echo '<p>';
|
||||
echo html_writer::link(new moodle_url('/mod/chat/report.php', array('id'=>$cm->id)), get_string('viewreport', 'chat'));
|
||||
echo html_writer::link(new moodle_url('/mod/chat/report.php', array('id' => $cm->id)),
|
||||
get_string('viewreport', 'chat'));
|
||||
echo '</p>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
} else {
|
||||
@ -175,7 +179,7 @@ if ($chatusers = chat_get_users($chat->id, $currentgroup, $cm->groupingid)) {
|
||||
foreach ($chatusers as $chatuser) {
|
||||
$lastping = $timenow - $chatuser->lastmessageping;
|
||||
echo '<tr><td class="chatuserimage">';
|
||||
$url = new moodle_url('/user/view.php', array('id'=>$chatuser->id, 'course'=>$chat->course));
|
||||
$url = new moodle_url('/user/view.php', array('id' => $chatuser->id, 'course' => $chat->course));
|
||||
echo html_writer::link($url, $OUTPUT->user_picture($chatuser));
|
||||
echo '</td><td class="chatuserdetails">';
|
||||
echo '<p>'.fullname($chatuser).'</p>';
|
||||
|
Loading…
x
Reference in New Issue
Block a user