2004-09-12 15:06:29 +00:00
|
|
|
<?php // $Id$
|
2003-07-07 06:44:16 +00:00
|
|
|
|
|
|
|
/// This page prints a particular instance of chat
|
|
|
|
|
2005-02-03 20:39:27 +00:00
|
|
|
require_once('../../config.php');
|
|
|
|
require_once('lib.php');
|
2005-02-10 01:59:11 +00:00
|
|
|
require_once($CFG->libdir.'/blocklib.php');
|
2005-02-09 16:44:35 +00:00
|
|
|
require_once('pagelib.php');
|
2007-05-09 15:03:01 +00:00
|
|
|
|
|
|
|
if (!empty($THEME->customcorners)) {
|
|
|
|
require_once($CFG->dirroot.'/lib/custom_corners_lib.php');
|
|
|
|
}
|
2003-07-07 06:44:16 +00:00
|
|
|
|
2006-04-23 20:58:06 +00:00
|
|
|
$id = optional_param('id', 0, PARAM_INT);
|
|
|
|
$c = optional_param('c', 0, PARAM_INT);
|
|
|
|
$edit = optional_param('edit', -1, PARAM_BOOL);
|
2003-07-07 06:44:16 +00:00
|
|
|
|
|
|
|
if ($id) {
|
2006-08-08 22:09:55 +00:00
|
|
|
if (! $cm = get_coursemodule_from_id('chat', $id)) {
|
2005-02-03 20:39:27 +00:00
|
|
|
error('Course Module ID was incorrect');
|
2003-07-07 06:44:16 +00:00
|
|
|
}
|
2005-02-03 20:39:27 +00:00
|
|
|
|
|
|
|
if (! $course = get_record('course', 'id', $cm->course)) {
|
|
|
|
error('Course is misconfigured');
|
2003-07-07 06:44:16 +00:00
|
|
|
}
|
2003-07-25 06:47:06 +00:00
|
|
|
|
|
|
|
chat_update_chat_times($cm->instance);
|
2005-02-03 20:39:27 +00:00
|
|
|
|
|
|
|
if (! $chat = get_record('chat', 'id', $cm->instance)) {
|
|
|
|
error('Course module is incorrect');
|
2003-07-07 06:44:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2003-07-25 06:47:06 +00:00
|
|
|
chat_update_chat_times($c);
|
|
|
|
|
2005-02-03 20:39:27 +00:00
|
|
|
if (! $chat = get_record('chat', 'id', $c)) {
|
|
|
|
error('Course module is incorrect');
|
2003-07-07 06:44:16 +00:00
|
|
|
}
|
2005-02-03 20:39:27 +00:00
|
|
|
if (! $course = get_record('course', 'id', $chat->course)) {
|
|
|
|
error('Course is misconfigured');
|
2003-07-07 06:44:16 +00:00
|
|
|
}
|
2005-02-03 20:39:27 +00:00
|
|
|
if (! $cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) {
|
|
|
|
error('Course Module ID was incorrect');
|
2003-07-07 06:44:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-03 20:39:27 +00:00
|
|
|
|
2006-08-08 05:13:06 +00:00
|
|
|
require_course_login($course, true, $cm);
|
|
|
|
|
2006-08-09 13:45:49 +00:00
|
|
|
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
2006-08-08 05:13:06 +00:00
|
|
|
|
2006-08-09 13:45:49 +00:00
|
|
|
add_to_log($course->id, 'chat', 'view', "view.php?id=$cm->id", $chat->id, $cm->id);
|
2003-07-07 06:44:16 +00:00
|
|
|
|
2005-02-09 15:47:22 +00:00
|
|
|
// Initialize $PAGE, compute blocks
|
|
|
|
|
2005-03-02 05:19:47 +00:00
|
|
|
$PAGE = page_create_instance($chat->id);
|
|
|
|
$pageblocks = blocks_setup($PAGE);
|
2005-02-09 15:47:22 +00:00
|
|
|
$blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
|
|
|
|
|
2003-07-07 06:44:16 +00:00
|
|
|
/// Print the page header
|
|
|
|
|
2005-02-03 20:39:27 +00:00
|
|
|
$strenterchat = get_string('enterchat', 'chat');
|
|
|
|
$stridle = get_string('idle', 'chat');
|
|
|
|
$strcurrentusers = get_string('currentusers', 'chat');
|
|
|
|
$strnextsession = get_string('nextsession', 'chat');
|
2003-07-07 06:44:16 +00:00
|
|
|
|
2006-04-23 20:58:06 +00:00
|
|
|
if (($edit != -1) and $PAGE->user_allowed_editing()) {
|
|
|
|
$USER->editing = $edit;
|
2005-02-09 15:47:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$PAGE->print_header($course->shortname.': %fullname%');
|
|
|
|
|
2005-02-12 11:37:09 +00:00
|
|
|
echo '<table id="layout-table"><tr>';
|
2005-02-09 15:47:22 +00:00
|
|
|
|
2005-03-16 03:26:21 +00:00
|
|
|
if(!empty($CFG->showblocksonmodpages) && (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $PAGE->user_is_editing())) {
|
2005-02-12 11:37:09 +00:00
|
|
|
echo '<td style="width: '.$blocks_preferred_width.'px;" id="left-column">';
|
2007-05-09 15:03:01 +00:00
|
|
|
if (!empty($THEME->customcorners)) print_custom_corners_start();
|
2005-03-02 05:47:39 +00:00
|
|
|
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
|
2007-05-09 15:03:01 +00:00
|
|
|
if (!empty($THEME->customcorners)) print_custom_corners_end();
|
2005-02-09 15:47:22 +00:00
|
|
|
echo '</td>';
|
|
|
|
}
|
|
|
|
|
2005-02-12 11:37:09 +00:00
|
|
|
echo '<td id="middle-column">';
|
2007-05-09 15:03:01 +00:00
|
|
|
if (!empty($THEME->customcorners)) print_custom_corners_start();
|
2006-08-08 05:13:06 +00:00
|
|
|
|
2006-08-14 05:55:40 +00:00
|
|
|
if ($chat->studentlogs or has_capability('mod/chat:readlog',$context)) {
|
2005-04-13 07:45:47 +00:00
|
|
|
echo '<div class="reportlink">';
|
|
|
|
echo "<a href=\"report.php?id=$cm->id\">".
|
|
|
|
get_string('viewreport', 'chat').'</a>';
|
|
|
|
echo '</div>';
|
2003-07-21 03:16:19 +00:00
|
|
|
}
|
|
|
|
|
2005-03-27 11:36:54 +00:00
|
|
|
print_heading(format_string($chat->name));
|
2004-02-24 06:35:57 +00:00
|
|
|
|
|
|
|
/// Check to see if groups are being used here
|
|
|
|
if ($groupmode = groupmode($course, $cm)) { // Groups are being used
|
|
|
|
$currentgroup = setup_and_print_groups($course, $groupmode, "view.php?id=$cm->id");
|
|
|
|
} else {
|
2005-02-03 20:39:27 +00:00
|
|
|
$currentgroup = 0;
|
2004-02-24 06:35:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($currentgroup) {
|
|
|
|
$groupselect = " AND groupid = '$currentgroup'";
|
2004-09-16 17:13:57 +00:00
|
|
|
$groupparam = "&groupid=$currentgroup";
|
2004-02-24 06:35:57 +00:00
|
|
|
} else {
|
|
|
|
$groupselect = "";
|
|
|
|
$groupparam = "";
|
|
|
|
}
|
|
|
|
|
2003-07-07 06:44:16 +00:00
|
|
|
/// Print the main part of the page
|
|
|
|
|
2006-08-14 05:55:40 +00:00
|
|
|
if (has_capability('mod/chat:chat',$context)) {
|
2005-02-03 20:39:27 +00:00
|
|
|
print_simple_box_start('center');
|
2007-01-04 01:13:26 +00:00
|
|
|
// users with screenreader set, will only see 1 link, to the manual refresh page
|
|
|
|
// for better accessibility
|
2007-01-04 21:39:47 +00:00
|
|
|
if (!empty($USER->screenreader)) {
|
2007-01-04 01:13:26 +00:00
|
|
|
$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";
|
|
|
|
}
|
|
|
|
|
|
|
|
link_to_popup_window ($chattarget,
|
2005-02-09 15:47:22 +00:00
|
|
|
"chat$course->id$chat->id$groupparam", "$strenterchat", 500, 700, get_string('modulename', 'chat'));
|
2003-11-03 10:22:24 +00:00
|
|
|
print_simple_box_end();
|
2007-01-04 01:13:26 +00:00
|
|
|
|
|
|
|
// if user is using screen reader, then there is no need to display this link again
|
2007-01-04 21:39:47 +00:00
|
|
|
if ($CFG->chat_method == 'header_js' && empty($USER->screenreader)) {
|
2006-12-30 19:45:24 +00:00
|
|
|
// show frame/js-less alternative
|
|
|
|
print_simple_box_start('center');
|
|
|
|
link_to_popup_window ("/mod/chat/gui_basic/index.php?id=$chat->id$groupparam",
|
|
|
|
"chat$course->id$chat->id$groupparam", '('.get_string('noframesjs', 'message').')', 500, 700, get_string('modulename', 'chat'));
|
|
|
|
print_simple_box_end();
|
|
|
|
}
|
2004-08-21 21:18:33 +00:00
|
|
|
} else {
|
2006-08-14 05:55:40 +00:00
|
|
|
/* XXX TODO
|
2005-04-25 19:10:14 +00:00
|
|
|
$wwwroot = $CFG->wwwroot.'/login/index.php';
|
|
|
|
if (!empty($CFG->loginhttps)) {
|
2006-05-15 21:36:46 +00:00
|
|
|
$wwwroot = str_replace('http:','https:', $wwwroot);
|
2005-04-25 19:10:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
notice_yesno(get_string('noguests', 'chat').'<br /><br />'.get_string('liketologin'),
|
|
|
|
$wwwroot, $_SERVER['HTTP_REFERER']);
|
|
|
|
|
|
|
|
print_footer($course);
|
|
|
|
exit;
|
2006-08-08 05:13:06 +00:00
|
|
|
*/
|
2003-11-03 10:22:24 +00:00
|
|
|
}
|
2003-07-07 06:44:16 +00:00
|
|
|
|
2003-07-25 06:47:06 +00:00
|
|
|
|
|
|
|
if ($chat->chattime and $chat->schedule) { // A chat is scheduled
|
2007-02-06 08:24:37 +00:00
|
|
|
echo "<p class=\"nextchatsession\">$strnextsession: ".userdate($chat->chattime).' ('.usertimezone($USER->timezone).')</p>';
|
2003-07-25 06:47:06 +00:00
|
|
|
} else {
|
2005-02-03 20:39:27 +00:00
|
|
|
echo '<br />';
|
2003-07-25 06:47:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($chat->intro) {
|
2007-01-11 08:06:15 +00:00
|
|
|
print_box(format_text($chat->intro), 'generalbox', 'intro');
|
2003-07-25 06:47:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
chat_delete_old_users();
|
2003-07-21 05:05:25 +00:00
|
|
|
|
2004-04-08 14:35:36 +00:00
|
|
|
if ($chatusers = chat_get_users($chat->id, $currentgroup)) {
|
2003-07-21 05:03:15 +00:00
|
|
|
$timenow = time();
|
2005-02-03 20:39:27 +00:00
|
|
|
print_simple_box_start('center');
|
2003-07-21 05:03:15 +00:00
|
|
|
print_heading($strcurrentusers);
|
2007-03-02 02:40:30 +00:00
|
|
|
echo '<table id="chatcurrentusers">';
|
2003-07-21 05:03:15 +00:00
|
|
|
foreach ($chatusers as $chatuser) {
|
|
|
|
$lastping = $timenow - $chatuser->lastmessageping;
|
2007-03-02 02:40:30 +00:00
|
|
|
echo '<tr><td class="chatuserimage">';
|
2004-09-16 17:13:57 +00:00
|
|
|
echo "<a href=\"$CFG->wwwroot/user/view.php?id=$chatuser->id&course=$chat->course\">";
|
2003-07-21 05:03:15 +00:00
|
|
|
print_user_picture($chatuser->id, 0, $chatuser->picture, false, false, false);
|
2007-03-02 02:40:30 +00:00
|
|
|
echo '</a></td><td class="chatuserdetails">';
|
|
|
|
echo '<p>';
|
2004-08-20 20:12:48 +00:00
|
|
|
echo fullname($chatuser).'<br />';
|
2007-03-02 02:40:30 +00:00
|
|
|
echo "<span class=\"idletime\">$stridle: ".format_time($lastping)."</span>";
|
|
|
|
echo '</p>';
|
2006-12-22 05:42:36 +00:00
|
|
|
echo '</td></tr>';
|
2003-07-21 05:03:15 +00:00
|
|
|
}
|
2005-02-03 20:39:27 +00:00
|
|
|
echo '</table>';
|
2003-07-21 05:03:15 +00:00
|
|
|
print_simple_box_end();
|
|
|
|
}
|
|
|
|
|
2003-07-07 06:44:16 +00:00
|
|
|
|
|
|
|
/// Finish the page
|
2007-05-09 15:03:01 +00:00
|
|
|
if (!empty($THEME->customcorners)) print_custom_corners_end();
|
2005-02-09 15:47:22 +00:00
|
|
|
echo '</td></tr></table>';
|
|
|
|
|
2003-07-07 06:44:16 +00:00
|
|
|
print_footer($course);
|
|
|
|
|
|
|
|
?>
|