remove old readme
[atutor.git] / docs / mods / _standard / forums / admin / forums.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
15 define('AT_INCLUDE_PATH', '../../../../include/');
16 require(AT_INCLUDE_PATH.'vitals.inc.php');
17
18 admin_authenticate(AT_ADMIN_PRIV_FORUMS);
19
20 if (isset($_GET['edit'], $_GET['id'])) {
21         header('Location: forum_edit.php?forum='.$_GET['id']);
22         exit;
23 } else if (isset($_GET['delete'], $_GET['id'])) {
24         header('Location: forum_delete.php?forum='.$_GET['id']);
25         exit;
26 } else if (isset($_GET['delete']) || isset($_GET['edit'])) {
27         $msg->addError('NO_ITEM_SELECTED');
28 }
29
30 include(AT_INCLUDE_PATH.'../mods/_standard/forums/lib/forums.inc.php');
31
32 require(AT_INCLUDE_PATH.'header.inc.php'); 
33
34
35
36         $all_forums    = get_forums(0);
37         $num_shared    = count($all_forums['shared']);
38         $num_nonshared = count($all_forums['nonshared']);
39
40         $shared_forums = array();
41         $i = 0;
42                 
43         if ($num_shared) {
44                 foreach ($all_forums['shared'] as $forum) {
45                         $shared_forums[$i]["id"] = $forum['forum_id'];
46                         $shared_forums[$i]["title"] = AT_print($forum['title'], 'forums.title');   
47                         $shared_forums[$i]["desc"] = AT_print($forum['description'], 'forums.description');
48
49                         $courses = array();//create an empty array
50                         $sql = "SELECT F.course_id FROM ".TABLE_PREFIX."forums_courses F WHERE F.forum_id=$forum[forum_id]";
51                         $c_result = mysql_query($sql, $db);
52                         while ($course = mysql_fetch_assoc($c_result)) {
53                                 $courses[] = $system_courses[$course['course_id']]['title'];
54                         }
55                         natcasesort($courses);
56                         $shared_forums[$i]["courses"] = $courses;
57                         
58                         $i++;
59
60                 }
61         } else {
62                 echo '<tr>';
63                 echo '  <td colspan="4"><strong>' . _AT('no_forums') . '</strong></td>';
64                 echo '</tr>';
65         }
66
67 $nonshared_forums = array();
68 $i = 0;
69
70 if ($num_nonshared) {
71         foreach ($all_forums['nonshared'] as $forum) {
72                 $nonshared_forums[$i]["forum_id"] = $forum['forum_id'];
73                 $nonshared_forums[$i]["title"] = AT_print($forum['title'], 'forums.title');
74                 $nonshared_forums[$i]["desc"] = AT_print($forum['description'], 'forums.description');
75                 
76                 $i++;
77         }
78 }
79
80 $savant->assign('system_courses', $system_courses);
81 $savant->assign('num_nonshared', $num_nonshared);
82 $savant->assign('courses', $courses);
83 $savant->assign('shared_forums', $shared_forums);
84 $savant->assign('nonshared_forums', $nonshared_forums);
85 $savant->assign('all_forums', $all_forums);
86 $savant->display('admin/courses/forums.tmpl.php');
87 require(AT_INCLUDE_PATH.'footer.inc.php'); ?>