made a copy
[atutor.git] / admin / forums.php
1 <?php\r
2 /************************************************************************/\r
3 /* ATutor                                                                                                                               */\r
4 /************************************************************************/\r
5 /* Copyright (c) 2002-2008 by Greg Gay, Joel Kronenberg & Heidi Hazelton*/\r
6 /* Adaptive Technology Resource Centre / University of Toronto                  */\r
7 /* http://atutor.ca                                                                                                             */\r
8 /*                                                                                                                                              */\r
9 /* This program is free software. You can redistribute it and/or                */\r
10 /* modify it under the terms of the GNU General Public License                  */\r
11 /* as published by the Free Software Foundation.                                                */\r
12 /************************************************************************/\r
13 // $Id$\r
14 \r
15 define('AT_INCLUDE_PATH', '../include/');\r
16 require(AT_INCLUDE_PATH.'vitals.inc.php');\r
17 \r
18 admin_authenticate(AT_ADMIN_PRIV_FORUMS);\r
19 \r
20 if (isset($_GET['edit'], $_GET['id'])) {\r
21         header('Location: forum_edit.php?forum='.$_GET['id']);\r
22         exit;\r
23 } else if (isset($_GET['delete'], $_GET['id'])) {\r
24         header('Location: forum_delete.php?forum='.$_GET['id']);\r
25         exit;\r
26 } else if (isset($_GET['delete']) || isset($_GET['edit'])) {\r
27         $msg->addError('NO_ITEM_SELECTED');\r
28 }\r
29 \r
30 require(AT_INCLUDE_PATH.'lib/forums.inc.php');\r
31 \r
32 require(AT_INCLUDE_PATH.'header.inc.php'); \r
33 \r
34 ?>\r
35 <form name="form" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">\r
36 <table class="data" summary="" rules="groups" style="width: 90%">\r
37 <thead>\r
38 <tr>\r
39         <th scope="col">&nbsp;</th>\r
40         <th scope="col"><?php echo _AT('title');       ?></th>\r
41         <th scope="col"><?php echo _AT('description'); ?></th>\r
42         <th scope="col"><?php echo _AT('courses');     ?></th>\r
43 </tr>\r
44 </thead>\r
45 <tfoot>\r
46 <tr>\r
47         <td colspan="4"><input type="submit" name="edit" value="<?php echo _AT('edit'); ?>" /> <input type="submit" name="delete" value="<?php echo _AT('delete'); ?>" /></td>\r
48 </tr>\r
49 </tfoot>\r
50 <tbody>\r
51 <tr>\r
52         <th colspan="4"><?php echo _AT('shared_forums'); ?></th>\r
53 </tr>\r
54 <?php\r
55 \r
56 \r
57         $all_forums    = get_forums(0);\r
58         $num_shared    = count($all_forums['shared']);\r
59         $num_nonshared = count($all_forums['nonshared']);\r
60 \r
61         if ($num_shared) {\r
62                 foreach ($all_forums['shared'] as $forum) {\r
63                         echo '<tr onmousedown="document.form[\'f'.$forum['forum_id'].'\'].checked = true; rowselect(this);"  id="r_'.$forum['forum_id'].'">';\r
64                         echo '<td><input type="radio" name="id" value="'. $forum['forum_id'].'" id="f'.$forum['forum_id'].'"></td>';\r
65                         echo '  <td><label for="f'.$forum['forum_id'].'">' . $forum['title'] . '</label></td>';\r
66                         echo '  <td>' . $forum['description'] . '</td>';\r
67                         echo '  <td>';\r
68 \r
69                         $courses = array();\r
70                         $sql = "SELECT F.course_id FROM ".TABLE_PREFIX."forums_courses F WHERE F.forum_id=$forum[forum_id]";\r
71                         $c_result = mysql_query($sql, $db);\r
72                         while ($course = mysql_fetch_assoc($c_result)) {\r
73                                 $courses[] = $system_courses[$course['course_id']]['title'];\r
74                         }\r
75                         natcasesort($courses);\r
76                         echo implode(', ', $courses);\r
77                         echo '</td>';\r
78                         echo '</tr>';\r
79                 }\r
80         } else {\r
81                 echo '<tr>';\r
82                 echo '  <td colspan="4"><em>' . _AT('no_forums') . '</em></td>';\r
83                 echo '</tr>';\r
84         }\r
85 ?>\r
86 </tbody>\r
87 <tbody>\r
88         <tr>\r
89                 <th colspan="4"><?php echo _AT('unshared_forums'); ?></th>\r
90         </tr>\r
91 <?php if ($num_nonshared) : ?>\r
92         <?php foreach ($all_forums['nonshared'] as $forum) : ?>\r
93                 <tr onmousedown="document.form['f<?php echo $forum['forum_id']; ?>'].checked = true; rowselect(this);" id="r_<?php echo $forum['forum_id']; ?>">\r
94                         <td><input type="radio" name="id" value="<?php echo $forum['forum_id']; ?>" id="f<?php echo $forum['forum_id']; ?>" /></td>\r
95                         <td><label for="f<?php echo $forum['forum_id']; ?>"><?php echo $forum['title']; ?></label></td>\r
96                         <td><?php echo $forum['description']; ?></td>\r
97                         <td><?php echo $system_courses[$forum['course_id']]['title']; ?></td>\r
98                 </tr>\r
99         <?php endforeach; ?>\r
100 <?php else: ?>\r
101         <tr>\r
102                 <td colspan="4"><em><?php echo _AT('no_forums'); ?></em></td>\r
103         </tr>\r
104 <?php endif; ?>\r
105 </tbody>\r
106 </table>\r
107 </form>\r
108 \r
109 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>