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
|
|
|
|
|
2009-05-06 09:25:54 +00:00
|
|
|
require_once(dirname(__FILE__) . '/../../config.php');
|
|
|
|
require_once($CFG->dirroot . '/mod/chat/lib.php');
|
2008-07-24 03:15:03 +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)) {
|
2008-06-06 08:46:48 +00:00
|
|
|
print_error('invalidcoursemodule');
|
2003-07-07 06:44:16 +00:00
|
|
|
}
|
2005-02-03 20:39:27 +00:00
|
|
|
|
2008-06-06 08:46:48 +00:00
|
|
|
if (! $course = $DB->get_record('course', array('id'=>$cm->course))) {
|
|
|
|
print_error('coursemisconf');
|
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
|
|
|
|
2008-06-06 08:46:48 +00:00
|
|
|
if (! $chat = $DB->get_record('chat', array('id'=>$cm->instance))) {
|
|
|
|
print_error('invalidid', 'chat');
|
2003-07-07 06:44:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2003-07-25 06:47:06 +00:00
|
|
|
chat_update_chat_times($c);
|
|
|
|
|
2008-06-06 08:46:48 +00:00
|
|
|
if (! $chat = $DB->get_record('chat', array('id'=>$c))) {
|
|
|
|
print_error('coursemisconf');
|
2003-07-07 06:44:16 +00:00
|
|
|
}
|
2008-06-08 15:49:36 +00:00
|
|
|
if (! $course = $DB->get_record('course', array('id'=>$chat->course))) {
|
2008-06-06 08:46:48 +00:00
|
|
|
print_error('coursemisconf');
|
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)) {
|
2008-06-06 08:46:48 +00:00
|
|
|
print_error('invalidcoursemodule');
|
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);
|
2008-07-24 03:15:03 +00:00
|
|
|
|
2006-08-09 13:45:49 +00:00
|
|
|
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
2008-07-24 03:15:03 +00:00
|
|
|
|
2007-12-16 13:57:21 +00:00
|
|
|
// show some info for guests
|
|
|
|
if (isguestuser()) {
|
|
|
|
$navigation = build_navigation('', $cm);
|
|
|
|
print_header_simple(format_string($chat->name), '', $navigation,
|
|
|
|
'', '', true, '', navmenu($course, $cm));
|
|
|
|
|
|
|
|
notice_yesno(get_string('noguests', 'chat').'<br /><br />'.get_string('liketologin'),
|
2009-01-02 22:56:48 +00:00
|
|
|
get_login_url(), $CFG->wwwroot.'/course/view.php?id='.$course->id);
|
2007-12-16 13:57:21 +00:00
|
|
|
|
|
|
|
print_footer($course);
|
|
|
|
exit;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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
|
2009-05-06 08:55:53 +00:00
|
|
|
$PAGE->set_url('mod/chat/view.php', array('id' => $cm->id));
|
2005-03-02 05:19:47 +00:00
|
|
|
$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
|
|
|
}
|
|
|
|
|
2009-05-06 09:25:54 +00:00
|
|
|
$title = $course->shortname . ': ' . format_string($chat->name);
|
|
|
|
|
|
|
|
$buttons = '<table><tr><td>'.update_module_button($cm->id, $course->id, get_string('modulename', 'chat')).'</td>';
|
|
|
|
if ($PAGE->user_allowed_editing() && !empty($CFG->showblocksonmodpages)) {
|
|
|
|
$buttons .= '<td><form '.$CFG->frametarget.' method="get" action="view.php"><div>'.
|
|
|
|
'<input type="hidden" name="id" value="'.$cm->id.'" />'.
|
|
|
|
'<input type="hidden" name="edit" value="'.($PAGE->user_is_editing()?'off':'on').'" />'.
|
|
|
|
'<input type="submit" value="'.get_string($PAGE->user_is_editing()?'blockseditoff':'blocksediton').'" /></div></form></td>';
|
|
|
|
}
|
|
|
|
$buttons .= '</tr></table>';
|
|
|
|
|
|
|
|
$navigation = build_navigation(array(), $cm);
|
|
|
|
print_header($title, $course->fullname, $navigation, '', '', true, $buttons, navmenu($course, $cm));
|
2005-02-09 15:47:22 +00:00
|
|
|
|
2005-02-12 11:37:09 +00:00
|
|
|
echo '<table id="layout-table"><tr>';
|
2005-02-09 15:47:22 +00:00
|
|
|
|
2007-10-10 14:57:39 +00:00
|
|
|
$lt = (empty($THEME->layouttable)) ? array('left', 'middle', 'right') : $THEME->layouttable;
|
|
|
|
foreach ($lt as $column) {
|
|
|
|
switch ($column) {
|
|
|
|
case 'left':
|
|
|
|
|
|
|
|
if(!empty($CFG->showblocksonmodpages) && (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $PAGE->user_is_editing())) {
|
|
|
|
echo '<td style="width: '.$blocks_preferred_width.'px;" id="left-column">';
|
2007-11-23 16:49:51 +00:00
|
|
|
print_container_start();
|
2007-10-10 14:57:39 +00:00
|
|
|
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
|
2007-11-23 16:49:51 +00:00
|
|
|
print_container_end();
|
2007-10-10 14:57:39 +00:00
|
|
|
echo '</td>';
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'middle':
|
|
|
|
|
|
|
|
echo '<td id="middle-column">';
|
2007-11-23 16:49:51 +00:00
|
|
|
print_container_start();
|
2007-10-10 14:57:39 +00:00
|
|
|
|
|
|
|
/// Check to see if groups are being used here
|
|
|
|
$groupmode = groups_get_activity_groupmode($cm);
|
|
|
|
$currentgroup = groups_get_activity_group($cm, true);
|
|
|
|
groups_print_activity_menu($cm, "view.php?id=$cm->id");
|
|
|
|
|
|
|
|
if ($currentgroup) {
|
2008-10-15 09:03:30 +00:00
|
|
|
$groupselect = " AND groupid = '$currentgroup'";
|
2007-10-10 14:57:39 +00:00
|
|
|
$groupparam = "&groupid=$currentgroup";
|
|
|
|
} else {
|
2008-10-15 09:03:30 +00:00
|
|
|
$groupselect = "";
|
2007-10-10 14:57:39 +00:00
|
|
|
$groupparam = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($chat->studentlogs or has_capability('mod/chat:readlog',$context)) {
|
2008-10-15 09:03:30 +00:00
|
|
|
if ($msg = $DB->get_records_select('chat_messages', "chatid = ? $groupselect", array($chat->id))) {
|
2008-10-08 07:55:42 +00:00
|
|
|
echo '<div class="reportlink">';
|
|
|
|
echo "<a href=\"report.php?id=$cm->id\">".
|
|
|
|
get_string('viewreport', 'chat').'</a>';
|
|
|
|
echo '</div>';
|
|
|
|
}
|
2007-10-10 14:57:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
print_heading(format_string($chat->name));
|
|
|
|
|
2009-03-11 02:34:20 +00:00
|
|
|
if (has_capability('mod/chat:chat',$context)) {
|
|
|
|
/// Print the main part of the page
|
|
|
|
print_box_start('generalbox', 'enterlink');
|
|
|
|
// users with screenreader set, will only see 1 link, to the manual refresh page
|
|
|
|
// for better accessibility
|
|
|
|
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";
|
|
|
|
}
|
2008-11-19 06:32:49 +00:00
|
|
|
|
2008-11-18 05:21:57 +00:00
|
|
|
echo '<p>';
|
2009-03-11 02:34:20 +00:00
|
|
|
link_to_popup_window ($chattarget,
|
|
|
|
"chat$course->id$chat->id$groupparam", "$strenterchat", 500, 700, get_string('modulename', 'chat'));
|
2008-11-18 05:21:57 +00:00
|
|
|
echo '</p>';
|
2008-11-19 06:29:27 +00:00
|
|
|
|
2009-03-11 02:34:20 +00:00
|
|
|
if ($CFG->enableajax) {
|
|
|
|
echo '<p>';
|
|
|
|
link_to_popup_window ("/mod/chat/gui_ajax/index.php?id=$chat->id$groupparam",
|
|
|
|
"chat$course->id$chat->id$groupparam", get_string('ajax_gui', 'message'), 500, 700, get_string('modulename', 'chat'));
|
|
|
|
echo '</p>';
|
|
|
|
}
|
2008-11-18 05:21:57 +00:00
|
|
|
|
2009-03-11 02:34:20 +00:00
|
|
|
// 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 '<p>(';
|
|
|
|
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'));
|
|
|
|
echo ')</p>';
|
|
|
|
}
|
2007-12-16 13:57:21 +00:00
|
|
|
|
2009-03-11 02:34:20 +00:00
|
|
|
print_box_end();
|
2007-12-16 13:57:21 +00:00
|
|
|
|
2009-03-11 02:34:20 +00:00
|
|
|
} else {
|
|
|
|
print_box_start('generalbox', 'notallowenter');
|
|
|
|
echo '<p>'.get_string('notallowenter', 'chat').'</p>';
|
|
|
|
print_box_end();
|
|
|
|
}
|
2007-10-10 14:57:39 +00:00
|
|
|
|
|
|
|
if ($chat->chattime and $chat->schedule) { // A chat is scheduled
|
|
|
|
echo "<p class=\"nextchatsession\">$strnextsession: ".userdate($chat->chattime).' ('.usertimezone($USER->timezone).')</p>';
|
|
|
|
} else {
|
|
|
|
echo '<br />';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($chat->intro) {
|
2009-04-21 21:33:08 +00:00
|
|
|
print_box(format_module_intro('chat', $chat, $cm->id), 'generalbox', 'intro');
|
2007-10-10 14:57:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
chat_delete_old_users();
|
|
|
|
|
|
|
|
if ($chatusers = chat_get_users($chat->id, $currentgroup, $cm->groupingid)) {
|
|
|
|
$timenow = time();
|
|
|
|
print_simple_box_start('center');
|
|
|
|
print_heading($strcurrentusers);
|
|
|
|
echo '<table id="chatcurrentusers">';
|
|
|
|
foreach ($chatusers as $chatuser) {
|
|
|
|
$lastping = $timenow - $chatuser->lastmessageping;
|
|
|
|
echo '<tr><td class="chatuserimage">';
|
|
|
|
echo "<a href=\"$CFG->wwwroot/user/view.php?id=$chatuser->id&course=$chat->course\">";
|
2008-02-13 17:03:25 +00:00
|
|
|
print_user_picture($chatuser, 0, $chatuser->picture, false, false, false);
|
2007-10-10 14:57:39 +00:00
|
|
|
echo '</a></td><td class="chatuserdetails">';
|
|
|
|
echo '<p>';
|
|
|
|
echo fullname($chatuser).'<br />';
|
|
|
|
echo "<span class=\"idletime\">$stridle: ".format_time($lastping)."</span>";
|
|
|
|
echo '</p>';
|
|
|
|
echo '</td></tr>';
|
|
|
|
}
|
|
|
|
echo '</table>';
|
|
|
|
print_simple_box_end();
|
|
|
|
}
|
|
|
|
|
2007-11-23 16:49:51 +00:00
|
|
|
print_container_end();
|
2007-10-10 14:57:39 +00:00
|
|
|
echo '</td>';
|
|
|
|
|
|
|
|
break;
|
2005-04-25 19:10:14 +00:00
|
|
|
}
|
2003-07-25 06:47:06 +00:00
|
|
|
}
|
2008-07-24 03:15:03 +00:00
|
|
|
|
2007-10-10 14:57:39 +00:00
|
|
|
echo '</tr></table>';
|
2005-02-09 15:47:22 +00:00
|
|
|
|
2003-07-07 06:44:16 +00:00
|
|
|
print_footer($course);
|
|
|
|
|
|
|
|
?>
|