5 * Copyright 1999-2000, Tim Perdue/Sourceforge
6 * Copyright 2002, Tim Perdue/GForge, LLC
7 * Copyright 2009, Roland Mas
9 * This file is part of FusionForge.
11 * FusionForge is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published
13 * by the Free Software Foundation; either version 2 of the License,
14 * or (at your option) any later version.
16 * FusionForge is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with FusionForge; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
27 require_once $gfcommon.'include/Error.class.php';
28 require_once $gfcommon.'forum/Forum.class.php';
30 class ForumFactory extends Error {
49 * @param object The Group object to which this forum is associated.
51 function ForumFactory(&$Group) {
53 if (!$Group || !is_object($Group)) {
54 $this->setError(_('Forum:: No Valid Group Object'));
57 if ($Group->isError()) {
58 $this->setError(_('Forum').':: '.$Group->getErrorMessage());
61 $this->Group =& $Group;
67 * getGroup - get the Group object this ForumFactory is associated with.
69 * @return object The Group object.
71 function &getGroup() {
75 function &getAllForumIds() {
76 $res = db_query_params ('SELECT * FROM forum_group_list_vw
78 ORDER BY group_forum_id',
79 array ($this->Group->getID())) ;
83 while ($arr =& db_fetch_array($res)) {
84 $result[] = $arr['group_forum_id'] ;
90 * getForums - get an array of Forum objects for this Group.
92 * @return array The array of Forum objects.
94 function &getForums() {
99 $this->forums = array () ;
100 $ids = $this->getAllForumIds() ;
102 foreach ($ids as $id) {
103 if (forge_check_perm ('forum', $id, 'read')) {
104 $this->forums[] = new Forum($this->Group, $id);
107 return $this->forums;
111 * getForumsAdmin - get an array of all (public, private and suspended) Forum objects for this Group.
113 * @return array The array of Forum objects.
115 function &getForumsAdmin() {
117 return $this->forums;
121 if (session_loggedin()) {
122 if (!forge_check_perm ('forum_admin', $this->Group->getID())) {
123 $this->setError(_("You don't have a permission to access this page"));
124 $this->forums = false;
126 $result = db_query_params ('SELECT * FROM forum_group_list_vw
128 ORDER BY group_forum_id',
129 array ($this->Group->getID())) ;
132 $this->setError(_("You don't have a permission to access this page"));
133 $this->forums = false;
136 $rows = db_numrows($result);
139 $this->setError(_('Forum not found').' : '.db_error());
140 $this->forums = false;
142 while ($arr = db_fetch_array($result)) {
143 $this->forums[] = new Forum($this->Group, $arr['group_forum_id'], $arr);
146 return $this->forums;
152 // c-file-style: "bsd"