5 * Copyright 1999-2001, VA Linux Systems, Inc.
6 * Copyright 2002-2004, GForge, LLC
8 * This file is part of FusionForge.
10 * FusionForge is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published
12 * by the Free Software Foundation; either version 2 of the License,
13 * or (at your option) any later version.
15 * FusionForge is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with FusionForge; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
26 require_once $gfcommon.'include/Error.class.php';
27 require_once $gfcommon.'tracker/ArtifactType.class.php';
28 require_once $gfcommon.'tracker/ArtifactExtraField.class.php';
30 class ArtifactTypes extends Error {
33 * The artifact type object.
35 * @var object $ArtifactType.
37 var $Group; //group object
40 * Array of artifactTypes data.
42 * @var array $data_array.
47 * ArtifactTypes - constructor.
49 * @param object The Group object.
50 * @return boolean success.
52 function ArtifactTypes(&$Group) {
54 if (!$Group || !is_object($Group)) {
55 $this->setError('No Valid Group Object');
58 if ($Group->isError()) {
59 $this->setError('ArtifactType: '.$Group->getErrorMessage());
62 $this->Group =& $Group;
67 * createTrackers - creates all the standard trackers for a given Group.
69 * @return boolean success.
71 function createTrackers() {
73 // first, check if trackers already exist
74 $res=db_query("SELECT * FROM artifact_group_list
75 WHERE group_id='".$this->Group->getID()."' AND datatype > 0");
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)) {
86 $this->setError('Error Getting Tracker Object');
92 if (!$at->create(addslashes($trk[0]), addslashes($trk[1]), $trk[2], $trk[3], $trk[4], $trk[5], $trk[6], $trk[7], $trk[8], $trk[9], $trk[10])) {
94 $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(addslashes($fld[0]), $fld[1], $fld[2], $fld[3], $fld[4])) {
105 $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(addslashes($el_name),$el_status)) {
129 $this->setError('Error Creating Extra Field Element: '.$aefe->getErrorMessage());
146 // c-file-style: "bsd"