5 * Copyright 2002, GForge, LLC
6 * Copyright 2009, Roland Mas
7 * Copyright 2013, Franck Villaume - TrivialDev
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.'tracker/ArtifactType.class.php';
28 class ArtifactTypeFactory extends Error {
38 * The ArtifactTypes array.
40 * @var array ArtifactTypes.
47 * @var string dataType
52 * __construct - ArtifactTypeFactory constructor.
54 * @param Group $Group The Group object to which this ArtifactTypeFactory is associated
56 function __construct(&$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 if (!$Group->usesTracker()) {
67 $this->setError(sprintf(_('%s does not use the Tracker tool'),
68 $Group->getPublicName()));
71 $this->Group =& $Group;
77 * getGroup - get the Group object this ArtifactType is associated with.
79 * @return object The Group object.
81 function &getGroup() {
86 * getAllArtifactTypeIds - return a list of tracker ids.
88 * @return array The array of ArtifactType objects.
90 function &getAllArtifactTypeIds() {
92 $res = db_query_params ('SELECT * FROM artifact_group_list_vw
94 ORDER BY group_artifact_id ASC',
95 array ($this->Group->getID())) ;
99 while ($arr = db_fetch_array($res)) {
100 $result[] = $arr['group_artifact_id'] ;
106 * getArtifactTypes - return an array of ArtifactType objects.
108 * @return array The array of ArtifactType objects.
110 function getArtifactTypes() {
111 if ($this->ArtifactTypes) {
112 return $this->ArtifactTypes;
115 $this->ArtifactTypes = array () ;
116 $ids = $this->getAllArtifactTypeIds() ;
118 foreach ($ids as $id) {
119 if (forge_check_perm ('tracker', $id, 'read')) {
120 $artifactType = new ArtifactType($this->Group, $id);
121 if($artifactType->isError()) {
122 $this->setError($artifactType->getErrorMessage());
124 $this->ArtifactTypes[] = $artifactType;
128 return $this->ArtifactTypes;
134 // c-file-style: "bsd"