remove old readme
[atutor.git] / mods / _standard / chat / index.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 // $Id$
14
15 define('AT_INCLUDE_PATH', '../../../include/');
16
17 $CACHE_DEBUG=0;
18 require(AT_INCLUDE_PATH.'vitals.inc.php');
19
20 require(AT_INCLUDE_PATH.'../mods/_standard/chat/lib/chat.inc.php');
21 $admin = getAdminSettings();
22
23 require(AT_INCLUDE_PATH.'header.inc.php');
24
25 ?>
26 <p align="center"><a href="mods/_standard/chat/chat.php?firstLoginFlag=1"><strong> <?php echo _AT('enter_chat');  ?></strong></a></p><br />
27 <?php
28
29 $orders = array('asc' => 'desc', 'desc' => 'asc');
30 $cols   = array('name' => 1, 'date' => 1);
31
32 if (isset($_GET['asc'])) {
33         $order = 'asc';
34         $col   = isset($cols[$_GET['asc']]) ? $_GET['asc'] : 'date';
35 } else if (isset($_GET['desc'])) {
36         $order = 'desc';
37         $col   = isset($cols[$_GET['desc']]) ? $_GET['desc'] : 'date';
38 } else {
39         // no order set
40         $order = 'desc';
41         $col   = 'date';
42 }
43
44 $tran_files = array();
45 if (!@opendir(AT_CONTENT_DIR . 'chat/')){
46         mkdir(AT_CONTENT_DIR . 'chat/', 0777);
47 }
48
49 if(!file_exists(AT_CONTENT_DIR . 'chat/'.$_SESSION['course_id'].'/admin.settings')){
50         @mkdir(AT_CONTENT_DIR . 'chat/'.$_SESSION['course_id'], 0777);
51         @mkdir(AT_CONTENT_DIR . 'chat/'.$_SESSION['course_id'].'/tran/', 0776);
52         @mkdir(AT_CONTENT_DIR . 'chat/'.$_SESSION['course_id'].'/msgs/', 0776);
53         @mkdir(AT_CONTENT_DIR . 'chat/'.$_SESSION['course_id'].'/users/', 0776);
54         @copy('admin.settings.default', AT_CONTENT_DIR . 'chat/'.$_SESSION['course_id'].'/admin.settings');
55         @chmod (AT_CONTENT_DIR . 'chat/'.$_SESSION['course_id'].'/admin.settings', 0777);
56
57 }
58         
59 if ($dir = @opendir(AT_CONTENT_DIR . 'chat/'.$_SESSION['course_id'].'/tran/')) {
60         while (($file = readdir($dir)) !== false) {
61                 if (substr($file, -strlen('.html')) == '.html') {
62                         $la     = stat(AT_CONTENT_DIR . 'chat/'.$_SESSION['course_id'].'/tran/'.$file);
63
64                         $file = str_replace('.html', '', $file);
65                         $tran_files[$file] = $la['ctime'];
66                 }
67         }
68 }
69
70 if (count($tran_files) == 0) {
71         echo '<p>'._AT('chat_none_found').'</p>';
72 } else {?>
73         
74 <form name="form" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
75
76         <table class="data" rules="cols" summary="">
77         <colgroup>
78                 <?php if ($col == 'name'): ?>
79                         <col class="sort" />
80                         <col span="2" />
81                 <?php elseif($col == 'date'): ?>
82                         <col span="2" />
83                         <col class="sort" />
84                 <?php endif; ?>
85         </colgroup>
86         <thead>
87         <tr>
88                 <th scope="col"><a href="<?php echo url_rewrite('chat/index.php?'.$orders[$order].'=name'); ?>"><?php echo _AT('chat_transcript');?></a></th>
89                 <th scope="col"><?php echo _AT('status'); ?></th>
90                 <th scope="col"><a href="<?php echo url_rewrite('chat/index.php?'.$orders[$order].'=date'); ?>"><?php echo _AT('date'); ?></a></th> 
91         </tr>
92         </thead>
93         <?php
94
95         if (($col == 'date') && ($order == 'asc')) {
96                 asort($tran_files);
97         } else if (($col == 'date') && ($order == 'desc')) {
98                 arsort($tran_files);
99         } else if (($col == 'name') && ($order == 'asc')) {
100                 ksort($tran_files);
101         } else if (($col == 'name') && ($order == 'desc')) {
102                 krsort($tran_files);
103         }
104         reset ($tran_files);
105         ?>
106
107         <tbody>
108         <?php foreach ($tran_files as $file => $date) { ?>
109                 <tr onmousedown="document.location='<?php echo AT_BASE_HREF; ?>mods/_standard/chat/view_transcript.php?t=<?php echo $file; ?>'">
110                         <td><a href="<?php echo url_rewrite('mods/_standard/chat/view_transcript.php?t='.$file); ?>"><?php echo $file; ?></a></td>
111                         <td>
112                                 <?php if (($file.'.html' == $admin['tranFile']) && ($admin['produceTran'])) { 
113                                         echo _AT('chat_currently_active');
114                                 } else {
115                                         echo _AT('chat_inactive');
116                                 }?>
117                         </td>
118         
119                         <td><?php 
120                                                 //echo $date;
121                         $startend_date_longs_format=_AT('startend_date_longs_format');
122                         echo AT_date($startend_date_longs_format, $date, AT_DATE_UNIX_TIMESTAMP);
123                         ?></td>
124                 </tr>
125         <?php } ?>
126         </tbody>
127
128         </table>
129 </form>
130 <?php
131 }
132
133 require(AT_INCLUDE_PATH.'footer.inc.php');
134 ?>