move code up one directory
[atutor.git] / mods / _standard / chat / sublinks.php
1 <?php
2 /************************************************************************/
3 /* ATutor                                                                                                                               */
4 /************************************************************************/
5 /* Copyright (c) 2002-2010                                              */
6 /* Inclusive Design Institute                                           */
7 /* http://atutor.ca                                                     */
8 /* This program is free software. You can redistribute it and/or        */
9 /* modify it under the terms of the GNU General Public License          */
10 /* as published by the Free Software Foundation.                        */
11 /************************************************************************/
12
13 if (!defined('AT_INCLUDE_PATH')) { exit; }
14
15 $record_limit = 3;      // Number of sublinks to display for this module on course home page -> detail view
16 $cnt = 0;           // count number of sublinks pushed into $list
17
18 if ($dir = @opendir(AT_CONTENT_DIR . 'chat/'.$_SESSION['course_id'].'/tran/')) {
19         while (($file = readdir($dir)) !== false) {
20                 if ($cnt >= $record_limit) break;       // quit the loop when reaching the record limit
21                 
22                 if (substr($file, -strlen('.html')) == '.html') {
23                         $file = str_replace('.html', '', $file);
24
25                         $list[] = '<a href="'.url_rewrite('mods/_standard/chat/view_transcript.php?t='.$file, AT_PRETTY_URL_IS_HEADER).'"'.
26                                   (strlen($file) > SUBLINK_TEXT_LEN ? ' title="'.$file.'"' : '') .'>'. 
27                                   validate_length($file, SUBLINK_TEXT_LEN, VALIDATE_LENGTH_FOR_DISPLAY) .'</a>'; 
28                         
29                         $cnt++;
30                 }
31         }
32 }
33
34 if (count($list) > 0) {
35         return $list;
36 } else {
37         return 0;
38 }
39
40
41 ?>