dirroot . '/mod/chat/lib.php');
$id = optional_param('id', 0, PARAM_INT);
$c = optional_param('c', 0, PARAM_INT);
$edit = optional_param('edit', -1, PARAM_BOOL);
if ($id) {
if (! $cm = get_coursemodule_from_id('chat', $id)) {
print_error('invalidcoursemodule');
}
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))) {
print_error('invalidid', 'chat');
}
} else {
chat_update_chat_times($c);
if (! $chat = $DB->get_record('chat', array('id'=>$c))) {
print_error('coursemisconf');
}
if (! $course = $DB->get_record('course', array('id'=>$chat->course))) {
print_error('coursemisconf');
}
if (! $cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) {
print_error('invalidcoursemodule');
}
}
require_course_login($course, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
// show some info for guests
if (isguestuser()) {
$PAGE->set_title(format_string($chat->name));
echo $OUTPUT->header();
echo $OUTPUT->confirm(get_string('noguests', 'chat').'
'.get_string('liketologin'),
get_login_url(), $CFG->wwwroot.'/course/view.php?id='.$course->id);
echo $OUTPUT->footer();
exit;
}
add_to_log($course->id, 'chat', 'view', "view.php?id=$cm->id", $chat->id, $cm->id);
// Initialize $PAGE, compute blocks
$PAGE->set_url('mod/chat/view.php', array('id' => $cm->id));
/// Print the page header
$strenterchat = get_string('enterchat', 'chat');
$stridle = get_string('idle', 'chat');
$strcurrentusers = get_string('currentusers', 'chat');
$strnextsession = get_string('nextsession', 'chat');
if (($edit != -1) and $PAGE->user_allowed_editing()) {
$USER->editing = $edit;
}
$title = $course->shortname . ': ' . format_string($chat->name);
$buttons = '
'.$OUTPUT->update_module_button($cm->id, $cm->modname).' | '; if ($PAGE->user_allowed_editing() && !empty($CFG->showblocksonmodpages)) { $buttons .= ''; } $buttons .= ' |
'; $link = html_link::make($chattarget, $strenterchat); $link->add_action(new popup_action('click', $link->url, "chat$course->id$chat->id$groupparam", array('height' => 500, 'width' => 700))); $link->title = get_string('modulename', 'chat'); echo $OUTPUT->link($link); echo '
'; if ($CFG->enableajax) { echo ''; $link = html_link::make("/mod/chat/gui_ajax/index.php?id=$chat->id$groupparam", get_string('ajax_gui', 'message')); $link->add_action(new popup_action('click', $link->url, "chat$course->id$chat->id$groupparam", array('height' => 500, 'width' => 700, 'toolbar' => false, 'resizeable' => false, 'status' => false))); $link->title = get_string('modulename', 'chat'); echo $OUTPUT->link($link); echo '
'; } // if user is using screen reader, then there is no need to display this link again if ($CFG->chat_method == 'header_js' && empty($USER->screenreader)) { // show frame/js-less alternative echo '('; $link = html_link::make("/mod/chat/gui_basic/index.php?id=$chat->id$groupparam", get_string('noframesjs', 'message')); $link->add_action(new popup_action('click', $link->url, "chat$course->id$chat->id$groupparam", array('height' => 500, 'width' => 700))); $link->title = get_string('modulename', 'chat'); echo $OUTPUT->link($link); echo ')
'; } echo $OUTPUT->box_end(); } else { echo $OUTPUT->box_start('generalbox', 'notallowenter'); echo ''.get_string('notallowenter', 'chat').'
'; echo $OUTPUT->box_end(); } if ($chat->chattime and $chat->schedule) { // A chat is scheduled echo "$strnextsession: ".userdate($chat->chattime).' ('.usertimezone($USER->timezone).')
'; } else { echo ''; echo "wwwroot/user/view.php?id=$chatuser->id&course=$chat->course\">"; echo $OUTPUT->user_picture(moodle_user_picture::make($chatuser, $COURSE->id)); echo ' | ';
echo ' ';
echo fullname($chatuser).' |