400914a98934b58a30c4d5b7fc16d31ee3fbfd70
[atutor.git] / docs / mods / _standard / file_storage / module_news.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  * Get the latest updates of this module
16  * @return list of news, [timestamp]=>
17  */
18 function file_storage_news() {
19         global $db, $enrolled_courses, $system_courses;
20         $news = array();
21
22         if ($enrolled_courses == ''){
23                 return $news;
24         } 
25
26         $sql = "SELECT date, file_id, file_name, owner_id, description FROM ".TABLE_PREFIX."files WHERE owner_id IN $enrolled_courses ORDER BY date DESC";
27         $result = mysql_query($sql, $db);
28         if($result){
29                 while($row = mysql_fetch_assoc($result)){
30                         $row['course_id'] = $row['owner_id'];
31                         if($row['description'] !=""){
32                                 $filetext = $row['description'];
33                         } else {
34                                 $filetext = $row['file_name'];
35                         }
36                         $news[] = array('time'=>$row['date'], 
37                               'object'=>$row, 
38                               'course'=>$system_courses[$row['owner_id']]['title'],
39                               'alt'=>_AT('download'),
40                               'thumb'=>'images/application_get.png', 
41                               'link'=>'<a href="bounce.php?course='.$row['owner_id'].SEP.'p='.urlencode('mods/_standard/file_storage/index.php?download=1'.SEP.'files[]='. $row['file_id']).'"'.
42                           (strlen($filetext) > SUBLINK_TEXT_LEN ? ' title="'.AT_print($filetext, 'input.text').'"' : '') .'>'. 
43                           AT_print(validate_length($filetext, SUBLINK_TEXT_LEN, VALIDATE_LENGTH_FOR_DISPLAY), 'input.text') .'</a>');
44                 }
45         }
46         return $news;
47 }
48
49 ?>