File: ArtifactTypes.class

package info (click to toggle)
gforge 3.1-31sarge5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 9,148 kB
  • ctags: 11,865
  • sloc: sql: 27,860; php: 25,574; perl: 7,124; xml: 3,152; sh: 2,586; ansic: 315; makefile: 143
file content (242 lines) | stat: -rw-r--r-- 5,996 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
<?php
/**
 * ArtifactTypes.class - Class to handle artifact types
 *
 * SourceForge: Breaking Down the Barriers to Open Source Development
 * Copyright 1999-2001 (c) VA Linux Systems
 * http://sourceforge.net
 *
 * @version   $Id: ArtifactTypes.class,v 1.3.2.1 2004/03/31 20:08:10 lo-lan-do Exp $
 *
 * This file is part of GForge.
 *
 * GForge is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * GForge is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with GForge; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  US
 */
require_once('common/include/Error.class');
require_once('common/tracker/ArtifactType.class');
require_once('common/tracker/ArtifactGroup.class');
require_once('common/tracker/ArtifactCategory.class');

class ArtifactTypes extends Error {

	/** 
	 * The artifact type object.
	 *
	 * @var		object	$ArtifactType.
	 */
	var $Group; //group object

	/**
	 * Array of artifactTypes data.
	 *
	 * @var		array	$data_array.
	 */
	var $data_array;

	/**
	 *	ArtifactTypes - constructor.
	 *
	 *	@param	object	The Group object.
	 *	@return	boolean	success.
	 */
	function ArtifactTypes(&$Group) {
		$this->Error();
		if (!$Group || !is_object($Group)) {
			$this->setError('No Valid Group Object');
			return false;
		}
		if ($Group->isError()) {
			$this->setError('ArtifactType: '.$Group->getErrorMessage());
			return false;
		}
		$this->Group =& $Group;
		return true;
	}

	/**
	 *	createTrackers - creates all the standard trackers for a given Group.
	 *
	 *	@return	boolean	success.
	 */
	function createTrackers() {

		// first, check if trackers already exist
		$res=db_query("SELECT * FROM artifact_group_list 
			WHERE group_id='".$this->Group->getID()."' AND datatype > 0");
		if (db_numrows($res) > 0) {
			return true;
		}

		db_begin();
		if (!$this->createBugTracker()) {
			db_rollback();
			return false;
		} elseif (!$this->createSupportTracker()) {
			db_rollback();
			return false;
		} elseif (!$this->createPatchTracker()) {
			db_rollback();
			return false;
		} elseif (!$this->createFeatureTracker()) {
			db_rollback();
			return false;
		} else {
			db_commit();
			return true;
		}
	}

	/**
	 *	createBugTracker creates bug tracker.
	 *
	 *	@return	boolean	success.
	 *	@access private.
	 */
	function createBugTracker() {
		$at=new ArtifactType($this->Group);
		if (!$at || !is_object($at)) {
			$this->setError('Error Creating ArtifactType for Bug Tracker');
			return false;
		} else {
			if ($at->create('Bugs','Bug Tracking System',1,1,0,'',30,1,'','',1)) {
				//
				//	create a default category
				//	
				$ac=new ArtifactCategory($at);
				$ac->create('Interface (example)',100);

				//
				//	create a default group
				//	
				$ag=new ArtifactGroup($at);
				$ag->create('v1.0 (example)');
				return true;
			} else {
				$this->setError('Failed to create bug tracker: '.$at->getErrorMessage());
				return false;
			}
		}	  
	}

	/**
	 *	createSupportTracker creates support tracker.
	 *
	 *	@return	boolean	success.
	 *	@access private.
	 */
	function createSupportTracker() {
		$at=new ArtifactType($this->Group);
		if (!$at || !is_object($at)) {
			$this->setError('Error Creating ArtifactType for support Tracker');
			return false;
		} else {
			if ($at->create('Support Requests','Tech Support Tracking System',1,1,0,'',15,0,'','',2)) {
				//
				//  create a default category
				//  
				$ac=new ArtifactCategory($at);
				$ac->create('Install Problem (example)',100);

				//
				//  create a default group
				//  
				$ag=new ArtifactGroup($at);
				$ag->create('v1.0 (example)');
				return true;
			} else {
				$this->setError('Failed to create support tracker: '.$at->getErrorMessage());
				return false;
			}   
		}
	}

	/**
	 *	createPatchTracker creates patch tracker.
	 *
	 *	@return	boolean	success.
	 *	@access private.
	 */
	function createPatchTracker() {
		//	
		//  Set up a patch tracker for this group
		//  
		$at=new ArtifactType($this->Group);
		if (!$at || !is_object($at)) {
			$this->setError('Error Creating ArtifactType for patch Tracker');
			return false;
		} else {
			if ($at->create('Patches','Patch Tracking System',1,1,0,'',15,1,'','',3)) {
				//
				//  create a default category
				//
				$ac=new ArtifactCategory($at);
				$ac->create('Widget (example)',100);

				//  
				//  create a default group
				//
				$ag=new ArtifactGroup($at);
				$ag->create('Unstable (example)');
				return true;
			} else {
				$this->setError('Failed to create support tracker: '.$at->getErrorMessage());
				return false;
			}
		}
	}

	/**
	 *	createFeatureTracker creates feature tracker.
	 *
	 *	@return	boolean	success.
	 *	@access private.
	 */
	function createFeatureTracker() {
		//	
		//  Set up a feature request tracker for this group
		//	
		$at=new ArtifactType($this->Group);
		if (!$at || !is_object($at)) {
			$this->setError('Error Creating ArtifactType for feature Tracker');
			return false;
		} else {
			if ($at->create('Feature Requests','Feature Request Tracking System',1,1,0,'',45,0,'','',4)) {
				//
				//  create a default category
				//
				$ac=new ArtifactCategory($at);
				$ac->create('Interface Improvements (example)',100);

				//  
				//  create a default group
				//
				$ag=new ArtifactGroup($at);
				$ag->create('Next Release (example)');
				return true;
			} else {
				$this->setError('Failed to create support tracker: '.$at->getErrorMessage());
				return false;
			}
		}
	}

}

// Local Variables:
// mode: php
// c-file-style: "bsd"
// End:

?>