<?php
/****************************************************************************************/
/* ACollab */
/****************************************************************************************/
/* Copyright (c) 2002-2004 Adaptive Technology Resource Centre / University of Toronto */
/* */
/* http://atutor.ca/acollab */
/* */
/* This program is free software. You may redistribute it and/or */
/* modify it under the terms of the GNU General Public License */
/* as published by the Free Software Foundation; either version 2 of the License, */
/* or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but */
/* WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */
/* See the GNU General Public License for more details. */
/* */
/* You may access the GNU General Public License at: */
/* http://www.opensource.org/licenses/gpl-license.php */
/* */
/* You may contact the Adaptive Technology Resource Centre at */
/* Robarts Library, University of Toronto */
/* 130 St. George Street, Toronto, Ontario, Canada M5S 1A5 */
/* Further contact information is available at http://www.utoronto.ca/atrc/ */
/****************************************************************************************/
/* Programmer: */
/* Joel Kronenberg - ATRC */
/****************************************************************************************/
// $Id: display.php 230 2004-06-07 18:52:57Z boonhau $
define('AC_INCLUDE_PATH', '../include/');
require(AC_INCLUDE_PATH.'vitals.inc.php');
session_write_close();
authenticate(USER_CLIENT, USER_GROUP_ADMIN, USER_ADMIN);
require('include/functions.inc.php');
$myPrefs = getPrefs($_SESSION['login']);
cleanUp();
howManyMessages($topMsgNum, $bottomMsgNum);
if ($_REQUEST['set']) {
if (isset($_GET['set'])) {
if ($_GET['set'] == $_POST['message']) {
$message = $_POST['tempField'];
} else {
$message = $_POST['message'];
}
} else {
$message = $_POST['message'];
}
//$message = $_POST['message'];
postMessage($_SESSION['login'], $message, $topMsgNum, $bottomMsgNum);
} else if ($_REQUEST['firstLoginFlag'] > 0) {
postMessage(_AC('chat_system'), _AC('chat_user_logged_in', $_SESSION['login']), $topMsgNum, $bottomMsgNum);
}
require(AC_INCLUDE_PATH.'pub/header.inc.php');
if ($myPrefs['refresh'] != 'manual') {
?>
<script type="text/javascript">
<!--
setTimeout("reDisplay()", <?php echo $myPrefs['refresh'] * 1000; ?>);
function reDisplay() {
window.location.href = "<?php echo $_SERVER[PHP_SELF]; ?>";
}
//-->
</script>
<?php
} /* end if */
?>
<a name="messages"></a>
<table width="100%" border="0" cellpadding="5" cellspacing="0">
<tr>
<th align="left" class="box"><?php echo _AC('chat_messages') ?></th>
</tr>
</table>
<?php
$min = 1;
if ($topMsgNum - 10 > 1) {
$min = $topMsgNum - 10;
}
if ($myPrefs['onlyNewFlag'] > 0) {
$min = $myPrefs['lastRead'] +1;
}
if ($min <= $topMsgNum) {
echo '<table border="0" cellpadding="2" cellspacing="0" width="90%" class="box2">';
} else {
echo '<p>'._AC('chat_no_new_messages').'</p>';
}
if ($myPrefs['newestFirstFlag'] > 0) {
for ($i = $topMsgNum; $i >= $min; $i--) {
showMessage($i, $myPrefs);
}
} else {
for ($i = $min; $i <= $topMsgNum ; $i++) {
showMessage($i, $myPrefs);
}
}
if ($min <= $topMsgNum) {
echo '</table> ';
}
echo '<table width="100%" border="0" cellpadding="5" cellspacing="0">';
echo '<tr>';
echo '<td align="right">';
if ($myPrefs['navigationAidFlag'] > 0) {
echo '<label accesskey="m" for="messageQ"><a href="chat/display.php#messages" id="messageQ" onfocus="this.className=\'highlight\'" onblur="this.className=\'\'" title="'._AC('chat_jump_to_message').' Alt-m">'._AC('chat_jump_to_message').'</a></label> | ';
}
echo '<label accesskey="r" for="refreshQ"><a id="refreshQ" href="chat/display.php" target="display" onfocus="this.className=\'highlight\'" onblur="this.className=\'\'" title="'._AC('chat_refresh_message').' Alt-r">'._AC('chat_refresh_message').'</a></label></td>';
echo '</tr>';
echo '</table>';
echo '<br /><br />';
if ($myPrefs['refresh'] == 'manual') {
echo '<table width="100%" border="0" cellpadding="5" cellspacing="0">
<tr><th align="left" class="box">'._AC('chat_compose_message').'</th></tr></table>';
echo '<p class="light">';
echo '<form action="chat/display.php" target="display" name="f1" method="post" onsubmit="return checkForm();">
<input type="hidden" name="set" value="1" />
<label accesskey="c" for="message"><input type="text" maxlength="200" size="50" id="message" name="message" value="" class="input" title="Alt-c" onfocus="this.className=\'input highlight\'" onblur="this.className=\'input\'" /></label>
<input type="submit" name="submit" value="'._AC('chat_send').'" class="submit" title="'._AC('chat_send').'" onfocus="this.className=\'submit highlight\'" onblur="this.className=\'submit\'" />';
echo '</form></p>';
echo '<script type="text/javascript"><!--
function checkForm() {
if (document.f1.message.value == "" || !document.f1.message.value) return false;
return true;
}';
echo '//--></script>';
} else {
if ($myPrefs['bingFlag'] > 0 && $topMsgNum > $myPrefs['lastRead']) {
echo '<embed src="chat/bings/chime.wav" loop="false" autoplay="true" play="true" hidden="true" width="1" height="1" />';
}
}
$myPrefs['lastRead'] = $topMsgNum;
$myPrefs['lastChecked'] = $topMsgNum;
writePrefs($myPrefs, $_SESSION['login']);
require(AC_INCLUDE_PATH.'pub/footer.inc.php');
?>