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');
|
2003-07-07 06:44:16 +00:00
|
|
|
|
2005-02-09 15:47:22 +00:00
|
|
|
$id = optional_param('id', 0, PARAM_INT);
|
|
|
|
$c = optional_param('c', 0, PARAM_INT);
|
|
|
|
$edit = optional_param('edit', '');
|
2003-07-07 06:44:16 +00:00
|
|
|
|
|
|
|
if ($id) {
|
2005-02-03 20:39:27 +00:00
|
|
|
if (! $cm = get_record('course_modules', 'id', $id)) {
|
|
|
|
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-16 10:40:48 +00:00
|
|
|
require_course_login($course, true, $cm);
|
2005-02-03 20:39:27 +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
|
|
|
|
2005-02-09 15:47:22 +00:00
|
|
|
if (!empty($edit) && $PAGE->user_allowed_editing()) {
|
|
|
|
if ($edit == 'on') {
|
|
|
|
$USER->editing = true;
|
|
|
|
} else if ($edit == 'off') {
|
|
|
|
$USER->editing = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$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">';
|
2005-03-02 05:47:39 +00:00
|
|
|
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
|
2005-02-09 15:47:22 +00:00
|
|
|
echo '</td>';
|
|
|
|
}
|
|
|
|
|
2005-02-12 11:37:09 +00:00
|
|
|
echo '<td id="middle-column">';
|
2003-07-07 06:44:16 +00:00
|
|
|
|
2003-11-03 10:22:24 +00:00
|
|
|
if (($chat->studentlogs or isteacher($course->id)) and !isguest()) {
|
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
|
|
|
|
|
2003-11-03 10:22:24 +00:00
|
|
|
if (!isguest()) {
|
2005-02-03 20:39:27 +00:00
|
|
|
print_simple_box_start('center');
|
|
|
|
link_to_popup_window ("/mod/chat/gui_$CFG->chat_method/index.php?id=$chat->id$groupparam",
|
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();
|
2004-08-21 21:18:33 +00:00
|
|
|
} else {
|
2005-04-25 19:10:14 +00:00
|
|
|
|
|
|
|
$wwwroot = $CFG->wwwroot.'/login/index.php';
|
|
|
|
if (!empty($CFG->loginhttps)) {
|
|
|
|
$wwwroot = str_replace('http','https', $wwwroot);
|
|
|
|
}
|
|
|
|
|
|
|
|
notice_yesno(get_string('noguests', 'chat').'<br /><br />'.get_string('liketologin'),
|
|
|
|
$wwwroot, $_SERVER['HTTP_REFERER']);
|
|
|
|
|
|
|
|
print_footer($course);
|
|
|
|
exit;
|
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
|
2005-04-27 03:44:52 +00:00
|
|
|
echo "<p align=\"center\">$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) {
|
2005-03-13 16:17:55 +00:00
|
|
|
print_simple_box(format_text($chat->intro), 'center', '70%', '', 5, 'generalbox', 'intro');
|
2005-02-03 20:39:27 +00:00
|
|
|
echo '<br />';
|
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);
|
2005-02-03 20:39:27 +00:00
|
|
|
echo '<table width="100%">';
|
2003-07-21 05:03:15 +00:00
|
|
|
foreach ($chatusers as $chatuser) {
|
|
|
|
$lastping = $timenow - $chatuser->lastmessageping;
|
2005-02-03 20:39:27 +00:00
|
|
|
echo '<tr><td width="35">';
|
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);
|
2005-02-03 20:39:27 +00:00
|
|
|
echo '</a></td><td valign="center">';
|
|
|
|
echo '<p><font size="1">';
|
2004-08-20 20:12:48 +00:00
|
|
|
echo fullname($chatuser).'<br />';
|
2004-08-21 20:25:15 +00:00
|
|
|
echo "<font color=\"#888888\">$stridle: ".format_time($lastping)."</font>";
|
2005-02-03 20:39:27 +00:00
|
|
|
echo '</font></p>';
|
|
|
|
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
|
2005-02-09 15:47:22 +00:00
|
|
|
echo '</td></tr></table>';
|
|
|
|
|
2003-07-07 06:44:16 +00:00
|
|
|
print_footer($course);
|
|
|
|
|
|
|
|
?>
|