3 * FusionForge project manager
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.'pm/ProjectGroup.class.php';
30 class ProjectGroupFactory extends Error {
40 * The projectGroups array.
42 * @var array projectGroups.
49 * @param object The Group object to which this ProjectGroupFactory is associated.
50 * @return boolean success.
52 function ProjectGroupFactory(&$Group) {
54 if (!$Group || !is_object($Group)) {
55 $this->setError('ProjectGroup:: No Valid Group Object');
58 if ($Group->isError()) {
59 $this->setError('ProjectGroup:: '.$Group->getErrorMessage());
62 $this->Group =& $Group;
68 * getGroup - get the Group object this ProjectGroupFactory is associated with.
70 * @return object The Group object.
72 function &getGroup() {
76 function &getAllProjectGroupIds() {
78 $res = db_query_params ('SELECT * FROM project_group_list_vw WHERE group_id=$1 ORDER BY group_project_id',
79 array ($this->Group->getID())) ;
83 while ($arr =& db_fetch_array($res)) {
84 $result[] = $arr['group_project_id'] ;
90 * getProjectGroups - get an array of ProjectGroup objects.
92 * @return array The array of ProjectGroups.
94 function &getProjectGroups() {
95 if ($this->projectGroups) {
96 return $this->projectGroups;
99 $this->projectGroups = array () ;
100 $ids = $this->getAllProjectGroupIds() ;
102 foreach ($ids as $id) {
103 if (forge_check_perm ('pm', $id, 'read')) {
104 $this->projectGroups[] = new ProjectGroup($this->Group, $id);
107 return $this->projectGroups;
114 // c-file-style: "bsd"