mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
mod-chat MDL-21534 Converted JS to YUI3 and new coding style also fixed several regressions.
This commit is contained in:
parent
98d3784e6d
commit
579a4976cc
8 changed files with 392 additions and 416 deletions
|
@ -11,25 +11,18 @@ if ($groupid !== 0) {
|
||||||
$url->param('groupid', $groupid);
|
$url->param('groupid', $groupid);
|
||||||
}
|
}
|
||||||
$PAGE->set_url($url);
|
$PAGE->set_url($url);
|
||||||
if (!$chat = $DB->get_record('chat', array('id'=>$id))) {
|
|
||||||
print_error('invalidid', 'chat');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$course = $DB->get_record('course', array('id'=>$chat->course))) {
|
$chat = $DB->get_record('chat', array('id'=>$id), '*', MUST_EXIST);
|
||||||
print_error('invalidcourseid');
|
$course = $DB->get_record('course', array('id'=>$chat->course), '*', MUST_EXIST);
|
||||||
}
|
$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id, false, MUST_EXIST);
|
||||||
|
|
||||||
if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) {
|
|
||||||
print_error('invalidcoursemodule');
|
|
||||||
}
|
|
||||||
|
|
||||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||||
require_login($course->id, false, $cm);
|
require_login($course->id, false, $cm);
|
||||||
require_capability('mod/chat:chat',$context);
|
require_capability('mod/chat:chat',$context);
|
||||||
|
|
||||||
if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_MODULE, $cm->id))) {
|
if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_MODULE, $cm->id))) {
|
||||||
echo $OUTPUT->header();
|
|
||||||
notice(get_string("activityiscurrentlyhidden"));
|
notice(get_string("activityiscurrentlyhidden"));
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check to see if groups are being used here
|
/// Check to see if groups are being used here
|
||||||
|
@ -52,25 +45,16 @@ if (!$chat_sid = chat_login_user($chat->id, 'ajax', $groupid, $course)) {
|
||||||
print_error('cantlogin', 'chat');
|
print_error('cantlogin', 'chat');
|
||||||
}
|
}
|
||||||
|
|
||||||
$str_title = format_string($course->shortname) . ": ".format_string($chat->name,true).$groupname;
|
|
||||||
$str_send = get_string('send', 'chat');
|
|
||||||
$str_themes = get_string('themes');
|
|
||||||
|
|
||||||
$PAGE->set_pagelayout('popup');
|
|
||||||
$PAGE->set_title('Chat');
|
|
||||||
$PAGE->requires->yui2_lib('dragdrop');
|
|
||||||
$PAGE->requires->yui2_lib('resize');
|
|
||||||
$PAGE->requires->yui2_lib('layout');
|
|
||||||
$PAGE->requires->yui2_lib('container');
|
|
||||||
$PAGE->requires->yui2_lib('connection');
|
|
||||||
$PAGE->requires->yui2_lib('json');
|
|
||||||
$PAGE->requires->yui2_lib('animation');
|
|
||||||
$PAGE->requires->yui2_lib('menu');
|
|
||||||
|
|
||||||
if (!file_exists(dirname(__FILE__) . '/theme/'.$theme.'/chat.css')) {
|
if (!file_exists(dirname(__FILE__) . '/theme/'.$theme.'/chat.css')) {
|
||||||
$theme = 'bubble';
|
$theme = 'bubble';
|
||||||
}
|
}
|
||||||
$PAGE->requires->data_for_js('chat_cfg', array(
|
|
||||||
|
$module = array(
|
||||||
|
'name' => 'mod_chat_ajax',
|
||||||
|
'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')
|
||||||
|
);
|
||||||
|
$modulecfg = array(array(
|
||||||
'home'=>$CFG->httpswwwroot.'/mod/chat/view.php?id='.$cm->id,
|
'home'=>$CFG->httpswwwroot.'/mod/chat/view.php?id='.$cm->id,
|
||||||
'chaturl'=>$CFG->httpswwwroot.'/mod/chat/gui_ajax/index.php?id='.$id,
|
'chaturl'=>$CFG->httpswwwroot.'/mod/chat/gui_ajax/index.php?id='.$id,
|
||||||
'theme'=>$theme,
|
'theme'=>$theme,
|
||||||
|
@ -79,56 +63,27 @@ $PAGE->requires->data_for_js('chat_cfg', array(
|
||||||
'timer'=>3000,
|
'timer'=>3000,
|
||||||
'chat_lasttime'=>0,
|
'chat_lasttime'=>0,
|
||||||
'chat_lastrow'=>null,
|
'chat_lastrow'=>null,
|
||||||
'chatroom_name'=>$str_title
|
'chatroom_name'=>format_string($course->shortname) . ": ".format_string($chat->name,true).$groupname
|
||||||
));
|
));
|
||||||
|
$PAGE->requires->js_init_call('M.mod_chat.ajax.init', $modulecfg, false, $module);
|
||||||
|
$PAGE->requires->strings_for_js(array('send','sending','inputarea','userlist','modulename','beep','talk'), 'chat');
|
||||||
|
|
||||||
$PAGE->requires->string_for_js('send', 'chat');
|
$PAGE->set_title('Chat');
|
||||||
$PAGE->requires->string_for_js('sending', 'chat');
|
|
||||||
$PAGE->requires->string_for_js('inputarea', 'chat');
|
|
||||||
$PAGE->requires->string_for_js('userlist', 'chat');
|
|
||||||
$PAGE->requires->string_for_js('modulename', 'chat');
|
|
||||||
$PAGE->requires->string_for_js('beep', 'chat');
|
|
||||||
$PAGE->requires->string_for_js('talk', 'chat');
|
|
||||||
|
|
||||||
$PAGE->requires->js('/mod/chat/gui_ajax/script.js');
|
|
||||||
$PAGE->requires->yui2_lib('animation');
|
|
||||||
|
|
||||||
$PAGE->add_body_class('yui-skin-sam');
|
$PAGE->add_body_class('yui-skin-sam');
|
||||||
$PAGE->set_pagelayout('embedded');
|
$PAGE->set_pagelayout('embedded');
|
||||||
|
|
||||||
echo $OUTPUT->header();
|
echo $OUTPUT->header();
|
||||||
$intro = format_text($chat->intro, $chat->introformat);
|
echo $OUTPUT->box('<ul id="users-list"></ul>', '', 'chat-userlist');
|
||||||
$home_url = $CFG->httpswwwroot.'/mod/chat/gui_ajax/index.php?id='.$id;
|
echo $OUTPUT->box('', '', 'chat-options');
|
||||||
|
echo $OUTPUT->box('<ul id="messages-list"></ul>', '', 'chat-messages');
|
||||||
echo <<<DIVS
|
$table = new html_table();
|
||||||
<!--
|
$table->data = array(
|
||||||
<div id="chat-header">
|
array(
|
||||||
{$chat->name} <p>{$intro}</p>
|
' »<input type="text" disabled="true" id="input-message" value="Loading..." size="50" /><input type="button" id="button-send" value="'.get_string('send', 'chat').'" />',
|
||||||
</div>
|
'<a id="choosetheme" href="###">'.get_string('themes').' ▶</a>'
|
||||||
-->
|
)
|
||||||
<div id="chat-userlist">
|
);
|
||||||
<ul id="users-list">
|
echo $OUTPUT->box($OUTPUT->table($table), '', 'chat-input-area');
|
||||||
</ul>
|
echo $OUTPUT->box('', '', 'chat-notify');
|
||||||
</div>
|
|
||||||
<div id="chat-options"></div>
|
|
||||||
<div id="chat-messages">
|
|
||||||
<ul id="messages-list"><ul>
|
|
||||||
</div>
|
|
||||||
<div id="chat-input-area">
|
|
||||||
<table width="100%">
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
»
|
|
||||||
<input type="text" disabled="true" id="input-message" value="Loading..." size="50" />
|
|
||||||
<input type="button" id="button-send" value="$str_send" />
|
|
||||||
</td>
|
|
||||||
<td align="right">
|
|
||||||
<a id="choosetheme" href="###">{$str_themes} ▶</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div id="chat-notify"></div>
|
|
||||||
DIVS;
|
|
||||||
echo $OUTPUT->footer();
|
echo $OUTPUT->footer();
|
||||||
|
|
||||||
|
|
240
mod/chat/gui_ajax/module.js
Normal file
240
mod/chat/gui_ajax/module.js
Normal file
|
@ -0,0 +1,240 @@
|
||||||
|
/**
|
||||||
|
* AJAX Chat Module
|
||||||
|
*/
|
||||||
|
YUI.add('mod_chat_ajax', function(Y) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @namespace M.mod_chat
|
||||||
|
*/
|
||||||
|
M.mod_chat = M.mod_chat || {};
|
||||||
|
/**
|
||||||
|
* This is the AJAX chat modules main namespace
|
||||||
|
* @namespace M.mod_chat.ajax
|
||||||
|
*/
|
||||||
|
M.mod_chat.ajax = {
|
||||||
|
|
||||||
|
// Properties
|
||||||
|
api : M.cfg.wwwroot+'/mod/chat/chat_ajax.php', // 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,
|
||||||
|
sendbutton : null,
|
||||||
|
messagebox : null,
|
||||||
|
|
||||||
|
init : function(m, cfg) {
|
||||||
|
this.cfg = cfg;
|
||||||
|
this.cfg.req_count = this.cfg.req_count || 0;
|
||||||
|
this.layout = new YAHOO.widget.Layout({
|
||||||
|
units : [
|
||||||
|
{position: 'right', width: 180, resize: true, gutter: '5px', scroll: true, body: 'chat-userlist', animate: false},
|
||||||
|
{position: 'bottom', height: 42, resize: false, body: 'chat-input-area', gutter: '5px', collapse: false, resize: false},
|
||||||
|
{position: 'center', body: 'chat-messages', gutter: '5px', scroll: true}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
this.layout.on('render', function() {
|
||||||
|
this.getUnitByPosition('left').on('close', function() {
|
||||||
|
closeLeft();
|
||||||
|
});
|
||||||
|
}, this.layout);
|
||||||
|
this.layout.render();
|
||||||
|
|
||||||
|
// Gather the general elements
|
||||||
|
this.messageinput = Y.one('#input-message');
|
||||||
|
this.sendbutton = Y.one('#button-send');
|
||||||
|
this.messagebox = Y.one('#chat-messages');
|
||||||
|
|
||||||
|
// Attach the default events for this module
|
||||||
|
this.sendbutton.on('click', this.send, this);
|
||||||
|
this.messagebox.on('mouseenter', new function(){this.scrollable = false;}, this);
|
||||||
|
this.messagebox.on('mouseleave', new function(){this.scrollable = true;}, this);
|
||||||
|
|
||||||
|
// 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
|
||||||
|
Y.io(this.api,{
|
||||||
|
method : 'POST',
|
||||||
|
data : build_querystring({
|
||||||
|
action : 'init',
|
||||||
|
chat_init : 1,
|
||||||
|
chat_sid : this.cfg.sid,
|
||||||
|
theme : this.theme
|
||||||
|
}),
|
||||||
|
on : {
|
||||||
|
success : function(tid, outcome) {
|
||||||
|
this.messageinput.focus();
|
||||||
|
this.messageinput.removeAttribute('disabled'),
|
||||||
|
this.messageinput.set('value', '');
|
||||||
|
try {
|
||||||
|
var data = Y.JSON.parse(outcome.responseText);
|
||||||
|
} catch (ex) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.update_users(data.users);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
context : this
|
||||||
|
});
|
||||||
|
|
||||||
|
this.interval = setInterval(function(me){
|
||||||
|
me.update_messages();
|
||||||
|
}, this.cfg.timer, this);
|
||||||
|
|
||||||
|
// Create and initalise theme changing menu
|
||||||
|
/*
|
||||||
|
this.thememenu = new Y.Overlay({
|
||||||
|
bodyContent : '<div class="menuitem"><a href="'+this.cfg.chaturl+'&theme=bubble">Bubble</a></div><div class="menuitem"><a href="'+this.cfg.chaturl+'&theme=compact">Compact</a></div>',
|
||||||
|
visible : false,
|
||||||
|
zIndex : 2,
|
||||||
|
align : {
|
||||||
|
node : '#choosetheme',
|
||||||
|
points : [Y.WidgetPositionExt.BL, Y.WidgetPositionExt.BR]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.thememenu.render(document.body);
|
||||||
|
Y.one('#choosetheme').on('click', function(e){
|
||||||
|
this.show();
|
||||||
|
this.get('boundingBox').setStyle('visibility', 'visible');
|
||||||
|
}, this.thememenu);
|
||||||
|
|
||||||
|
return;
|
||||||
|
*/
|
||||||
|
this.thememenu = new YAHOO.widget.Menu('basicmenu', {xy:[0,0]});
|
||||||
|
this.thememenu.addItems([
|
||||||
|
{text: "Bubble", url: this.cfg.chaturl+'&theme=bubble'},
|
||||||
|
{text: "Compact", url: this.cfg.chaturl+'&theme=compact'}
|
||||||
|
]);
|
||||||
|
this.thememenu.render(document.body);
|
||||||
|
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');
|
||||||
|
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" />');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
send : function(e, beep) {
|
||||||
|
this.sendbutton.set('value', M.str.chat.sending);
|
||||||
|
|
||||||
|
var data = {
|
||||||
|
chat_message : (!beep)?this.messageinput.get('value'):'',
|
||||||
|
chat_sid : this.cfg.sid,
|
||||||
|
theme : this.cfg.theme
|
||||||
|
}
|
||||||
|
if (beep) {
|
||||||
|
data.beep = beep
|
||||||
|
}
|
||||||
|
|
||||||
|
Y.io(this.api+'?action=chat', {
|
||||||
|
method : 'POST',
|
||||||
|
data : build_querystring(data),
|
||||||
|
on : {
|
||||||
|
success : this.send_callback
|
||||||
|
},
|
||||||
|
context : this
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
send_callback : function(tid, outcome, args) {
|
||||||
|
if(outcome.responseText == 200){
|
||||||
|
this.sendbutton.set('value', M.str.chat.send);
|
||||||
|
this.messageinput.set('value', '');
|
||||||
|
}
|
||||||
|
clearInterval(this.interval);
|
||||||
|
this.update_messages();
|
||||||
|
this.interval = setInterval(function(me){
|
||||||
|
me.update_messages();
|
||||||
|
}, this.cfg.timer, this);
|
||||||
|
},
|
||||||
|
|
||||||
|
talkto : function (name) {
|
||||||
|
this.messageinput.set('value', "To "+name+": ");
|
||||||
|
this.messageinput.focus();
|
||||||
|
},
|
||||||
|
|
||||||
|
update_messages : function() {
|
||||||
|
this.cfg.req_count++;
|
||||||
|
Y.io(this.api+'?action=update', {
|
||||||
|
method : 'POST',
|
||||||
|
data : build_querystring({
|
||||||
|
chat_lastrow : this.cfg.chat_lastrow || false,
|
||||||
|
chat_lasttime : this.cfg.chat_lasttime,
|
||||||
|
chat_sid : this.cfg.sid,
|
||||||
|
theme : this.cfg.theme
|
||||||
|
}),
|
||||||
|
on : {
|
||||||
|
success : this.update_messages_callback
|
||||||
|
},
|
||||||
|
context : this
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
update_messages_callback : function(tid, outcome) {
|
||||||
|
try {
|
||||||
|
var data = Y.JSON.parse(outcome.responseText);
|
||||||
|
} catch (ex) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (data.error) {
|
||||||
|
if (data.error.level == 'ERROR'){
|
||||||
|
clearInterval(this.interval);
|
||||||
|
window.location = this.cfg.home;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.cfg.chat_lasttime = data.lasttime;
|
||||||
|
this.cfg.chat_lastrow = data.lastrow;
|
||||||
|
// 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
|
||||||
|
this.update_users(data.users);
|
||||||
|
// Scroll to the bottom of the message list
|
||||||
|
if (this.scrollable) {
|
||||||
|
Y.Node.getDOMNode(this.messagebox).parentNode.scrollTop+=500;
|
||||||
|
}
|
||||||
|
this.messageinput.focus();
|
||||||
|
},
|
||||||
|
|
||||||
|
update_users : function(users) {
|
||||||
|
if(!users){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
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>');
|
||||||
|
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>'));
|
||||||
|
} 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>').on('click', this.talkto, this, users[i].name);
|
||||||
|
var beep = Y.Node.create('<a href="###">'+M.str.chat.beep+'</a>').on('click', this.send, this, users[i].id);
|
||||||
|
li.all('td').item(1).append(Y.Node.create('<div></div>').append(talk).append(beep));
|
||||||
|
}
|
||||||
|
list.append(li);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}, '2.0.0', {requires:['base', 'dom', 'event', 'event-mouseenter', 'event-key', 'json-parse', 'io', 'overlay', 'yui2-resize', 'yui2-layout']});
|
|
@ -1,253 +0,0 @@
|
||||||
YAHOO.namespace('moodle.chat');
|
|
||||||
YAHOO.moodle.chat.api = M.cfg.wwwroot+'/mod/chat/chat_ajax.php';
|
|
||||||
YAHOO.moodle.chat.interval = null;
|
|
||||||
YAHOO.moodle.chat.chat_input_element = null;
|
|
||||||
YAHOO.moodle.chat.msgs = [];
|
|
||||||
YAHOO.moodle.chat.scrollable = true;
|
|
||||||
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
var Dom = YAHOO.util.Dom, Event = YAHOO.util.Event;
|
|
||||||
// window.onload
|
|
||||||
Event.onDOMReady(function() {
|
|
||||||
var layout = new YAHOO.widget.Layout({
|
|
||||||
units: [
|
|
||||||
//{ position: 'top', height: 50, body: 'chat-header', gutter: '5px', resize: false },
|
|
||||||
{ position: 'right', width: 180, resize: true, gutter: '5px', scroll: true, body: 'chat-userlist', animate: false },
|
|
||||||
{ position: 'bottom', height: 42, resize: false, body: 'chat-input-area', gutter: '5px', collapse: false, resize: false },
|
|
||||||
//{ position: 'left', header: 'Options', width: 200, resize: true, body: 'chat-options', gutter: '5px', collapse: true, close: true, collapseSize: 50, scroll: true, animate: false },
|
|
||||||
{ position: 'center', body: 'chat-messages', gutter: '5px', scroll: true }
|
|
||||||
]
|
|
||||||
});
|
|
||||||
layout.on('render', function() {
|
|
||||||
layout.getUnitByPosition('left').on('close', function() {
|
|
||||||
closeLeft();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
layout.render();
|
|
||||||
Event.on('button-send', 'click', function(ev) {
|
|
||||||
Event.stopEvent(ev);
|
|
||||||
YAHOO.moodle.chat.send_message();
|
|
||||||
});
|
|
||||||
Event.on('chat-messages', 'mouseover', function(ev) {
|
|
||||||
Event.stopEvent(ev);
|
|
||||||
YAHOO.moodle.chat.scrollable = false;
|
|
||||||
});
|
|
||||||
Event.on('chat-messages', 'mouseout', function(ev) {
|
|
||||||
Event.stopEvent(ev);
|
|
||||||
YAHOO.moodle.chat.scrollable = true;
|
|
||||||
});
|
|
||||||
YAHOO.moodle.chat.chat_input_element = document.getElementById('input-message');
|
|
||||||
YAHOO.moodle.chat.chat_input_element.onkeypress = function(ev) {
|
|
||||||
var e = (ev)?ev:event;
|
|
||||||
if (e.keyCode == 13) {
|
|
||||||
YAHOO.moodle.chat.send_message();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
document.title = chat_cfg.chatroom_name;
|
|
||||||
|
|
||||||
this.cb = {
|
|
||||||
success: function(o){
|
|
||||||
YAHOO.moodle.chat.chat_input_element.focus();
|
|
||||||
document.getElementById('input-message').disabled = false;
|
|
||||||
document.getElementById('input-message').value = '';
|
|
||||||
document.getElementById('input-message').focus();
|
|
||||||
if(o.responseText){
|
|
||||||
var data = YAHOO.lang.JSON.parse(o.responseText);
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
YAHOO.moodle.chat.update_users(data.users);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var params = {};
|
|
||||||
params.action = 'init';
|
|
||||||
params.chat_init = 1;
|
|
||||||
params.chat_sid = chat_cfg.sid;
|
|
||||||
params.theme = chat_cfg.theme;
|
|
||||||
var trans = YAHOO.util.Connect.asyncRequest('POST', YAHOO.moodle.chat.api, this.cb, build_querystring(params));
|
|
||||||
YAHOO.moodle.chat.interval = setInterval(function(){
|
|
||||||
YAHOO.moodle.chat.update_messages();
|
|
||||||
}, chat_cfg.timer);
|
|
||||||
var oMenu = new YAHOO.widget.Menu("basicmenu", { xy:[0,0] });
|
|
||||||
oMenu.addItems([
|
|
||||||
{ text: "Bubble", url: chat_cfg.chaturl+'&theme=bubble'},
|
|
||||||
{ text: "Compact", url: chat_cfg.chaturl+'&theme=compact'},
|
|
||||||
]);
|
|
||||||
oMenu.render(document.body);
|
|
||||||
YAHOO.util.Event.addListener('choosetheme', 'click', function(e) {
|
|
||||||
var position = YAHOO.util.Event.getXY(e);
|
|
||||||
oMenu.moveTo(position[0]-120, position[1]-70);
|
|
||||||
oMenu.show();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
|
|
||||||
function in_array(f, t){
|
|
||||||
var a = false;
|
|
||||||
for( var i = 0; i<t.length; i++){
|
|
||||||
if(f==t[i]){
|
|
||||||
a=true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
YAHOO.moodle.chat.talkto = function(name) {
|
|
||||||
var msg = document.getElementById('input-message');
|
|
||||||
msg.value = "To "+name+": ";
|
|
||||||
msg.focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
YAHOO.moodle.chat.send_callback = {
|
|
||||||
success: function(o) {
|
|
||||||
if(o.responseText == 200){
|
|
||||||
document.getElementById('button-send').value = M.str.chat.send;
|
|
||||||
document.getElementById('input-message').value = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
clearInterval(YAHOO.moodle.chat.interval)
|
|
||||||
YAHOO.moodle.chat.update_messages();
|
|
||||||
YAHOO.moodle.chat.interval = setInterval(function(){
|
|
||||||
YAHOO.moodle.chat.update_messages();
|
|
||||||
}, chat_cfg.timer);
|
|
||||||
//document.getElementById('input-message').focus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
YAHOO.moodle.chat.send_message = function(ev) {
|
|
||||||
var msg = document.getElementById('input-message').value;
|
|
||||||
var el_send = document.getElementById('button-send');
|
|
||||||
if (!msg) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
el_send.value = M.str.chat.sending;
|
|
||||||
var params = {};
|
|
||||||
params.chat_message=msg;
|
|
||||||
params.chat_sid=chat_cfg.sid;
|
|
||||||
params.theme = chat_cfg.theme;
|
|
||||||
var trans = YAHOO.util.Connect.asyncRequest('POST', YAHOO.moodle.chat.api+"?action=chat", YAHOO.moodle.chat.send_callback, build_querystring(params));
|
|
||||||
}
|
|
||||||
|
|
||||||
YAHOO.moodle.chat.send_beep = function(user_id) {
|
|
||||||
var url = 'post.php?chat_sid='+chat_cfg.sid;
|
|
||||||
var params = {};
|
|
||||||
params.chat_sid = chat_cfg.sid;
|
|
||||||
params.beep=user_id;
|
|
||||||
params.theme = chat_cfg.theme;
|
|
||||||
var trans = YAHOO.util.Connect.asyncRequest('POST', YAHOO.moodle.chat.api+"?action=chat", YAHOO.moodle.chat.send_callback, build_querystring(params));
|
|
||||||
}
|
|
||||||
|
|
||||||
YAHOO.moodle.chat.update_users = function(users) {
|
|
||||||
if(!users){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var list = document.getElementById('users-list');
|
|
||||||
list.innerHTML = '';
|
|
||||||
for(var i in users){
|
|
||||||
var el = document.createElement('li');
|
|
||||||
var html = '';
|
|
||||||
html += '<table>';
|
|
||||||
html += '<tr>';
|
|
||||||
html += '<td>' + users[i].picture + '</td>';
|
|
||||||
html += '<td>';
|
|
||||||
if (users[i].id==chat_cfg.userid) {
|
|
||||||
html += ' <strong><a target="_blank" href="'+users[i].url+'">'+ users[i].name+'</a></strong>';
|
|
||||||
} else {
|
|
||||||
html += ' <a target="_blank" href="'+users[i].url+'">'+ users[i].name+'</a>';
|
|
||||||
}
|
|
||||||
html += '<br />';
|
|
||||||
if (users[i].id!=chat_cfg.userid) {
|
|
||||||
html += ' <a href="###" onclick="YAHOO.moodle.chat.talkto(\''+users[i].name+'\')">'+M.str.chat.talk+'</a> ';
|
|
||||||
html += ' <a href="###" onclick="YAHOO.moodle.chat.send_beep('+users[i].id+')">'+M.str.chat.beep+'</a>';
|
|
||||||
}
|
|
||||||
html += '</td>';
|
|
||||||
html += '</tr>';
|
|
||||||
html += '</table>';
|
|
||||||
el.innerHTML = html;
|
|
||||||
list.appendChild(el);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
YAHOO.moodle.chat.update_messages = function() {
|
|
||||||
if(!chat_cfg.req_count){
|
|
||||||
chat_cfg.req_count = 1;
|
|
||||||
} else {
|
|
||||||
chat_cfg.req_count++;
|
|
||||||
}
|
|
||||||
var params = {};
|
|
||||||
if(chat_cfg.chat_lastrow != null){
|
|
||||||
params.chat_lastrow = chat_cfg.chat_lastrow;
|
|
||||||
}
|
|
||||||
params.chat_lasttime = chat_cfg.chat_lasttime;
|
|
||||||
params.chat_sid = chat_cfg.sid;
|
|
||||||
params.theme = chat_cfg.theme;
|
|
||||||
var trans = YAHOO.util.Connect.asyncRequest('POST', YAHOO.moodle.chat.api+"?action=update", YAHOO.moodle.chat.update_cb, build_querystring(params));
|
|
||||||
}
|
|
||||||
|
|
||||||
YAHOO.moodle.chat.mymsg_cfg = {
|
|
||||||
color: { to: '#06e' },
|
|
||||||
backgroundColor: { to: '#e06' }
|
|
||||||
};
|
|
||||||
YAHOO.moodle.chat.oddmsg_cfg = {
|
|
||||||
color: { to: 'red' },
|
|
||||||
backgroundColor: { to: '#FFFFCC' }
|
|
||||||
};
|
|
||||||
YAHOO.moodle.chat.evenmsg_cfg = {
|
|
||||||
color: { to: 'blue' }
|
|
||||||
};
|
|
||||||
|
|
||||||
YAHOO.moodle.chat.append_msg = function(key, msg, row) {
|
|
||||||
var list = document.getElementById('messages-list');
|
|
||||||
var item = document.createElement('li');
|
|
||||||
item.id="mdl-chat-entry-"+key;
|
|
||||||
if (msg.mymessage) {
|
|
||||||
item.className = 'mdl-chat-my-entry';
|
|
||||||
} else {
|
|
||||||
item.className = 'mdl-chat-entry';
|
|
||||||
}
|
|
||||||
item.innerHTML = msg.message;
|
|
||||||
if(msg.type && msg.type == 'beep') {
|
|
||||||
document.getElementById('chat-notify').innerHTML = '<embed src="../beep.wav" autostart="true" hidden="true" name="beep" />';
|
|
||||||
}
|
|
||||||
list.appendChild(item);
|
|
||||||
if (!row) {
|
|
||||||
var anim = new YAHOO.util.ColorAnim(item.id, YAHOO.moodle.chat.oddmsg_cfg);
|
|
||||||
//anim.animate();
|
|
||||||
}
|
|
||||||
if (msg.mymessage) {
|
|
||||||
//var anim = new YAHOO.util.ColorAnim(item.id, YAHOO.moodle.chat.mymsg_cfg);
|
|
||||||
//anim.animate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
YAHOO.moodle.chat.update_cb = {
|
|
||||||
success: function(o){
|
|
||||||
var data = Y.JSON.parse(o.responseText);
|
|
||||||
if (!data) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(data.error) {
|
|
||||||
if(data.error.level == 'ERROR'){
|
|
||||||
clearInterval(YAHOO.moodle.chat.interval);
|
|
||||||
window.location = chat_cfg.home;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
chat_cfg.chat_lasttime = data['lasttime'];
|
|
||||||
chat_cfg.chat_lastrow = data['lastrow'];
|
|
||||||
// update messages
|
|
||||||
for (key in data['msgs']){
|
|
||||||
if(!in_array(key, YAHOO.moodle.chat.msgs)){
|
|
||||||
YAHOO.moodle.chat.msgs.push(key);
|
|
||||||
YAHOO.moodle.chat.append_msg(key, data['msgs'][key], data.lastrow);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// update users
|
|
||||||
YAHOO.moodle.chat.update_users(data['users']);
|
|
||||||
// scroll to the bottom of the message list
|
|
||||||
if(YAHOO.moodle.chat.scrollable){
|
|
||||||
document.getElementById('chat-messages').parentNode.scrollTop+=500;
|
|
||||||
}
|
|
||||||
YAHOO.moodle.chat.chat_input_element.focus();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
var waitFlag = false;
|
|
||||||
function empty_field_and_submit() {
|
|
||||||
if(waitFlag) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
waitFlag = true;
|
|
||||||
var input_chat_message = document.getElementById('input_chat_message');
|
|
||||||
document.getElementById('sendForm').chat_message.value = input_chat_message.value;
|
|
||||||
input_chat_message.value = '';
|
|
||||||
input_chat_message.className = 'wait';
|
|
||||||
document.getElementById('sendForm').submit();
|
|
||||||
enableForm();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function enableForm() {
|
|
||||||
var input_chat_message = document.getElementById('input_chat_message');
|
|
||||||
waitFlag = false;
|
|
||||||
input_chat_message.className = '';
|
|
||||||
input_chat_message.focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
var timer = null
|
|
||||||
var f = 1; //seconds
|
|
||||||
function stop() {
|
|
||||||
clearTimeout(timer)
|
|
||||||
}
|
|
||||||
|
|
||||||
function start() {
|
|
||||||
timer = setTimeout("update()", f*1000);
|
|
||||||
YAHOO.util.Event.addListener(document.body, 'unload', stop);
|
|
||||||
}
|
|
||||||
|
|
||||||
function update() {
|
|
||||||
for(i=0; i<uidles.length; i++) {
|
|
||||||
el = document.getElementById(uidles[i]);
|
|
||||||
if (el != null) {
|
|
||||||
parts = el.innerHTML.split(":");
|
|
||||||
time = f + (parseInt(parts[0], 10)*60) + parseInt(parts[1], 10);
|
|
||||||
min = Math.floor(time/60);
|
|
||||||
sec = time % 60;
|
|
||||||
el.innerHTML = ((min < 10) ? "0" : "") + min + ":" + ((sec < 10) ? "0" : "") + sec;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
timer = setTimeout("update()", f*1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
function insert_redirect() {
|
|
||||||
parent.jsupdate.location.href = parent.jsupdate.document.anchors[0].href;
|
|
||||||
}
|
|
|
@ -30,26 +30,31 @@ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||||
//Get the user theme
|
//Get the user theme
|
||||||
$USER = $DB->get_record('user', array('id'=>$chatuser->userid));
|
$USER = $DB->get_record('user', array('id'=>$chatuser->userid));
|
||||||
|
|
||||||
|
|
||||||
|
$module = array(
|
||||||
|
'name' => 'mod_chat_js',
|
||||||
|
'fullpath' => '/mod/chat/gui_header_js/module.js',
|
||||||
|
'requires' => array('base', 'node')
|
||||||
|
);
|
||||||
|
$PAGE->requires->js_init_call('M.mod_chat_js.init', array(false), false, $module);
|
||||||
|
|
||||||
//Setup course, lang and theme
|
//Setup course, lang and theme
|
||||||
$PAGE->set_course($course);
|
$PAGE->set_course($course);
|
||||||
$PAGE->requires->js('/mod/chat/gui_header_js/chat_gui_header.js', true);
|
|
||||||
$PAGE->set_pagelayout('embedded');
|
$PAGE->set_pagelayout('embedded');
|
||||||
$PAGE->set_focuscontrol('input_chat_message');
|
$PAGE->set_focuscontrol('input_chat_message');
|
||||||
$PAGE->set_cacheable(false);
|
$PAGE->set_cacheable(false);
|
||||||
echo $OUTPUT->header();
|
echo $OUTPUT->header();
|
||||||
|
|
||||||
?>
|
echo html_writer::start_tag('form', array('action'=>'../empty.php', 'method'=>'post', 'target'=>'empty', 'id'=>'inputForm', 'style'=>'margin:0'));
|
||||||
<form action="../empty.php" method="post" target="empty" id="inputForm"
|
echo html_writer::empty_tag('input', array('type'=>'text', 'id'=>'input_chat_message', 'name'=>'chat_message', 'size'=>'50', 'value'=>''));
|
||||||
onsubmit="return empty_field_and_submit()" style="margin:0">
|
echo html_writer::empty_tag('input', array('type'=>'checkbox', 'id'=>'auto', 'checked'=>'checked', 'value'=>''));
|
||||||
<input type="text" id="input_chat_message" name="chat_message" size="50" value="" />
|
echo html_writer::tag('label', array('for'=>'auto'), get_string('autoscroll', 'chat'));
|
||||||
<?php echo $OUTPUT->help_icon('chatting', get_string('helpchatting', 'chat'), 'chat', true); ?><br />
|
echo $OUTPUT->help_icon('chatting', get_string('helpchatting', 'chat'), 'chat', true);
|
||||||
<input type="checkbox" id="auto" size="50" value="" checked="checked" /><label for="auto"><?php echo get_string('autoscroll', 'chat');?></label>
|
echo html_writer::end_tag('form');
|
||||||
</form>
|
|
||||||
|
|
||||||
<form action="insert.php" method="post" target="empty" id="sendForm">
|
echo html_writer::start_tag('form', array('action'=>'insert.php', 'method'=>'post', 'target'=>'empty', 'id'=>'sendForm'));
|
||||||
<input type="hidden" name="chat_sid" value="<?php echo $chat_sid ?>" />
|
echo html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'chat_sid', 'value'=>$chat_sid));
|
||||||
<input type="hidden" name="chat_message" />
|
echo html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'chat_message', 'id'=>'insert_chat_message'));
|
||||||
</form>
|
echo html_writer::end_tag('form');
|
||||||
<?php
|
|
||||||
echo $OUTPUT->footer();
|
echo $OUTPUT->footer();
|
||||||
?>
|
|
73
mod/chat/gui_header_js/module.js
Normal file
73
mod/chat/gui_header_js/module.js
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
YUI.add('mod_chat_js', function(Y){
|
||||||
|
|
||||||
|
M.mod_chat_js = {
|
||||||
|
|
||||||
|
waitflag : false,
|
||||||
|
timer : null,
|
||||||
|
timeout : 1,
|
||||||
|
users : [],
|
||||||
|
|
||||||
|
init : function(Y, users) {
|
||||||
|
if (users) {
|
||||||
|
this.users = users;
|
||||||
|
this.start();
|
||||||
|
Y.one(document.body).on('unload', this.stop, this);
|
||||||
|
}
|
||||||
|
var inputform = Y.one('#inputForm');
|
||||||
|
if (inputform) {
|
||||||
|
inputform.on('submit', this.submit, this);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
start : function() {
|
||||||
|
this.timer = setTimeout(function(self){
|
||||||
|
self.update();
|
||||||
|
}, this.timeout*1000, this);
|
||||||
|
},
|
||||||
|
|
||||||
|
stop : function() {
|
||||||
|
clearTimeout(this.timer);
|
||||||
|
},
|
||||||
|
|
||||||
|
update : function() {
|
||||||
|
for (var i in this.users) {
|
||||||
|
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 sec = time % 60;
|
||||||
|
el.set('innerHTML', ((min < 10) ? "0" : "") + min + ":" + ((sec < 10) ? "0" : "") + sec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.start();
|
||||||
|
},
|
||||||
|
|
||||||
|
insert_redirect : function() {
|
||||||
|
parent.jsupdate.location.href = parent.jsupdate.document.anchors[0].href;
|
||||||
|
},
|
||||||
|
|
||||||
|
enable_form : function(el) {
|
||||||
|
this.waitflag = false;
|
||||||
|
el.set('className','');
|
||||||
|
el.focus();
|
||||||
|
},
|
||||||
|
|
||||||
|
submit : function(e) {
|
||||||
|
e.halt();
|
||||||
|
if(this.waitflag) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this.waitflag = true;
|
||||||
|
var inputchatmessage = Y.one('#input_chat_message');
|
||||||
|
Y.one('#insert_chat_message').set('value', inputchatmessage.get('value'));
|
||||||
|
inputchatmessage.set('value', '');
|
||||||
|
inputchatmessage.addClass('wait');
|
||||||
|
Y.one('#sendForm').submit();
|
||||||
|
this.enable_form(inputchatmessage);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}, '2.0.0', {requires:['base','node']});
|
|
@ -63,25 +63,25 @@ if (!$chatusers = chat_get_users($chatuser->chatid, $chatuser->groupid, $cm->gro
|
||||||
}
|
}
|
||||||
|
|
||||||
$uidles = Array();
|
$uidles = Array();
|
||||||
$i = 0;
|
|
||||||
foreach ($chatusers as $chatuser) {
|
foreach ($chatusers as $chatuser) {
|
||||||
$uidles[$i] = 'uidle{$chatuser->id}';
|
$uidles[] = $chatuser->id;
|
||||||
$i++;
|
|
||||||
}
|
}
|
||||||
$PAGE->requires->data_for_js('uidles', $uidles);
|
|
||||||
$PAGE->requires->js('/mod/chat/gui_header_js/chat_gui_header.js');
|
$module = array(
|
||||||
$PAGE->requires->js_function_call('start', null, true);
|
'name' => 'mod_chat_js',
|
||||||
ob_start();
|
'fullpath' => '/mod/chat/gui_header_js/module.js',
|
||||||
echo $OUTPUT->header();
|
'requires' => array('base', 'node')
|
||||||
|
);
|
||||||
|
$PAGE->requires->js_init_call('M.mod_chat_js.init', array($uidles), false, $module);
|
||||||
|
|
||||||
/// Print user panel body
|
/// Print user panel body
|
||||||
$timenow = time();
|
$timenow = time();
|
||||||
$stridle = get_string('idle', 'chat');
|
$stridle = get_string('idle', 'chat');
|
||||||
$strbeep = get_string('beep', 'chat');
|
$strbeep = get_string('beep', 'chat');
|
||||||
|
|
||||||
|
$table = new html_table();
|
||||||
echo '<div style="display: none"><a href="'.$refreshurl.'" id="refreshLink">Refresh link</a></div>';
|
$table->width = '100%';
|
||||||
echo '<table width="100%">';
|
$table->data = array();
|
||||||
foreach ($chatusers as $chatuser) {
|
foreach ($chatusers as $chatuser) {
|
||||||
$lastping = $timenow - $chatuser->lastmessageping;
|
$lastping = $timenow - $chatuser->lastmessageping;
|
||||||
$min = (int) ($lastping/60);
|
$min = (int) ($lastping/60);
|
||||||
|
@ -89,19 +89,25 @@ foreach ($chatusers as $chatuser) {
|
||||||
$min = $min < 10 ? '0'.$min : $min;
|
$min = $min < 10 ? '0'.$min : $min;
|
||||||
$sec = $sec < 10 ? '0'.$sec : $sec;
|
$sec = $sec < 10 ? '0'.$sec : $sec;
|
||||||
$idle = $min.':'.$sec;
|
$idle = $min.':'.$sec;
|
||||||
echo '<tr><td width="35">';
|
|
||||||
echo "<a target=\"_blank\" onClick=\"return openpopup('/user/view.php?id=$chatuser->id&course=$courseid','user$chatuser->id','');\" href=\"$CFG->wwwroot/user/view.php?id=$chatuser->id&course=$courseid\">";
|
|
||||||
echo $OUTPUT->user_picture($chatuser, array('courseid'=>$courseid));
|
$row = array();
|
||||||
echo '</a></td><td valign="center">';
|
//$popupid = $OUTPUT->add_action_handler(new component_action('click', 'openpopup', array('url'=>'/user/view.php?id=$chatuser->id&course=$courseid', 'name'=>'user'.$chatuser->id, 'options'=>'')));
|
||||||
echo '<p><font size="1">';
|
$row[0] = $OUTPUT->user_picture($chatuser, array('courseid'=>$courseid, 'popup'=>true));
|
||||||
echo fullname($chatuser).'<br />';
|
$row[1] = html_writer::start_tag('p');
|
||||||
echo "<span class=\"dimmed_text\">$stridle <span name=\"uidles\" id=\"uidle{$chatuser->id}\">$idle</span></span>";
|
$row[1] .= html_writer::start_tag('font', array('size'=>'1'));
|
||||||
echo " <a href=\"users.php?chat_sid=$chat_sid&beep=$chatuser->id\">$strbeep</a>";
|
$row[1] .= fullname($chatuser).'<br />';
|
||||||
echo '</font></p>';
|
$row[1] .= html_writer::tag('span', array('class'=>'dimmed_text'), $stridle . html_writer::tag('span', array('name'=>'uidles', 'id'=>'uidle'.$chatuser->id), $idle)).' ';
|
||||||
echo '</td></tr>';
|
$row[1] .= html_writer::tag('a', array('href'=>new moodle_url('/mod/chat/gui_header_js/users.php', array('chat_sid'=>$chat_sid, 'beep'=>$chatuser->id))), $strbeep);
|
||||||
|
$row[1] .= html_writer::end_tag('font');
|
||||||
|
$row[1] .= html_writer::end_tag('p');
|
||||||
|
$table->data[] = $row;
|
||||||
}
|
}
|
||||||
// added 2 </div>s, xhtml strict complaints
|
|
||||||
echo '</table>';
|
ob_start();
|
||||||
|
echo $OUTPUT->header();
|
||||||
|
echo html_writer::tag('div', array('style'=>'display:none'), html_writer::tag('a', array('href'=>$refreshurl, 'id'=>'refreshLink'), 'Refresh link'));
|
||||||
|
echo $OUTPUT->table($table);
|
||||||
echo $OUTPUT->footer();
|
echo $OUTPUT->footer();
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -894,7 +894,7 @@ function chat_format_message($message, $courseid, $currentuser, $chat_lastrow=NU
|
||||||
|
|
||||||
if (isset($users[$message->userid])) {
|
if (isset($users[$message->userid])) {
|
||||||
$user = $users[$message->userid];
|
$user = $users[$message->userid];
|
||||||
} else if ($user = $DB->get_record('user', array('id'=>$message->userid), 'id,picture,firstname,lastname')) {
|
} else if ($user = $DB->get_record('user', array('id'=>$message->userid), 'id,picture,firstname,lastname,imagealt')) {
|
||||||
$users[$message->userid] = $user;
|
$users[$message->userid] = $user;
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -923,7 +923,7 @@ function chat_format_message_theme ($message, $courseid, $currentuser, $theme =
|
||||||
|
|
||||||
if (isset($users[$message->userid])) {
|
if (isset($users[$message->userid])) {
|
||||||
$sender = $users[$message->userid];
|
$sender = $users[$message->userid];
|
||||||
} else if ($sender = $DB->get_record('user', array('id'=>$message->userid), 'id,picture,firstname,lastname')) {
|
} else if ($sender = $DB->get_record('user', array('id'=>$message->userid), 'id,picture,firstname,lastname,imagealt')) {
|
||||||
$users[$message->userid] = $sender;
|
$users[$message->userid] = $sender;
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1261,7 +1261,7 @@ function chat_extend_navigation($navigation, $course, $module, $cm) {
|
||||||
foreach ($links as $link) {
|
foreach ($links as $link) {
|
||||||
$link->add_action(new popup_action('click', $link->url, 'chat'.$course->id.$cm->instance.$currentgroup, array('height' => 500, 'width' => 700)));
|
$link->add_action(new popup_action('click', $link->url, 'chat'.$course->id.$cm->instance.$currentgroup, array('height' => 500, 'width' => 700)));
|
||||||
$link->title = get_string('modulename', 'chat');
|
$link->title = get_string('modulename', 'chat');
|
||||||
$navigation->add($link->title, $link, navigation_node::TYPE_ACTIVITY, null ,null, $OUTPUT->pix_url('c/group'));
|
$navigation->add($link->title, $link, navigation_node::TYPE_ACTIVITY, null ,null, new pix_icon('c/group' , ''));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue