526ccd0b88022b439b95664eddc18b825d3e0d63
[atutor.git] / docs / mods / _standard / reading_list / 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 reading_list_news() {
19         global $db;
20         $news = array();
21
22         $sql = "SELECT * FROM ".TABLE_PREFIX."reading_list R INNER JOIN ".TABLE_PREFIX."external_resources E ON E.resource_id = R.resource_id WHERE R.course_id=$_SESSION[course_id] ORDER BY R.reading_id DESC";
23         $result = mysql_query($sql, $db);
24
25         if (mysql_num_rows($result) > 0) {
26                 while ($row = mysql_fetch_assoc($result)) {
27                         $news[] = array('time'=>$row['date_end'], 
28                                                         'object'=>$row,
29                                                         'thumb'=>'images/home-reading_list_sm.png',
30                                                         'link'=>'<a href="'.url_rewrite('mods/_standard/reading_list/display_resource.php?id=' . $row['resource_id'],
31                                                                         AT_PRETTY_URL_IS_HEADER).'"'.(strlen($row['title']) > SUBLINK_TEXT_LEN ? ' title="'.$row['title'].'"' : '') .'>'. 
32                                                                         validate_length($row['title'], SUBLINK_TEXT_LEN, VALIDATE_LENGTH_FOR_DISPLAY) .'</a>');
33                 }       
34         }
35         return $news;
36 }
37
38 ?>