5 * Copyright 1999-2000, Tim Perdue/Sourceforge
6 * Copyright 2002, Tim Perdue/GForge, LLC
8 * This file is part of FusionForge.
10 * FusionForge is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published
12 * by the Free Software Foundation; either version 2 of the License,
13 * or (at your option) any later version.
15 * FusionForge is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with FusionForge; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
26 require_once $gfcommon.'include/Error.class.php';
27 require_once $gfcommon.'forum/Forum.class.php';
29 class ForumFactory extends Error {
48 * @param object The Group object to which this forum is associated.
50 function ForumFactory(&$Group) {
52 if (!$Group || !is_object($Group)) {
53 $this->setError(_('Forum:: No Valid Group Object'));
56 if ($Group->isError()) {
57 $this->setError(_('Forum').':: '.$Group->getErrorMessage());
60 $this->Group =& $Group;
66 * getGroup - get the Group object this ForumFactory is associated with.
68 * @return object The Group object.
70 function &getGroup() {
75 * getForums - get an array of Forum objects for this Group.
77 * @return array The array of Forum objects.
79 function &getForums() {
80 global $sys_database_type;
85 if (session_loggedin()) {
86 $perm =& $this->Group->getPermission( session_get_user() );
87 if (!$perm || !is_object($perm) || !$perm->isMember()) {
92 if ($perm->isForumAdmin()) {
95 $exists=" AND group_forum_id IN (SELECT role_setting.ref_id
96 FROM role_setting, user_group
97 WHERE role_setting.value::integer >= 0
98 AND role_setting.section_name = 'forum'
99 AND role_setting.ref_id=forum_group_list_vw.group_forum_id
101 AND user_group.role_id = role_setting.role_id
102 AND user_group.user_id='".user_getid()."') ";
110 if ($sys_database_type == "mysql") {
112 (SELECT count(*) AS `count`
114 SELECT DISTINCT group_forum_id, thread_id FROM forum
116 WHERE tmp.group_forum_id = fgl.group_forum_id
118 FROM forum_group_list_vw AS fgl";
121 FROM forum_group_list_vw";
124 WHERE group_id='". $this->Group->getID() ."'
125 AND is_public $public_flag
127 ORDER BY group_forum_id;";
129 $result = db_query ($sql);
131 $rows = db_numrows($result);
134 $this->setError(_('Forum not found').' : '.db_error());
135 $this->forums = false;
137 while ($arr = db_fetch_array($result)) {
138 $this->forums[] = new Forum($this->Group, $arr['group_forum_id'], $arr);
141 return $this->forums;
148 // c-file-style: "bsd"