remove old readme
[atutor.git] / mods / _standard / chat / history.php
1 <?php
2 /****************************************************************/
3 /* ATutor                                                                                                               */
4 /****************************************************************/
5 /* Copyright (c) 2002-2010                                      */
6 /* Inclusive Design Institute                                   */
7 /* http://atutor.ca                                                                                             */
8 /*                                                              */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License  */
11 /* as published by the Free Software Foundation.                                */
12 /****************************************************************/
13
14 define('AT_INCLUDE_PATH', '../../../include/');
15         require(AT_INCLUDE_PATH.'vitals.inc.php');
16         //authenticate(USER_CLIENT, USER_ADMIN);
17 require(AT_INCLUDE_PATH.'../mods/_standard/chat/lib/chat.inc.php');
18
19         $myPrefs = getPrefs($_SESSION['username']);
20         writePrefs($myPrefs, $_SESSION['username']);
21
22         cleanUp();
23         $topMsgNum = $bottomMsgNum = 0;
24     howManyMessages($topMsgNum, $bottomMsgNum);
25
26         $hisTopNum = $_GET['hisTopNum'];
27
28         if ($hisTopNum > $topMsgNum) {
29                 $hisTopNum = $topMsgNum;
30         }
31     if (!$hisTopNum) {
32                 $hisTopNum = $topMsgNum;
33         }
34
35     $hisBottomNum = getLower20Bound($hisTopNum, $bottomMsgNum);
36
37     if ($hisBottomNum == 0) {
38                 $hisBottomNum = 1;
39         }
40     $totalNum = $topMsgNum - $bottomMsgNum + 1;
41
42     $hisTopNumUserPerspective = $hisTopNum - $bottomMsgNum + 1;
43     $hisBottomNumUserPerspective = $hisBottomNum - $bottomMsgNum + 1;
44
45     if ($hisBottomNumUserPerspective < 1) {
46                 $hisBottomNumUserPerspective = 1;
47         }
48
49         $prevNumT = $hisBottomNum - 1;
50     $nextNumT = $hisTopNum + 20;
51
52 require('include/html/chat_header.inc.php');
53
54
55         if ($hisTopNum < $topMsgNum && $hisBottomNum > $bottomMsgNum) {
56 ?>
57                 <table width="100%" border="0" cellpadding="5" cellspacing="0">
58                 <tr>
59                         <td align="right"><a href="history.php?hisTopNum=<?php echo $prevNumT; ?>" target="_top" onFocus="this.className='highlight'" onBlur="this.className=''"><?php echo _AT('previous'); ?></a> | <a href="history.php?hisTopNum=<?php echo $nextNumT; ?>" target="_top" onFocus="this.className='highlight'" onBlur="this.className=''"><?php echo _AT('next'); ?></a> | <a href="chat.php" target="_top" onFocus="this.className='highlight'" onBlur="this.className=''"><?php echo _AT('chat_return'); ?></a></td>
60                 </tr>
61                 </table>
62 <?php
63     } else if ($hisBottomNum > $bottomMsgNum) {
64 ?>
65                 <table width="100%" border="0" cellpadding="5" cellspacing="0">
66                 <tr>
67                         <td align="right"><a href="history.php?hisTopNum=<?php echo $prevNumT; ?>" target="_top" onFocus="this.className='highlight'" onBlur="this.className=''"><?php echo _AT('previous'); ?></a> | <a href="chat.php" target="_top" onFocus="this.className='highlight'" onBlur="this.className=''"><?php echo _AT('chat_return'); ?></a></td>
68                 </tr>
69                 </table>
70 <?php
71         } else {
72 ?>
73                 <table width="100%" border="0" cellpadding="5" cellspacing="0">
74                 <tr>
75                         <td align="right"><a href="history.php?hisTopNum=<?php echo $nextNumT; ?>" target="_top" onFocus="this.className='highlight'" onBlur="this.className=''"><?php echo _AT('next'); ?></a> | <a href="chat.php" target="_top" onFocus="this.className='highlight'" onBlur="this.className=''"><?php echo _AT('chat_return'); ?></a></td>
76                 </tr>
77                 </table>
78 <?php
79         }
80 ?>
81 <table width="100%" border="0" cellpadding="5" cellspacing="0">
82 <tr>
83         <th align="left" class="box"><?php echo _AT('chat_history_messages', $hisBottomNumUserPerspective, $hisTopNumUserPerspective, $totalNum); ?></th>
84 </tr>
85 </table>
86 <?php
87     echo '<p><table border="0" cellpadding="2" cellspacing="0" width="90%" class="box2">';
88
89     if ($myPrefs['newestFirstFlag'] > 0) {
90         for ($i = $hisTopNum; $i >= $hisBottomNum; $i--) {
91             showMessage($i, $myPrefs);
92         }
93     } else {
94         for ($i = $hisBottomNum; $i <= $hisTopNum ; $i++) {
95             showMessage($i, $myPrefs);
96         }
97     }
98     echo '</table></p>';
99
100         if ($hisTopNum < $topMsgNum && $hisBottomNum > $bottomMsgNum) {
101 ?>
102                 <table width="100%" border="0" cellpadding="5" cellspacing="0">
103                 <tr>
104                         <td align="right"><a href="history.php?hisTopNum=<?php echo $prevNumT; ?>" target="_top" onFocus="this.className='highlight'" onBlur="this.className=''">Previous</a> | <a href="history.php?hisTopNum=<?php echo $nextNumT; ?>" target="_top" onFocus="this.className='highlight'" onBlur="this.className=''">Next</a> | <a href="chat.php" target="_top" onFocus="this.className='highlight'" onBlur="this.className=''">Return to Chat</a></td>
105                 </tr>
106                 </table>
107 <?php
108
109         } else if ($hisBottomNum > $bottomMsgNum) {
110 ?>
111                 <table width="100%" border="0" cellpadding="5" cellspacing="0">
112                 <tr>
113                         <td align="right"><a href="history.php?hisTopNum=<?php echo $prevNumT; ?>" target="_top" onFocus="this.className='highlight'" onBlur="this.className=''">Previous</a> | <a href="chat.php" target="_top" onFocus="this.className='highlight'" onBlur="this.className=''">Return to Chat</a></td>
114                 </tr>
115                 </table>
116 <?php
117     } else {
118 ?>
119                 <table width="100%" border="0" cellpadding="5" cellspacing="0">
120                 <tr>
121                         <td align="right"><a href="history.php?hisTopNum=<?php echo $nextNumT; ?>" target="_top" onFocus="this.className='highlight'" onBlur="this.className=''">Next</a> | <a href="chat.php" target="_top" onFocus="this.className='highlight'" onBlur="this.className=''">Return to Chat</a></td>
122                 </tr>
123                 </table>
124 <?php
125     }
126
127         require('include/html/chat_footer.inc.php');
128 ?>