3 * GForge Project Management 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 US
29 By Tim Perdue, Sourceforge, 11/99
30 Heavy rewrite by Tim Perdue April 2000
32 Total rewrite in OO and GForge coding guidelines 12/2002 by Tim Perdue
35 require_once('common/include/Error.class.php');
36 require_once('common/pm/ProjectGroup.class.php');
38 class ProjectGroupFactory extends Error {
48 * The projectGroups array.
50 * @var array projectGroups.
57 * @param object The Group object to which this ProjectGroupFactory is associated.
58 * @return boolean success.
60 function ProjectGroupFactory(&$Group) {
62 if (!$Group || !is_object($Group)) {
63 $this->setError('ProjectGroup:: No Valid Group Object');
66 if ($Group->isError()) {
67 $this->setError('ProjectGroup:: '.$Group->getErrorMessage());
70 $this->Group =& $Group;
76 * getGroup - get the Group object this ProjectGroupFactory is associated with.
78 * @return object The Group object.
80 function &getGroup() {
85 * getProjectGroups - get an array of ProjectGroup objects.
87 * @return array The array of ProjectGroups.
89 function &getProjectGroups() {
90 if ($this->projectGroups) {
91 return $this->projectGroups;
93 if (session_loggedin()) {
94 $perm =& $this->Group->getPermission( session_get_user() );
95 if (!$perm || !is_object($perm) || !$perm->isMember()) {
100 if ($perm->isPMAdmin()) {
103 $exists=" AND group_project_id IN (SELECT role_setting.ref_id
104 FROM role_setting, user_group
105 WHERE role_setting.value >= 0
106 AND role_setting.section_name = 'pm'
107 AND role_setting.ref_id=project_group_list_vw.group_project_id
109 AND user_group.role_id = role_setting.role_id
110 AND user_group.user_id='".user_getid()."') ";
119 FROM project_group_list_vw
120 WHERE group_id='". $this->Group->getID() ."'
121 AND is_public $public_flag $exists
122 ORDER BY group_project_id;";
124 $result = db_query ($sql);
126 $rows = db_numrows($result);
128 if (!$result || $rows < 1) {
129 $this->setError(_('No ProjectGroups Found').db_error());
130 $this->projectGroups=NULL;
132 while ($arr = db_fetch_array($result)) {
133 $this->projectGroups[] = new ProjectGroup($this->Group, $arr['group_project_id'], $arr);
136 return $this->projectGroups;
143 // c-file-style: "bsd"