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
54 * @param object The Group object to which this ArtifactTypeFactory is associated
55 * @return boolean success.
57 function __construct(&$Group) {
59 if (!$Group || !is_object($Group)) {
60 $this->setError('ArtifactTypeFactory:: No Valid Group Object');
63 if ($Group->isError()) {
64 $this->setError('ArtifactTypeFactory:: '.$Group->getErrorMessage());
67 if (!$Group->usesTracker()) {
68 $this->setError(sprintf(_('%s does not use the Tracker tool'),
69 $Group->getPublicName()));
72 $this->Group =& $Group;
78 * getGroup - get the Group object this ArtifactType is associated with.
80 * @return object The Group object.
82 function &getGroup() {
87 * getAllArtifactTypeIds - return a list of tracker ids.
89 * @return array The array of ArtifactType objects.
91 function &getAllArtifactTypeIds() {
93 $res = db_query_params ('SELECT * FROM artifact_group_list_vw
95 ORDER BY group_artifact_id ASC',
96 array ($this->Group->getID())) ;
100 while ($arr = db_fetch_array($res)) {
101 $result[] = $arr['group_artifact_id'] ;
107 * getArtifactTypes - return an array of ArtifactType objects.
109 * @return array The array of ArtifactType objects.
111 function getArtifactTypes() {
112 if ($this->ArtifactTypes) {
113 return $this->ArtifactTypes;
116 $this->ArtifactTypes = array () ;
117 $ids = $this->getAllArtifactTypeIds() ;
119 foreach ($ids as $id) {
120 if (forge_check_perm ('tracker', $id, 'read')) {
121 $artifactType = new ArtifactType($this->Group, $id);
122 if($artifactType->isError()) {
123 $this->setError($artifactType->getErrorMessage());
125 $this->ArtifactTypes[] = $artifactType;
129 return $this->ArtifactTypes;
135 // c-file-style: "bsd"