artifactgroup.class
来自「GForge 3.0 协作开发平台 支持CVS, mailing lists, 」· CLASS 代码 · 共 197 行
CLASS
197 行
<?php/** * ArtifactGroup.class - Class to artifact groups * * SourceForge: Breaking Down the Barriers to Open Source Development * Copyright 1999-2001 (c) VA Linux Systems * http://sourceforge.net * * @version $Id: ArtifactGroup.class,v 1.4 2001/06/07 20:15:23 dbrogdon 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');class ArtifactGroup extends Error { /** * Artifact type object. * * @var object $ArtifactType. */ var $ArtifactType; /** * Array of artifactGroup data. * * @var array $data_array. */ var $data_array; /** * ArtifactGroup - constructor. * * @param object Artifact type object. * @param array (all fields from artifact_group) OR id from database. * @return boolean success. */ function ArtifactGroup(&$ArtifactType, $data=false) { $this->Error(); //was ArtifactType legit? if (!$ArtifactType || !is_object($ArtifactType)) { $this->setError('ArtifactGroup: No Valid ArtifactType'); return false; } //did ArtifactType have an error? if ($ArtifactType->isError()) { $this->setError('ArtifactGroup: '.$Artifact->getErrorMessage()); return false; } $this->ArtifactType =& $ArtifactType; if ($data) { if (is_array($data)) { $this->data_array =& $data; return true; } else { if (!$this->fetchData($data)) { return false; } else { return true; } } } } /** * create - create a new item in the database. * * @param string Item name. * @return id on success / false on failure. */ function create($name) { global $Language; // // data validation // if (!$name) { $this->setError($Language->getText('tracker_artifactgroup','required_field')); return false; } if (!$this->ArtifactType->userIsAdmin()) { $this->setPermissionDeniedError(); return false; } $sql="INSERT INTO artifact_group (group_artifact_id,group_name) VALUES ('".$this->ArtifactType->getID()."','".htmlspecialchars($name)."')"; $result=db_query($sql); if ($result && db_affected_rows($result) > 0) { return true; } else { $this->setError(db_error()); return false; }/* // // Now set up our internal data structures // if (!$this->fetchData($id)) { return false; }*/ } /** * fetchData - re-fetch the data for this ArtifactGroup from the database. * * @param int Data ID. * @return boolean success. */ function fetchData($id) { $res=db_query("SELECT * FROM artifact_group WHERE id='$id'"); if (!$res || db_numrows($res) < 1) { $this->setError('ArtifactGroup: Invalid ArtifactGroup ID'); return false; } $this->data_array =& db_fetch_array($res); db_free_result($res); return true; } /** * getArtifactType - get the ArtifactType Object this ArtifactGroup is associated with. * * @return object ArtifactType. */ function &getArtifactType() { return $this->ArtifactType; } /** * getID - get this ArtifactGroup's ID. * * @return int The id #. */ function getID() { return $this->data_array['id']; } /** * getName - get the name. * * @return string name. */ function getName() { return $this->data_array['group_name']; } /** * update - update an ArtifactGroup. * * @param string Name of the group. * @return boolean success. */ function update($name) { if (!$this->ArtifactType->userIsAdmin()) { $this->setPermissionDeniedError(); return false; } if (!$name) { $this->setMissingParamsError(); return false; } $sql="UPDATE artifact_group SET group_name='".htmlspecialchars($name)."' WHERE id='". $this->getID() ."' AND group_artifact_id='". $this->ArtifactType->getID() ."'"; $result=db_query($sql); if ($result && db_affected_rows($result) > 0) { return true; } else { $this->setError(db_error()); return false; } }}?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?