Location: PHPKode > projects > ACollab > chat/history.php
<?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: history.php 441 2005-03-07 21:07:59Z shozubq $

define('AC_INCLUDE_PATH', '../include/');

	require(AC_INCLUDE_PATH.'vitals.inc.php');
	authenticate(USER_CLIENT, USER_GROUP_ADMIN, USER_ADMIN);
	require('include/functions.inc.php');

	$myPrefs = getPrefs($_SESSION['username']);
	writePrefs($myPrefs, $_SESSION['username']);
/*updated*/
	cleanUp();
	$topMsgNum = $bottomMsgNum = 0;
    howManyMessages($topMsgNum, $bottomMsgNum);

	$hisTopNum = $_GET['hisTopNum'];

	if ($hisTopNum > $topMsgNum) {
		$hisTopNum = $topMsgNum;
	}
    if (!$hisTopNum) {
		$hisTopNum = $topMsgNum;
	}

    $hisBottomNum = getLower20Bound($hisTopNum, $bottomMsgNum);

    if ($hisBottomNum == 0) {
		$hisBottomNum = 1;
	}
    $totalNum = $topMsgNum - $bottomMsgNum + 1;

    $hisTopNumUserPerspective = $hisTopNum - $bottomMsgNum + 1;
    $hisBottomNumUserPerspective = $hisBottomNum - $bottomMsgNum + 1;

    if ($hisBottomNumUserPerspective < 1) {
		$hisBottomNumUserPerspective = 1;
	}

	$prevNumT = $hisBottomNum - 1;
    $nextNumT = $hisTopNum + 20;

require(AC_INCLUDE_PATH.'pub/header.inc.php');


	if ($hisTopNum < $topMsgNum && $hisBottomNum > $bottomMsgNum) {
?>
		<table width="100%" border="0" cellpadding="5" cellspacing="0">
		<tr>
			<td align="right"><a href="chat/history.php?hisTopNum=<?php echo $prevNumT; ?>" target="_top" onfocus="this.className='highlight'" onblur="this.className=''"><?php echo _AC('chat_previous'); ?></a> | <a href="chat/history.php?hisTopNum=<?php echo $nextNumT; ?>" target="_top" onfocus="this.className='highlight'" onblur="this.className=''"><?php echo _AC('chat_next'); ?></a> | <a href="chat/chat.php" target="_top" onfocus="this.className='highlight'" onblur="this.className=''"><?php echo _AC('chat_return'); ?></a></td>
		</tr>
		</table>
<?php
    } else if ($hisBottomNum > $bottomMsgNum) {
?>
		<table width="100%" border="0" cellpadding="5" cellspacing="0">
		<tr>
			<td align="right"><a href="chat/history.php?hisTopNum=<?php echo $prevNumT; ?>" target="_top" onfocus="this.className='highlight'" onblur="this.className=''"><?php echo _AC('chat_previous'); ?></a> | <a href="chat/chat.php" target="_top" onfocus="this.className='highlight'" onblur="this.className=''"><?php echo _AC('chat_return'); ?></a></td>
		</tr>
		</table>
<?php
	} else {
?>
		<table width="100%" border="0" cellpadding="5" cellspacing="0">
		<tr>
			<td align="right"><a href="chat/history.php?hisTopNum=<?php echo $nextNumT; ?>" target="_top" onfocus="this.className='highlight'" onblur="this.className=''"><?php echo _AC('chat_next'); ?></a> | <a href="chat/chat.php" target="_top" onfocus="this.className='highlight'" onblur="this.className=''"><?php echo _AC('chat_return'); ?></a></td>
		</tr>
		</table>
<?php
	}
?>
<table width="100%" border="0" cellpadding="5" cellspacing="0">
<tr>
	<th align="left" class="box"><?php echo _AC('chat_history_messages', $hisBottomNumUserPerspective, $hisTopNumUserPerspective, $totalNum); ?></th>
	<!-- History - Messages <?php echo $hisBottomNumUserPerspective.' to '.$hisTopNumUserPerspective.' of '.$totalNum; ?> -->
</tr>
</table>
<?php
    echo '<table border="0" cellpadding="2" cellspacing="0" width="90%" class="box2">';

    if ($myPrefs['newestFirstFlag'] > 0) {
        for ($i = $hisTopNum; $i >= $hisBottomNum; $i--) {
            showMessage($i, $myPrefs);
        }
    } else {
        for ($i = $hisBottomNum; $i <= $hisTopNum ; $i++) {
            showMessage($i, $myPrefs);
        }
    }
    echo '</table>';

	if ($hisTopNum < $topMsgNum && $hisBottomNum > $bottomMsgNum) {
?>
		<table width="100%" border="0" cellpadding="5" cellspacing="0">
		<tr>
			<td align="right"><a href="chat/history.php?hisTopNum=<?php echo $prevNumT; ?>" target="_top" onfocus="this.className='highlight'" onblur="this.className=''"><?php echo _AC('chat_previous'); ?></a> | <a href="chat/history.php?hisTopNum=<?php echo $nextNumT; ?>" target="_top" onfocus="this.className='highlight'" onblur="this.className=''"><?php echo _AC('chat_next'); ?></a> | <a href="chat/chat.php" target="_top" onfocus="this.className='highlight'" onblur="this.className=''"><?php echo _AC('chat_return'); ?></a></td>
		</tr>
		</table>
<?php

	} else if ($hisBottomNum > $bottomMsgNum) {
?>
		<table width="100%" border="0" cellpadding="5" cellspacing="0">
		<tr>
			<td align="right"><a href="chat/history.php?hisTopNum=<?php echo $prevNumT; ?>" target="_top" onfocus="this.className='highlight'" onblur="this.className=''"><?php echo _AC('chat_previous'); ?></a> | <a href="chat/chat.php" target="_top" onfocus="this.className='highlight'" onblur="this.className=''"><?php echo _AC('chat_return'); ?></a></td>
		</tr>
		</table>
<?php
    } else {
?>
		<table width="100%" border="0" cellpadding="5" cellspacing="0">
		<tr>
			<td align="right"><a href="chat/history.php?hisTopNum=<?php echo $nextNumT; ?>" target="_top" onfocus="this.className='highlight'" onblur="this.className=''"><?php echo _AC('chat_next'); ?></a> | <a href="chat/chat.php" target="_top" onfocus="this.className='highlight'" onblur="this.className=''"><?php echo _AC('chat_return'); ?></a></td>
		</tr>
		</table>
<?php
    }

	require(AC_INCLUDE_PATH.'pub/footer.inc.php');
?>
Return current item: ACollab