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/Artifact.class.php';
28 class Artifacts extends Error {
31 * Status db resource ID.
33 * @var int $status_res.
38 * Artifact Type object.
40 * @var object $ArtifactType.
45 * Array of Artifact objects.
47 * @var array $artifacts_array.
52 * Artifacts - constructor.
54 * Use this constructor if you are modifying an existing artifact.
56 * @param object Artifact Type object.
57 * @param int (primary key from database).
58 * @return boolean success.
60 function __construct(&$ArtifactType) {
63 $this->ArtifactType =& $ArtifactType;
65 //was ArtifactType legit?
66 if (!$ArtifactType || !is_object($ArtifactType)) {
67 $this->setError('Artifact: No Valid ArtifactType');
70 //did ArtifactType have an error?
71 if ($ArtifactType->isError()) {
72 $this->setError('Artifact: '.$ArtifactType->getErrorMessage());
79 * getArtifacts - get an array of artifacts.
81 * Retrieves an array of artifact objects.
83 * @param boolean Database query offset.
84 * @return an array of artifact objects on success / false on failure.
86 function getArtifacts($offset=false) {
90 $res = db_query_params ('SELECT * FROM artifact_vw WHERE group_artifact_id=$1',
91 array ($this->ArtifactType->getID()),
96 $this->setError('Could not get artifacts: ' . db_error());
99 while ($rows = db_fetch_array($res)) {
100 $this->artifacts_array[] = new Artifact($this->ArtifactType, $rows);
103 return $this->artifacts_array;
108 * getArtifactType - get the artifact type.
110 * @return object The ArtifactType object.
112 function &getArtifactType() {
113 return $this->ArtifactType;
119 // c-file-style: "bsd"