⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 documentfactory.class

📁 GForge 3.0 协作开发平台 支持CVS, mailing lists, bug tracking, message boards/forums, task management, perman
💻 CLASS
字号:
<?php/** * GForge Doc Mgr Facility * * Copyright 2002 GForge, LLC * http://gforge.org/ * * @version   $Id: DocumentFactory.class,v 1.5 2003/02/12 17:23:46 bigdisk 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  USA *//*	Document Manager	by Quentin Cregan, SourceForge 06/2000	Complete OO rewrite by Tim Perdue 1/2003*/require_once('common/include/Error.class');require_once('common/docman/Document.class');class DocumentFactory extends Error {	/**	 * The Group object.	 *	 * @var	 object  $Group.	 */	var $Group;	/**	 * The Documents array.	 *	 * @var	 array	Documents.	 */	var $Documents;	var $stateid;	var $languageid;	var $docgroupid;	var $sort='doc_group';	/**	 *  Constructor.	 *	 *	@param	object	The Group object to which this DocumentFactory is associated.	 *	@return	boolean	success.	 */	function DocumentFactory(&$Group) {		$this->Error();		if (!$Group || !is_object($Group)) {			$this->setError('ProjectGroup:: No Valid Group Object');			return false;		}		if ($Group->isError()) {			$this->setError('ProjectGroup:: '.$Group->getErrorMessage());			return false;		}		$this->Group =& $Group;		return true;	}	/**	 *	getGroup - get the Group object this DocumentFactory is associated with.	 *	 *	@return object	the Group object.	 */	function &getGroup() {		return $this->Group;	}	/**	 *	setStateID - call this before getDocuments() if you want to limit to a specific state.	 *	 *	@param	int	The stateid from the doc_states table.	 */	function setStateID($stateid) {		$this->stateid=$stateid;	}	/**	 *	setLanguageID - call this before getDocuments() if you want to limit to a specific language.	 *	 *	@param	int	The language_id from the supported_languages table.	 */	function setLanguageID($languageid) {		$this->languageid=$languageid;	}	/**	 *	setDocGroupID - call this before getDocuments() if you want to limit to a specific doc_group.	 *	 *	@param	int	The doc_group from the doc_groups table.	 */	function setDocGroupID($docgroupid) {		$this->docgroupid=$docgroupid;	}	/**	 *	setSort - call this before getDocuments() if you want to control the sorting.	 *	 *	@param	string	The name of the field to sort on.	 */	function setSort($sort) {		$this->sort=$sort;	}	/**	 *	getDocuments - returns an array of Document objects.	 *	 *	@return	array	Document objects.	 */	function &getDocuments() {		global $Language;		if ($this->Documents) {			return $this->Documents;		}		if (!$this->stateid) {			if (session_loggedin()) {				$perm =& $this->Group->getPermission( session_get_user() );				if (!$perm || !is_object($perm) || !$perm->isMember()) {					$public_flag='AND stateid=1';				} else {					$public_flag='AND stateid IN (1,4,5)';				}			} else {				$public_flag='AND stateid=1';			}		} else {			if ($this->stateid =='ALL') {			} else {				$public_flag='AND stateid =\''.$this->stateid.'\'';			}		}		if ($this->docgroupid) {			$docgroupsql="AND doc_group='".$this->docgroupid."'";		}		if ($this->languageid) {			$languagesql="AND language_id='".$this->languageid."'";		}		$sql="SELECT *			FROM docdata_vw			WHERE group_id='". $this->Group->getID() ."' 			$public_flag 			$docgroupsql			$languagesql			ORDER BY ".$this->sort;		$result = db_query ($sql);//echo "$sql<br>".db_error();		$rows = db_numrows($result);		if (!$result || $rows < 1) {			$this->setError($Language->getText('docman_common','no_docs')." ".db_error());			return false;		} else {			while ($arr =& db_fetch_array($result)) {				$this->Documents[] = new Document($this->Group, $arr['docid'], $arr);			}		}		return $this->Documents;	}}?>

⌨️ 快捷键说明

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