3 * FusionForge project manager
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.'pm/ProjectGroup.class.php';
29 class ProjectGroupFactory extends Error {
39 * The projectGroups array.
41 * @var array projectGroups.
48 * @param object The Group object to which this ProjectGroupFactory is associated.
49 * @return boolean success.
51 function ProjectGroupFactory(&$Group) {
53 if (!$Group || !is_object($Group)) {
54 $this->setError('ProjectGroup:: No Valid Group Object');
57 if ($Group->isError()) {
58 $this->setError('ProjectGroup:: '.$Group->getErrorMessage());
61 $this->Group =& $Group;
67 * getGroup - get the Group object this ProjectGroupFactory is associated with.
69 * @return object The Group object.
71 function &getGroup() {
76 * getProjectGroups - get an array of ProjectGroup objects.
78 * @return array The array of ProjectGroups.
80 function &getProjectGroups() {
81 if ($this->projectGroups) {
82 return $this->projectGroups;
84 if (session_loggedin()) {
85 $perm =& $this->Group->getPermission( session_get_user() );
86 if (!$perm || !is_object($perm) || !$perm->isMember()) {
91 if ($perm->isPMAdmin()) {
94 $exists=" AND group_project_id IN (SELECT role_setting.ref_id
95 FROM role_setting, user_group
96 WHERE role_setting.value::integer >= 0
97 AND role_setting.section_name = 'pm'
98 AND role_setting.ref_id=project_group_list_vw.group_project_id
100 AND user_group.role_id = role_setting.role_id
101 AND user_group.user_id='".user_getid()."') ";
110 FROM project_group_list_vw
111 WHERE group_id='". $this->Group->getID() ."'
112 AND is_public $public_flag $exists
113 ORDER BY group_project_id;";
115 $result = db_query ($sql);
117 $rows = db_numrows($result);
119 if (!$result || $rows < 1) {
120 $this->setError(_('No ProjectGroups Found').db_error());
121 $this->projectGroups=NULL;
123 while ($arr = db_fetch_array($result)) {
124 $this->projectGroups[] = new ProjectGroup($this->Group, $arr['group_project_id'], $arr);
127 return $this->projectGroups;
134 // c-file-style: "bsd"