move code up one directory
[atutor.git] / include / html / dropdowns / posts.inc.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 // $Id: posts.inc.php 4812 2005-06-07 19:52:15Z joel $
13
14 if (!defined('AT_INCLUDE_PATH')) { exit; }
15 global $db;
16 global $_base_path;
17 global $savant;
18
19 //Number of posts to display
20 $post_limit = 5;
21         
22 ob_start();
23
24 // global $_course_id is set when a guest accessing a public course. 
25 // This is to solve the issue that the google indexing fails as the session vars are lost.
26 global $_course_id;
27 if (isset($_SESSION['course_id'])) $_course_id = $_SESSION['course_id'];
28
29 $forum_list = get_group_concat('forums_courses', 'forum_id', "course_id={$_course_id}");
30 if ($forum_list != 0) {
31         $sql = "SELECT subject, post_id, forum_id, member_id FROM ".TABLE_PREFIX."forums_threads WHERE parent_id=0 AND forum_id IN ($forum_list) ORDER BY last_comment DESC LIMIT $post_limit";
32         $result = mysql_query($sql, $db);
33
34         if (mysql_num_rows($result) > 0) {
35                 while ($row = mysql_fetch_assoc($result)) {
36                         echo '&#176; <a href="' . $_base_path.url_rewrite('forum/view.php?fid=' . $row['forum_id'] . htmlentities(SEP) . 'pid=' . $row['post_id']) . '" title="' . $row['subject'] . ': ' . htmlspecialchars(get_display_name($row['member_id'])) . '">' . AT_print(validate_length($row['subject'], 20, VALIDATE_LENGTH_FOR_DISPLAY), 'forums_threads.subject') . '</a><br />';
37                 }
38         } else {
39                 echo '<strong>'._AT('none_found').'</strong>';
40         }
41 } else {
42         echo '<strong>'._AT('none_found').'</strong>';
43 }
44
45 $savant->assign('dropdown_contents', ob_get_contents());
46 ob_end_clean();
47
48 $savant->assign('title', _AT('forum_posts'));
49 $savant->display('include/box.tmpl.php');
50 ?>