tagging as ATutor 1.5.4-release
[atutor.git] / forum / index.php
1 <?php
2 /****************************************************************************/
3 /* ATutor                                                                                                                                       */
4 /****************************************************************************/
5 /* Copyright (c) 2002-2006 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$
14
15 define('AT_INCLUDE_PATH', '../include/');
16 require(AT_INCLUDE_PATH.'vitals.inc.php');
17
18 $fid = intval($_GET['fid']);
19
20 if (!isset($_GET['fid']) || !$fid) {
21         header('Location: list.php');
22         exit;
23 }
24 require(AT_INCLUDE_PATH.'lib/forums.inc.php');
25
26 if (!valid_forum_user($fid)) {
27         require(AT_INCLUDE_PATH.'header.inc.php');
28         $msg->addError('FORUM_DENIED');
29         $msg->printErrors();
30         require(AT_INCLUDE_PATH.'footer.inc.php');
31 }
32
33 $_pages['forum/index.php']['title']    = get_forum_name($fid);
34 $_pages['forum/index.php']['parent']   = 'forum/list.php';
35 $_pages['forum/index.php']['children'] = array('forum/new_thread.php?fid='.$fid);
36
37 $_pages['forum/new_thread.php?fid='.$fid]['title_var'] = 'new_thread';
38 $_pages['forum/new_thread.php?fid='.$fid]['parent']    = 'forum/index.php';
39
40 /* the last accessed field */
41 $last_accessed = array();
42 if ($_SESSION['valid_user'] && $_SESSION['enroll']) {
43         $sql    = "SELECT post_id, last_accessed + 0 AS last_accessed, subscribe FROM ".TABLE_PREFIX."forums_accessed WHERE member_id=$_SESSION[member_id]";
44         $result = mysql_query($sql, $db);
45         while ($row = mysql_fetch_assoc($result)) {
46                 $post_id = $row['post_id'];
47                 unset($row['post_id']);
48                 $last_accessed[$post_id] = $row;
49         }
50 }
51
52 require(AT_INCLUDE_PATH . 'header.inc.php');
53
54 require(AT_INCLUDE_PATH . 'html/forum.inc.php');
55
56 require(AT_INCLUDE_PATH . 'footer.inc.php');
57 ?>