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/FFError.class.php';
26 require_once $gfcommon.'tracker/ArtifactType.class.php';
28 class ArtifactTypeFactory extends FFError {
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, $skip_check=false) {
58 if (!$Group || !is_object($Group)) {
59 $this->setError(_('No Valid Group Object'));
62 if ($Group->isError()) {
63 $this->setError('ArtifactTypeFactory: '.$Group->getErrorMessage());
66 if (!$skip_check && !$Group->usesTracker()) {
67 $this->setError(sprintf(_('%s does not use the Tracker tool'),
68 $Group->getPublicName()));
71 $this->Group =& $Group;
75 * getGroup - get the Group object this ArtifactType is associated with.
77 * @return object The Group object.
79 function &getGroup() {
84 * getAllArtifactTypeIds - return a list of tracker ids.
86 * @return array The array of ArtifactType object ids.
88 function &getAllArtifactTypeIds() {
90 $res = db_query_params ('SELECT group_artifact_id FROM artifact_group_list_vw
92 ORDER BY group_artifact_id ASC',
93 array ($this->Group->getID())) ;
97 while ($arr = db_fetch_array($res)) {
98 $result[] = $arr['group_artifact_id'] ;
104 * getArtifactTypes - return an array of ArtifactType objects.
106 * @return array The array of ArtifactType objects.
108 function getArtifactTypes() {
109 if ($this->ArtifactTypes) {
110 return $this->ArtifactTypes;
113 $this->ArtifactTypes = array () ;
114 $ids = $this->getAllArtifactTypeIds() ;
116 foreach ($ids as $id) {
117 if (forge_check_perm ('tracker', $id, 'read')) {
118 $artifactType = new ArtifactType($this->Group, $id);
119 if($artifactType->isError()) {
120 $this->setError($artifactType->getErrorMessage());
122 $this->ArtifactTypes[] = $artifactType;
126 return $this->ArtifactTypes;
132 // c-file-style: "bsd"