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);
|
||||
}
|
||||
$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))) {
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
|
||||
if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
$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 = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
require_login($course->id, false, $cm);
|
||||
require_capability('mod/chat:chat',$context);
|
||||
|
||||
if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_MODULE, $cm->id))) {
|
||||
echo $OUTPUT->header();
|
||||
notice(get_string("activityiscurrentlyhidden"));
|
||||
exit;
|
||||
}
|
||||
|
||||
/// 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');
|
||||
}
|
||||
|
||||
$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')) {
|
||||
$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,
|
||||
'chaturl'=>$CFG->httpswwwroot.'/mod/chat/gui_ajax/index.php?id='.$id,
|
||||
'theme'=>$theme,
|
||||
|
@ -79,56 +63,27 @@ $PAGE->requires->data_for_js('chat_cfg', array(
|
|||
'timer'=>3000,
|
||||
'chat_lasttime'=>0,
|
||||
'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->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->set_title('Chat');
|
||||
$PAGE->add_body_class('yui-skin-sam');
|
||||
$PAGE->set_pagelayout('embedded');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
$intro = format_text($chat->intro, $chat->introformat);
|
||||
$home_url = $CFG->httpswwwroot.'/mod/chat/gui_ajax/index.php?id='.$id;
|
||||
|
||||
echo <<<DIVS
|
||||
<!--
|
||||
<div id="chat-header">
|
||||
{$chat->name} <p>{$intro}</p>
|
||||
</div>
|
||||
-->
|
||||
<div id="chat-userlist">
|
||||
<ul id="users-list">
|
||||
</ul>
|
||||
</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->box('<ul id="users-list"></ul>', '', 'chat-userlist');
|
||||
echo $OUTPUT->box('', '', 'chat-options');
|
||||
echo $OUTPUT->box('<ul id="messages-list"></ul>', '', 'chat-messages');
|
||||
$table = new html_table();
|
||||
$table->data = array(
|
||||
array(
|
||||
' »<input type="text" disabled="true" id="input-message" value="Loading..." size="50" /><input type="button" id="button-send" value="'.get_string('send', 'chat').'" />',
|
||||
'<a id="choosetheme" href="###">'.get_string('themes').' ▶</a>'
|
||||
)
|
||||
);
|
||||
echo $OUTPUT->box($OUTPUT->table($table), '', 'chat-input-area');
|
||||
echo $OUTPUT->box('', '', 'chat-notify');
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue