move code up one directory
[atutor.git] / mods / _standard / links / 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 links_news() {
19         global $db, $enrolled_courses, $system_courses;
20         $news = array();
21
22         if ($enrolled_courses == ''){
23                 return $news;
24         } 
25
26         $sql = "SELECT * FROM ".TABLE_PREFIX."links L INNER JOIN ".TABLE_PREFIX."links_categories C ON C.cat_id = L.cat_id WHERE owner_id IN $enrolled_courses AND L.Approved=1 ORDER BY SubmitDate DESC";
27         $result = mysql_query($sql, $db);
28         if($result){
29                 while($row = mysql_fetch_assoc($result)){
30                         $news[] = array(
31                                                         'time'=>$row['SubmitDate'], 
32                                                         'object'=>$row, 
33                                                         'alt'=>_AT('links'),
34                                                         'course'=>$system_courses[$row['owner_id']]['title'],
35                                                         'thumb'=>'images/home-links_sm.png', 
36                                                         'link'=>'<a href="bounce.php?course='.$row['owner_id'].'&p='.urlencode('mods/_standard/links/index.php?view='.$row['link_id']).'"'.
37                                                                         (strlen($row['LinkName']) > SUBLINK_TEXT_LEN ? ' title="'.$row['LinkName'].'"' : '') .'>'. 
38                                                                         validate_length($row['LinkName'], SUBLINK_TEXT_LEN, VALIDATE_LENGTH_FOR_DISPLAY) .'</a>');
39                 }
40         }
41         return $news;
42 }
43
44 ?>