3 * ArtifactHistory.class.php - Class to handle artifact history (unused-waiting for SOAP)
5 * Copyright 2004 (c) GForge, LLC
9 * This file is part of GForge.
11 * GForge is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * GForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with GForge; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 US
25 require_once('common/include/Error.class.php');
27 class ArtifactHistory extends Error {
30 * The artifact object.
32 * @var object $Artifact.
34 var $Artifact; //object
37 * Array of artifact data.
39 * @var array $data_array.
44 * ArtifactHistory - constructor.
46 * @param object Artifact object.
47 * @param array (all fields from artifact_history_user_vw) OR id from database.
48 * @return boolean success.
50 function ArtifactHistory(&$Artifact, $data=false) {
54 if (!$Artifact || !is_object($Artifact)) {
55 $this->setError('ArtifactHistory: No Valid Artifact');
58 //did Artifact have an error?
59 if ($Artifact->isError()) {
60 $this->setError('ArtifactHistory: '.$Artifact->getErrorMessage());
63 $this->Artifact =& $Artifact;
66 if (is_array($data)) {
67 $this->data_array =& $data;
70 if (!$this->fetchData($data)) {
80 * create - create a new item in the database.
82 * @param string Item name.
83 * @param int User_id of assignee.
84 * @return id on success / false on failure.
86 function create($name, $auto_assign_to) {
90 if (!$name || !$auto_assign_to) {
91 $this->setError(_('ArtifactCategory: name and assignee are Required'));
94 if (!$this->Artifact->userIsAdmin()) {
95 $this->setPermissionDeniedError();
98 $sql="INSERT INTO artifact_category (group_artifact_id,category_name,auto_assign_to)
99 VALUES ('".$this->Artifact->getID()."','".htmlspecialchars($name)."','$auto_assign_to')";
101 $result=db_query($sql);
103 if ($result && db_affected_rows($result) > 0) {
107 $this->setError(db_error());
111 // Now set up our internal data structures
112 if (!$this->fetchData($id)) {
118 * fetchData - re-fetch the data for this ArtifactHistory from the database.
120 * @param int ID of the category.
121 * @return boolean success.
123 function fetchData($id) {
124 $res=db_query("SELECT * FROM artifact_category WHERE id='$id'");
125 if (!$res || db_numrows($res) < 1) {
126 $this->setError('ArtifactHistory: Invalid ArtifactHistory ID');
129 $this->data_array =& db_fetch_array($res);
130 db_free_result($res);
135 * getArtifact - get the Artifact Object this ArtifactHistory is associated with.
137 * @return object Artifact.
139 function &getArtifact() {
140 return $this->Artifact;
144 * getID - get this ArtifactHistory's ID.
146 * @return int The id #.
149 return $this->data_array['id'];
153 * getName - get the name.
155 * @return string The name.
158 return $this->data_array['category_name'];
162 * getAssignee - get the user_id of the person to assign this category to.
164 * @return int user_id.
166 function getAssignee() {
167 return $this->data_array['auto_assign_to'];
174 // c-file-style: "bsd"