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);
if ($PAGE->user_allowed_editing() && !empty($CFG->showblocksonmodpages)) {
$buttons = '
'; $link = new moodle_url("/mod/chat/gui_ajax/index.php?id=$chat->id$groupparam"); $action = new popup_action('click', $link, "chat$course->id$chat->id$groupparam", array('height' => 500, 'width' => 700, 'toolbar' => false, 'resizeable' => false, 'status' => false)); echo $OUTPUT->action_link($link, get_string('ajax_gui', 'message'), $action, array('title'=>get_string('modulename', 'chat'))); echo '
'; } else { if (!empty($USER->screenreader)) { $chattarget = "/mod/chat/gui_basic/index.php?id=$chat->id$groupparam"; } else { $chattarget = "/mod/chat/gui_$CFG->chat_method/index.php?id=$chat->id$groupparam"; } echo ''; echo $OUTPUT->action_link($chattarget, $strenterchat, new popup_action('click', $chattarget, "chat$course->id$chat->id$groupparam", array('height' => 500, 'width' => 700))); echo '
'; } // if user is using screen reader, then there is no need to display this link again // users with screenreader set, will only see 1 link, to the manual refresh page // for better accessibility if ($CFG->chat_method == 'header_js' && empty($USER->screenreader)) { // show frame/js-less alternative echo '('; $link = new moodle_url("/mod/chat/gui_basic/index.php?id=$chat->id$groupparam"); $action = new popup_action('click', $link, "chat$course->id$chat->id$groupparam", array('height' => 500, 'width' => 700)); echo $OUTPUT->action_link($link, get_string('noframesjs', 'message'), $action, array('title'=>get_string('modulename', 'chat'))); 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($chatuser); echo ' | ';
echo ' ';
echo fullname($chatuser).' |