3 * ArtifactHistory.class - 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');
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) {
92 if (!$name || !$auto_assign_to) {
93 $this->setError(_('ArtifactCategory: name and assignee are Required'));
96 if (!$this->Artifact->userIsAdmin()) {
97 $this->setPermissionDeniedError();
100 $sql="INSERT INTO artifact_category (group_artifact_id,category_name,auto_assign_to)
101 VALUES ('".$this->Artifact->getID()."','".htmlspecialchars($name)."','$auto_assign_to')";
103 $result=db_query($sql);
105 if ($result && db_affected_rows($result) > 0) {
109 $this->setError(db_error());
113 // Now set up our internal data structures
114 if (!$this->fetchData($id)) {
120 * fetchData - re-fetch the data for this ArtifactHistory from the database.
122 * @param int ID of the category.
123 * @return boolean success.
125 function fetchData($id) {
126 $res=db_query("SELECT * FROM artifact_category WHERE id='$id'");
127 if (!$res || db_numrows($res) < 1) {
128 $this->setError('ArtifactHistory: Invalid ArtifactHistory ID');
131 $this->data_array =& db_fetch_array($res);
132 db_free_result($res);
137 * getArtifact - get the Artifact Object this ArtifactHistory is associated with.
139 * @return object Artifact.
141 function &getArtifact() {
142 return $this->Artifact;
146 * getID - get this ArtifactHistory's ID.
148 * @return int The id #.
151 return $this->data_array['id'];
155 * getName - get the name.
157 * @return string The name.
160 return $this->data_array['category_name'];
164 * getAssignee - get the user_id of the person to assign this category to.
166 * @return int user_id.
168 function getAssignee() {
169 return $this->data_array['auto_assign_to'];