artifacttype.class

来自「GForge 3.0 协作开发平台 支持CVS, mailing lists, 」· CLASS 代码 · 共 720 行 · 第 1/2 页

CLASS
720
字号
<?php/** * ArtifactType.class - Class to artifact an type * * SourceForge: Breaking Down the Barriers to Open Source Development * Copyright 1999-2001 (c) VA Linux Systems * http://sourceforge.net * * @version   $Id: ArtifactType.class,v 1.8 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 ArtifactType extends Error {	/**	 * The Group object.	 *	 * @var		object	$Group.	 */	var $Group; //group object	/**	 * Categories db resource ID.	 *	 * @var		int		$categories_res.	 */	var $categories_res;	/**	 * Resolutions db resource ID.	 *	 * @var		int		$resolutions_res.	 */	var $resolutions_res;	/**	 * Groups db resource ID.	 *	 * @var		int		$groups_res.	 */	var $groups_res;	/**	 * Current user permissions.	 *	 * @var		int		$current_user_perm.	 */	var $current_user_perm;	/**	 * Technicians db resource ID.	 *	 * @var		int		$technicians_res.	 */	var $technicians_res;	/**	 * Status db resource ID.	 *	 * @var		int		$status_res.	 */	var $status_res;	/**	 * Canned responses resource ID.	 *	 * @var		int		$cannecresponses_res.	 */	var $cannedresponses_res;	/**	 * Array of artifact data.	 *	 * @var		array	$data_array.	 */	var $data_array;	/**	 *	ArtifactType - constructor.	 *	 *	@param	object	The Group object.	 *	@param	int		The id # assigned to this artifact type in the db.	 *  @param	array	The associative array of data.	 *	@return boolean	success.	 */	function ArtifactType(&$Group,$artifact_type_id=false, $arr=false) {		$this->Error();		if (!$Group || !is_object($Group)) {			$this->setError('No Valid Group Object');			return false;		}		if ($Group->isError()) {			$this->setError('ArtifactType: '.$Group->getErrorMessage());			return false;		}		$this->Group =& $Group;		if ($artifact_type_id) {			if (!$arr || !is_array($arr)) {				if (!$this->fetchData($artifact_type_id)) {					return false;				}			} else {				$this->data_array =& $arr;				if ($this->data_array['group_id'] != $this->Group->getID()) {					$this->setError('Group_id in db result does not match Group Object');					$this->data_array = null;					return false;				}			}			if (!$this->isPublic()) {	                	$perm =& $this->Group->getPermission( session_get_user() );			        if (!$perm || !is_object($perm) || !$perm->isMember()) {	                		$this->setPermissionDeniedError();					$this->data_array = null;	                		return false;				}			}		}	}	/**	 *	create - use this to create a new ArtifactType in the database.	 *	 *	@param	string	The type name.	 *	@param	string	The type description.	 *	@param	bool	(1) true (0) false - viewable by general public.	 *	@param	bool	(1) true (0) false - whether non-logged-in users can submit.	 *	@param	bool	(1) true (0) false - whether to email on all updates.	 *	@param	string	The address to send new entries and updates to.	 *	@param	int		Days before this item is considered overdue.	 *	@param	bool	(1) trye (0) false - whether the resolution box should be shown.	 *	@param	string	Free-form string that project admins can place on the submit page.	 *	@param	string	Free-form string that project admins can place on the browse page.	 *	@param	int		(1) bug tracker, (2) Support Tracker, (3) Patch Tracker, (4) features (0) other.	 *	@return id on success, false on failure.	 */	function create($name,$description,$is_public,$allow_anon,$email_all,$email_address,		$due_period,$use_resolution,$submit_instructions,$browse_instructions,$datatype=0) {		global $Language;		$perm =& $this->Group->getPermission( session_get_user() );		if (!$perm || !is_object($perm) || !$perm->isArtifactAdmin()) {			$this->setPermissionDeniedError();			return false;		}		if (!$name || !$description || !$due_period) {			$this->setError($Language->getText('tracker_artifacttype','required_fields'));			return false;		}		if ($email_address && !validate_email($email_address)) {			$email_address='';		}		if ($email_all && !$email_address) {			$email_all=0;		}                $use_resolution = ((!$use_resolution) ? 0 : $use_resolution);                $is_public = ((!$is_public) ? 0 : $is_public);                $allow_anon = ((!$allow_anon) ? 0 : $allow_anon);                $email_all = ((!$email_all) ? 0 : $email_all);		$sql="INSERT INTO 			artifact_group_list 			(group_id,			name,			description,			is_public,			allow_anon,			email_all_updates,			email_address,			due_period,			status_timeout,			use_resolution,			submit_instructions,			browse_instructions,			datatype) 			VALUES 			('". $this->Group->getID() ."',			'". htmlspecialchars($name) ."',			'". htmlspecialchars($description) ."',			'$is_public',			'$allow_anon',			'$email_all',			'$email_address',			'". ($due_period*(60*60*24)) ."',			'1209600',			'$use_resolution',			'".htmlspecialchars($submit_instructions)."',			'".htmlspecialchars($browse_instructions)."',			'$datatype')";		//echo $sql;		$res = db_query($sql);		db_begin();		$id = db_insertid($res,'artifact_group_list','group_artifact_id');				if (!$res || !$id) {			$this->setError('ArtifactType: '.db_error());			db_rollback();			return false;		} else {			if (!$this->fetchData($id)) {				db_rollback();				return false;			} else {				db_commit();				return $id;			}		}	}	/**	 *  fetchData - re-fetch the data for this ArtifactType from the database.	 *	 *  @param	int		The artifact type ID.	 *  @return boolean	success.	 */	function fetchData($artifact_type_id) {		$res=db_query("SELECT * FROM artifact_group_list_vw			WHERE group_artifact_id='$artifact_type_id' 			AND group_id='". $this->Group->getID() ."'");		if (!$res || db_numrows($res) < 1) {			$this->setError('ArtifactType: Invalid ArtifactTypeID');			return false;		}		$this->data_array =& db_fetch_array($res);		db_free_result($res);		return true;	}	/**	 *	  getGroup - get the Group object this ArtifactType is associated with.	 *	 *	  @return	Object	The Group object.	 */	function &getGroup() {		return $this->Group;	}	/**	 *	  getID - get this ArtifactTypeID.	 *	 *	  @return	int	The group_artifact_id #.	 */	function getID() {		return $this->data_array['group_artifact_id'];	}	/**	 *	  getOpenCount - get the count of open tracker items in this tracker type.	 *	 *	  @return	int	The count.	 */	function getOpenCount() {		return $this->data_array['open_count'];	}	/**	 *	  getTotalCount - get the total number of tracker items in this tracker type.	 *	 *	  @return	int	The total count.	 */	function getTotalCount() {		return $this->data_array['count'];	}	/**	 *	  allowsAnon - determine if non-logged-in users can post.	 *	 *	  @return	boolean	allow_anonymous_submissions.	 */	function allowsAnon() {		return $this->data_array['allow_anon'];	}	/**	 *	  getSubmitInstructions - get the free-form string strings.	 *	 *	  @return	string	instructions.	 */	function getSubmitInstructions() {		return $this->data_array['submit_instructions'];	}	/**	 *	  getBrowseInstructions - get the free-form string strings.	 *	 *	  @return string instructions.	 */	function getBrowseInstructions() {		return $this->data_array['browse_instructions'];	}	/**	 *	  emailAll - determine if we're supposed to email on every event.	 *	 *	  @return	boolean	email_all.	 */	function emailAll() {		return $this->data_array['email_all_updates'];	}	/**	 *	  emailAddress - defined email address to send events to.	 *	 *	  @return	string	email.	 */	function getEmailAddress() {		return $this->data_array['email_address'];	}	/**	 *	  isPublic - whether non-group-members can view.	 *	 *	  @return boolean	is_public.	 */	function isPublic() {		return $this->data_array['is_public'];	}	/**	 *	  getName - the name of this ArtifactType.	 *	 *	  @return	string	name.	 */	function getName() {		return $this->data_array['name'];	}	/**	 *	  getDescription - the description of this ArtifactType.	 *	 *	  @return	string	description.	 */	function getDescription() {		return $this->data_array['description'];	}	/**	 *	  getDuePeriod - how many seconds until it's considered overdue.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?