remove old readme
[atutor.git] / mods / _standard / forums / 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 forums_news() {
19     require_once(AT_INCLUDE_PATH.'../mods/_standard/forums/lib/forums.inc.php');
20     global $db, $enrolled_courses, $system_courses;
21     $news = array();
22
23     if ($enrolled_courses == ''){
24         return $news;
25     } 
26
27     $sql = 'SELECT E.approved, E.last_cid, C.* FROM '.TABLE_PREFIX.'course_enrollment E, '.TABLE_PREFIX.'courses C WHERE E.member_id=1 AND E.course_id=C.course_id ORDER BY C.title';
28     $result = mysql_query($sql, $db);
29     if ($result) {
30         while($row = mysql_fetch_assoc($result)){
31             $all_forums = get_forums($row['course_id']);
32             if (is_array($all_forums)){
33                 foreach($all_forums as $forums){
34                     if (is_array($forums)){
35
36                         foreach ($forums as $forum_obj){
37                              $forum_obj['course_id'] = $row['course_id'];
38                              $link_title = $forum_obj['title'];
39                              $news[] = array('time'=>$forum_obj['last_post'], 
40                               'object'=>$forum_obj, 
41                               'alt'=>_AT('forum'),
42                               'thumb'=>'images/pin.png',
43                               'course'=>$system_courses[$row['course_id']]['title'],
44                               'link'=>'<a href="bounce.php?course='.$row['course_id'].SEP.'p='.urlencode('mods/_standard/forums/forum/index.php?fid='.$forum_obj['forum_id']).'"'.
45                               (strlen($link_title) > SUBLINK_TEXT_LEN ? ' title="'.AT_print($link_title, 'forums.title').'"' : '') .'>'. 
46                               AT_print(validate_length($link_title, SUBLINK_TEXT_LEN, VALIDATE_LENGTH_FOR_DISPLAY), 'forums.title') .'</a>');
47                         }
48                     }
49                 }
50             }
51         }
52     }
53     return $news;
54 }
55
56 ?>