3 * GForge Forums Facility
5 * Copyright 2002 GForge, LLC
10 * This file is part of GForge.
12 * GForge is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * GForge is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with GForge; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 By Tim Perdue, Sourceforge, 11/99
32 Massive rewrite by Tim Perdue 7/2000 (nested/views/save)
34 Complete OO rewrite by Tim Perdue 12/2002
38 require_once('common/include/Error.class');
39 require_once('common/forum/Forum.class');
41 class ForumFactory extends Error {
60 * @param object The Group object to which this forum is associated.
62 function ForumFactory(&$Group) {
65 if (!$Group || !is_object($Group)) {
66 $this->setError(_('Forum:: No Valid Group Object'));
69 if ($Group->isError()) {
70 $this->setError(_('Forum').':: '.$Group->getErrorMessage());
73 $this->Group =& $Group;
79 * getGroup - get the Group object this ForumFactory is associated with.
81 * @return object The Group object.
83 function &getGroup() {
88 * getForums - get an array of Forum objects for this Group.
90 * @return array The array of Forum objects.
92 function &getForums() {
93 global $Language, $sys_database_type;
98 if (session_loggedin()) {
99 $perm =& $this->Group->getPermission( session_get_user() );
100 if (!$perm || !is_object($perm) || !$perm->isMember()) {
104 if ($perm->isForumAdmin()) {
107 $exists=" AND group_forum_id IN (SELECT group_forum_ID
109 WHERE perm_level >= 0 AND group_forum_id=forum_group_list.group_forum_id
110 AND user_id='".user_getid()."') ";
117 if ($sys_database_type == "mysql") {
119 (SELECT count(*) AS `count`
121 SELECT DISTINCT group_forum_id, thread_id FROM forum
123 WHERE tmp.group_forum_id = fgl.group_forum_id
125 FROM forum_group_list_vw AS fgl";
128 FROM forum_group_list_vw";
131 WHERE group_id='". $this->Group->getID() ."'
132 AND is_public $public_flag
134 ORDER BY group_forum_id;";
136 $result = db_query ($sql);
138 $rows = db_numrows($result);
141 $this->setError(_('Forum not found').db_error());
144 while ($arr = db_fetch_array($result)) {
145 $this->forums[] = new Forum($this->Group, $arr['group_forum_id'], $arr);
148 return $this->forums;