made a copy
[atutor.git] / include / html / dropdowns / posts.inc.php
1 <?php
2 /************************************************************************/
3 /* ATutor                                                                                                                               */
4 /************************************************************************/
5 /* Copyright (c) 2002-2008 by Greg Gay, Joel Kronenberg & Heidi Hazelton*/
6 /* Adaptive Technology Resource Centre / University of Toronto                  */
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: posts.inc.php 4812 2005-06-07 19:52:15Z joel $
14
15 if (!defined('AT_INCLUDE_PATH')) { exit; }
16 global $db;
17 global $_base_path;
18 global $savant;
19
20 //Number of posts to display
21 $post_limit = 5;
22         
23 ob_start();
24
25 $forum_list = get_group_concat('forums_courses', 'forum_id', "course_id={$_SESSION['course_id']}");
26 if ($forum_list != 0) {
27         $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";
28         $result = mysql_query($sql, $db);
29
30         if (mysql_num_rows($result) > 0) {
31                 while ($row = mysql_fetch_assoc($result)) {
32                         echo '&#176; <a href="' . $_base_path.url_rewrite('forum/view.php?fid=' . $row['forum_id'] . 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 />';
33                 }
34         } else {
35                 echo '<em>'._AT('none_found').'</em>';
36         }
37 } else {
38         echo '<em>'._AT('none_found').'</em>';
39 }
40
41 $savant->assign('dropdown_contents', ob_get_contents());
42 ob_end_clean();
43
44 $savant->assign('title', _AT('forum_posts'));
45 $savant->display('include/box.tmpl.php');
46 ?>