5 * Copyright 2002, GForge, LLC
6 * Copyright 2009, Roland Mas
8 * This file is part of FusionForge. FusionForge is free software;
9 * you can redistribute it and/or modify it under the terms of the
10 * GNU General Public License as published by the Free Software
11 * Foundation; either version 2 of the Licence, or (at your option)
14 * FusionForge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 require_once $gfcommon.'include/Error.class.php';
25 require_once $gfcommon.'tracker/ArtifactType.class.php';
27 class ArtifactTypeFactory extends Error {
37 * The ArtifactTypes array.
39 * @var array ArtifactTypes.
46 * @var string dataType
53 * @param object The Group object to which this ArtifactTypeFactory is associated
54 * @return boolean success.
56 function ArtifactTypeFactory(&$Group) {
58 if (!$Group || !is_object($Group)) {
59 $this->setError('ArtifactTypeFactory:: No Valid Group Object');
62 if ($Group->isError()) {
63 $this->setError('ArtifactTypeFactory:: '.$Group->getErrorMessage());
66 $this->Group =& $Group;
72 * getGroup - get the Group object this ArtifactType is associated with.
74 * @return object The Group object.
76 function &getGroup() {
81 * getAllArtifactTypeIds - return a list of tracker ids.
83 * @return array The array of ArtifactType objects.
85 function &getAllArtifactTypeIds() {
87 $res = db_query_params ('SELECT * FROM artifact_group_list_vw
89 ORDER BY group_artifact_id ASC',
90 array ($this->Group->getID())) ;
94 while ($arr = db_fetch_array($res)) {
95 $result[] = $arr['group_artifact_id'] ;
101 * getArtifactTypes - return an array of ArtifactType objects.
103 * @return array The array of ArtifactType objects.
105 function getArtifactTypes() {
106 if ($this->ArtifactTypes) {
107 return $this->ArtifactTypes;
110 $this->ArtifactTypes = array () ;
111 $ids = $this->getAllArtifactTypeIds() ;
113 foreach ($ids as $id) {
114 if (forge_check_perm ('tracker', $id, 'read')) {
115 $artifactType = new ArtifactType($this->Group, $id);
116 if($artifactType->isError()) {
117 $this->setError($artifactType->getErrorMessage());
119 $this->ArtifactTypes[] = $artifactType;
123 return $this->ArtifactTypes;
127 * getPublicFlag - a utility method to load up the current user's permissions
129 * @return string The public_flag field to plug into a SQL string
131 function &getPublicFlag() {
139 // c-file-style: "bsd"