5 * Copyright 1999-2001, VA Linux Systems, Inc.
6 * Copyright 2002-2004, GForge, LLC
7 * Copyright 2009, Roland Mas
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';
27 require_once $gfcommon.'tracker/ArtifactExtraField.class.php';
29 class ArtifactTypes extends Error {
32 * The artifact type object.
34 * @var object $ArtifactType.
36 var $Group; //group object
39 * Array of artifactTypes data.
41 * @var array $data_array.
46 * ArtifactTypes - constructor.
48 * @param object The Group object.
49 * @return boolean success.
51 function ArtifactTypes(&$Group) {
53 if (!$Group || !is_object($Group)) {
54 $this->setError('No Valid Group Object');
57 if ($Group->isError()) {
58 $this->setError('ArtifactType: '.$Group->getErrorMessage());
61 $this->Group =& $Group;
66 * createTrackers - creates all the standard trackers for a given Group.
68 * @return boolean success.
70 function createTrackers() {
72 // first, check if trackers already exist
73 $res = db_query_params ('SELECT * FROM artifact_group_list
74 WHERE group_id=$1 AND datatype > 0',
75 array ($this->Group->getID()));
76 if (db_numrows($res) > 0) {
80 include $GLOBALS['gfcommon'].'tracker/artifact_type_definitions.php';
82 foreach ($trackers as $trk) {
83 $at = new ArtifactType($this->Group);
84 if (!$at || !is_object($at)) {
85 $this->setError('Error Getting Tracker Object');
92 if (!$at->create($trk[0], $trk[1], $trk[2], $trk[3], $trk[4], $trk[5], $trk[6], $trk[7], $trk[8], $trk[9], $trk[10])) {
93 $this->setError('Error Creating Tracker: '.$at->getErrorMessage());
98 // Create each field in the tracker
100 foreach ($trk[11] AS $fld) {
101 $aef = new ArtifactExtraField($at);
102 //print($fld[0])."***|";
103 if (!$aef->create($fld[0], $fld[1], $fld[2], $fld[3], $fld[4])) {
104 $this->setError('Error Creating Extra Field: '.$aef->getErrorMessage());
109 // create each element in the field
111 foreach ($fld[5] AS $el) {
114 $aefe = new ArtifactExtraFieldElement($aef);
115 /* Allow us to provide a list as an element
116 value - in doing so, we can provide a
117 status field value for people wanting to
118 set up custom statuses. The first element
119 of any given array is the name, the second
120 is the status_id (0, 1 or 2)*/
123 if (is_array($el) && $fld[1] == ARTIFACT_EXTRAFIELDTYPE_STATUS) {
127 if (!$aefe->create($el_name,$el_status)) {
128 $this->setError('Error Creating Extra Field Element: '.$aefe->getErrorMessage());
147 // c-file-style: "bsd"