move code up one directory
[atutor.git] / mods / _standard / forums / forum / list.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 define('AT_INCLUDE_PATH', '../../../../include/');
15
16 require (AT_INCLUDE_PATH.'vitals.inc.php');
17
18 require(AT_INCLUDE_PATH.'../mods/_standard/forums/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="<?php echo url_rewrite('mods/_standard/forums/forum/index.php?fid='.$row['forum_id']); ?>"><?php echo AT_print($row['title'], 'forums.title'); ?></a> <?php
60                                         // patch has added the two icons below
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                                         
65 if ($row1 = mysql_fetch_row($result1)) {
66                                         echo '<a href="mods/_standard/forums/forum/subscribe_forum.php?fid='.$row['forum_id'].SEP.'us=1">
67                                                         <br /><img border="0" src="'.AT_BASE_HREF.'images/unsubscribe-envelope.png" alt="" /> '._AT('unsubscribe1').'</a>';
68                                                 } else {
69                                                         echo '<a href="mods/_standard/forums/forum/subscribe_forum.php?fid='.$row['forum_id'].'">
70                                                         <br /><img border="0" src="'.AT_BASE_HREF.'images/subscribe-envelope.png" alt="" /> '._AT('subscribe1').'</a>';
71                                                 }
72                                         } ?>
73                                         <p><?php echo AT_print($row['description'], 'forums.description'); ?></p>
74                                 </td>
75                                 <td align="center" valign="top"><?php echo $row['num_topics']; ?></td>
76                                 <td align="center" valign="top"><?php echo $row['num_posts']; ?></td>
77                                 <td align="right" valign="top"><?php
78
79                                         if ($row['last_post'] == '0000-00-00 00:00:00') {
80                                                 echo '<strong>'._AT('na').'</strong>';
81                                         } else {
82                                                 echo AT_DATE(_AT('server_date_format'), $row['last_post'], AT_DATE_MYSQL_DATETIME);
83                                         } ?>
84                                 </td>
85                         </tr><?php
86                 endforeach;
87         }
88         echo '</tbody>';
89 } else {
90         echo '<tr><td class="row1" colspan="4"><strong>'._AT('no_forums').'</strong></td></tr>';
91 }
92 echo '</table>';
93
94 require (AT_INCLUDE_PATH.'footer.inc.php');
95 ?>