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. FusionForge is free software;
10 * you can redistribute it and/or modify it under the terms of the
11 * GNU General Public License as published by the Free Software
12 * Foundation; either version 2 of the Licence, or (at your option)
15 * FusionForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 require_once $gfcommon.'include/Error.class.php';
26 require_once $gfcommon.'pm/ProjectGroup.class.php';
28 class ProjectGroupFactory extends Error {
38 * The projectGroups array.
40 * @var array projectGroups.
47 * @param object The Group object to which this ProjectGroupFactory is associated.
48 * @return boolean success.
50 function ProjectGroupFactory(&$Group) {
52 if (!$Group || !is_object($Group)) {
53 $this->setError('ProjectGroup:: No Valid Group Object');
56 if ($Group->isError()) {
57 $this->setError('ProjectGroup:: '.$Group->getErrorMessage());
60 $this->Group =& $Group;
66 * getGroup - get the Group object this ProjectGroupFactory is associated with.
68 * @return object The Group object.
70 function &getGroup() {
74 function &getAllProjectGroupIds() {
76 $res = db_query_params ('SELECT * FROM project_group_list_vw WHERE group_id=$1 ORDER BY group_project_id',
77 array ($this->Group->getID())) ;
81 while ($arr = db_fetch_array($res)) {
82 $result[] = $arr['group_project_id'] ;
88 * getProjectGroups - get an array of ProjectGroup objects.
90 * @return array The array of ProjectGroups.
92 function getProjectGroups() {
93 if ($this->projectGroups) {
94 return $this->projectGroups;
97 $this->projectGroups = array () ;
98 $ids = $this->getAllProjectGroupIds() ;
100 foreach ($ids as $id) {
101 if (forge_check_perm ('pm', $id, 'read')) {
102 $this->projectGroups[] = new ProjectGroup($this->Group, $id);
105 return $this->projectGroups;
112 // c-file-style: "bsd"