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 * __construct - Artifacts constructor.
54 * Use this constructor if you are modifying an existing artifact.
56 * @param ArtifactType $ArtifactType Artifact Type object.
58 function __construct(&$ArtifactType) {
61 $this->ArtifactType =& $ArtifactType;
63 //was ArtifactType legit?
64 if (!$ArtifactType || !is_object($ArtifactType)) {
65 $this->setError('Artifact: No Valid ArtifactType');
68 //did ArtifactType have an error?
69 if ($ArtifactType->isError()) {
70 $this->setError('Artifact: '.$ArtifactType->getErrorMessage());
76 * getArtifacts - get an array of artifacts.
78 * Retrieves an array of artifact objects.
80 * @param boolean $offset Database query offset.
81 * @return array|bool An array of artifact objects on success / false on failure.
83 function getArtifacts($offset=false) {
87 $res = db_query_params ('SELECT * FROM artifact_vw WHERE group_artifact_id=$1',
88 array ($this->ArtifactType->getID()),
93 $this->setError('Could not get artifacts: ' . db_error());
96 while ($rows = db_fetch_array($res)) {
97 $this->artifacts_array[] = new Artifact($this->ArtifactType, $rows);
100 return $this->artifacts_array;
105 * getArtifactType - get the artifact type.
107 * @return ArtifactType The ArtifactType object.
109 function &getArtifactType() {
110 return $this->ArtifactType;
116 // c-file-style: "bsd"