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
51 * __construct - ArtifactTypeFactory constructor.
53 * @param Group $Group The Group object to which this ArtifactTypeFactory is associated
55 function __construct(&$Group) {
57 if (!$Group || !is_object($Group)) {
58 $this->setError('ArtifactTypeFactory:: No Valid Group Object');
61 if ($Group->isError()) {
62 $this->setError('ArtifactTypeFactory:: '.$Group->getErrorMessage());
65 $this->Group =& $Group;
71 * getGroup - get the Group object this ArtifactType is associated with.
73 * @return object The Group object.
75 function &getGroup() {
80 * getAllArtifactTypeIds - return a list of tracker ids.
82 * @return array The array of ArtifactType objects.
84 function &getAllArtifactTypeIds() {
86 $res = db_query_params ('SELECT * FROM artifact_group_list_vw
88 ORDER BY group_artifact_id ASC',
89 array ($this->Group->getID())) ;
93 while ($arr = db_fetch_array($res)) {
94 $result[] = $arr['group_artifact_id'] ;
100 * getArtifactTypes - return an array of ArtifactType objects.
102 * @return array The array of ArtifactType objects.
104 function getArtifactTypes() {
105 if ($this->ArtifactTypes) {
106 return $this->ArtifactTypes;
109 $this->ArtifactTypes = array () ;
110 $ids = $this->getAllArtifactTypeIds() ;
112 foreach ($ids as $id) {
113 if (forge_check_perm ('tracker', $id, 'read')) {
114 $artifactType = new ArtifactType($this->Group, $id);
115 if($artifactType->isError()) {
116 $this->setError($artifactType->getErrorMessage());
118 $this->ArtifactTypes[] = $artifactType;
122 return $this->ArtifactTypes;
128 // c-file-style: "bsd"