tagging as ATutor 1.5.4-release
[atutor.git] / forum / list.php
1 <?php
2 /****************************************************************/
3 /* ATutor                                                                                                               */
4 /****************************************************************/
5 /* Copyright (c) 2002-2006 by Greg Gay & Joel Kronenberg        */
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 define('AT_INCLUDE_PATH', '../include/');
15
16 require (AT_INCLUDE_PATH.'vitals.inc.php');
17
18 require_once(AT_INCLUDE_PATH.'lib/forums.inc.php');
19 require (AT_INCLUDE_PATH.'header.inc.php');
20 ?>
21 <table class="data static" summary="" rules="rows">
22 <thead>
23 <tr>
24         <th scope="col"><?php echo _AT('forum');        ?></th>
25         <th scope="col"><?php echo _AT('num_threads'); ?></th>
26         <th scope="col"><?php echo _AT('num_posts');    ?></th>
27         <th scope="col"><?php echo _AT('last_post');    ?></th>
28 </tr>
29 </thead>
30 <?php
31 $shared  = array();
32 $general = array();
33 $all_forums = get_forums($_SESSION['course_id']);
34 //output course forums
35 $num_shared    = count($all_forums['shared']);
36 $num_nonshared = count($all_forums['nonshared']);
37 $num_groups = count($all_forums['group']);
38
39 if ($num_shared || $num_nonshared || $num_groups) {
40         foreach ($all_forums as $shared => $forums) {
41                 if (($num_shared && $num_nonshared) || ($num_nonshared && $num_groups)) {
42                         if ($num_nonshared && ($shared == 'nonshared')) {
43                                 echo '<tbody><tr>';
44                                 echo '<th colspan="4">' . _AT('course_forums') . '</th>';
45                                 echo '</tr>';
46                         } else if ($num_shared && ($shared == 'shared')) {
47                                 echo '</tbody><tbody><tr>';
48                                 echo '<th colspan="4">' . _AT('shared_forums') . '</th>';
49                                 echo '</tr>';
50                         } else if ($num_groups && ($shared == 'group')) {
51                                 echo '</tbody><tbody><tr>';
52                                 echo '<th colspan="4">' . _AT('group_forums') . '</th>';
53                                 echo '</tr>';
54                         }
55                 }
56
57                 foreach ($forums as $row) : ?>
58                         <tr>
59                                 <td><a href="forum/index.php?fid=<?php echo $row['forum_id']; ?>"><?php echo $row['title']; ?></a> <?php
60
61                                         if ($_SESSION['enroll']) {
62                                                 $sql    = "SELECT 1 AS constant FROM ".TABLE_PREFIX."forums_subscriptions WHERE forum_id=$row[forum_id] AND member_id=$_SESSION[member_id]";
63                                                 $result1 = mysql_query($sql, $db);
64                                                 echo ' [ ';
65                                                 if ($row1 = mysql_fetch_row($result1)) {
66                                                         echo '<a href="forum/subscribe_forum.php?fid='.$row['forum_id'].SEP.'us=1">'._AT('unsubscribe1').'</a>';
67                                                 } else {
68                                                         echo '<a href="forum/subscribe_forum.php?fid='.$row['forum_id'].'">'._AT('subscribe1').'</a>';
69                                                 }
70                                                 echo ' ]';
71                                         } ?>
72                                         <p><?php echo $row['description']; ?></p>
73                                 </td>
74                                 <td align="center" valign="top"><?php echo $row['num_topics']; ?></td>
75                                 <td align="center" valign="top"><?php echo $row['num_posts']; ?></td>
76                                 <td align="right" valign="top"><?php
77
78                                         if ($row['last_post'] == '0000-00-00 00:00:00') {
79                                                 echo '<em>'._AT('na').'</em>';
80                                         } else {
81                                                 echo $row['last_post'];
82                                         } ?>
83                                 </td>
84                         </tr><?php
85                 endforeach;
86         }
87         echo '</tbody>';
88 } else {
89         echo '<tr><td class="row1" colspan="4"><em>'._AT('no_forums').'</em></td></tr>';
90 }
91 echo '</table>';
92
93 require (AT_INCLUDE_PATH.'footer.inc.php');
94 ?>