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

📄 projectgroup.class

📁 GForge 3.0 协作开发平台 支持CVS, mailing lists, bug tracking, message boards/forums, task management, perman
💻 CLASS
字号:
<?php/** * GForge Project Management Facility * * Copyright 2002 GForge, LLC * http://gforge.org/ * * @version   $Id: ProjectGroup.class,v 1.8 2003/02/12 17:23:47 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  US *//*	Project/Task Manager	By Tim Perdue, Sourceforge, 11/99	Heavy rewrite by Tim Perdue April 2000	Total rewrite in OO and GForge coding guidelines 12/2002 by Tim Perdue*/require_once('common/include/Error.class');class ProjectGroup extends Error {	/**	 * Associative array of data from db.	 *	 * @var	 array   $data_array.	 */	var $data_array;	/**	 * The Group object.	 *	 * @var	 object  $Group.	 */	var $Group;	var $statuses;	var $categories;	var $technicians;	/**	 *  Constructor.	 *	 *	@param	object	The Group object to which this forum is associated.	 *  @param  int	 The group_project_id.	 *  @param  array	The associative array of data.	 *	@return	boolean	success.	 */	function ProjectGroup(&$Group, $group_project_id=false, $arr=false) {		$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;		if ($group_project_id) {			if (!$arr || !is_array($arr)) {				if (!$this->fetchData($group_project_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');					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;				}			}		}		return true;	}	/**	 *	create - create a new ProjectGroup in the database.	 *	 *	@param	string	The project name.	 *	@param	string	The project description.	 *	@param	int	Whether it is (1) public or (0) private .	 *	@param	string	The email address to send new notifications to.	 *	@return boolean success.	 */	function create($project_name,$description,$is_public=1,$send_all_posts_to='') {		global $Language;				if (strlen($project_name) < 3) {			$this->setError($Language->getText('pm_projectgroup','error_min_name_length'));			return false;		}		if (strlen($description) < 10) {			$this->setError($Language->getText('pm_projectgroup','error_min_desc_length'));			return false;		}		if ($send_all_posts_to && !validate_email($send_all_posts_to)) {			$this->setInvalidEmailError();			return false;		}		$perm =& $this->Group->getPermission( session_get_user() );		if (!$perm || !is_object($perm) || !$perm->isPMAdmin()) {			$this->setPermissionDeniedError();			return false;		}		$sql="INSERT INTO project_group_list (group_id,project_name,is_public,			description,send_all_posts_to)			VALUES ('".$this->Group->getId()."','". htmlspecialchars($project_name) ."','$is_public',			'". htmlspecialchars($description) ."','$send_all_posts_to')";		db_begin();		$result=db_query($sql);		if (!$result) {			db_rollback();			$this->setError('Error Adding ProjectGroup: '.db_error());			return false;		}		$this->group_project_id=db_insertid($result,'project_group_list','group_project_id');		$this->fetchData($this->group_project_id);		db_commit();		return true;	}	/**	 *  fetchData - re-fetch the data for this ProjectGroup from the database.	 *	 *  @param  int	 The project group ID.	 *  @return	boolean	success.	 */	function fetchData($group_project_id) {		$res=db_query("SELECT * FROM project_group_list			WHERE group_project_id='$group_project_id'			AND group_id='". $this->Group->getID() ."'");		if (!$res || db_numrows($res) < 1) {			$this->setError('ProjectGroup:: Invalid group_project_id');			return false;		}		$this->data_array =& db_fetch_array($res);		db_free_result($res);		return true;	}	/**	 *	getGroup - get the Group object this ProjectGroup is associated with.	 *	 *	@return	object	The Group object.	 */	function &getGroup() {		return $this->Group;	}	/**	 *	getID - get this GroupProjectID.	 *	 *	@return	int	The group_project_id #.	 */	function getID() {		return $this->data_array['group_project_id'];	}	/**	 *	isPublic - Is this projectGroup open to the general public.	 *	 *	@return boolean	allow.	 */	function isPublic() {		return $this->data_array['is_public'];	}	/**	 *	getName - get the name of this projectGroup.	 *	 *	@return string	The name of this projectGroup.	 */	function getName() {		return $this->data_array['project_name'];	}	/**	 *	getSendAllPostsTo - an optional email address to send all task updates to.	 *	 *	@return string	The email address.	 */	function getSendAllPostsTo() {		return $this->data_array['send_all_posts_to'];	}	/**	 *	getDescription - the description of this ProjectGroup.	 *	 *	@return string	The description.	 */	function getDescription() {		return $this->data_array['description'];	}	/**	 *	getTaskCount - the total number of tasks in this ProjectGroup.	 *	 *	@return int	The count.	 * /	function getTaskCount() {		return $this->data_array['total'];	}*/	/**	 * getStatuses - Return result set of statuses.	 *	 * @returns Database result set.	 */	function getStatuses () {		if (!$this->statuses) {			$sql='SELECT * FROM project_status';			$this->statuses=db_query($sql);		}		return $this->statuses;	}	/**	 * getCategories - Return result set of categories.	 *	 * @returns Database result set.	 */	function getCategories () {		if (!$this->categories) {			$sql="SELECT category_id,category_name 				FROM project_category 				WHERE group_project_id='".$this->getID()."'";			$this->categories=db_query($sql);		}		return $this->categories;	}	/**	 * getTechnicians - Return a result set of pm technicians in this group.	 *	 * @returns Datbase result set.	 */	function getTechnicians () {		if (!$this->technicians) {			$sql="SELECT users.user_id,users.realname 				FROM users,user_group 				WHERE users.user_id=user_group.user_id 				AND user_group.group_id='". $this->Group->getID() ."' 				AND user_group.project_flags IN (1,2) 				ORDER BY users.user_name";			$this->technicians=db_query($sql);		}		return $this->technicians;	}	/**	 *	create - create a new ProjectGroup in the database.	 *	 *	@param	string	The project name.	 *	@param	string	The project description.	 *	@param	int	Whether it is (1) public or (0) private .	 *	@param	string	The email address to send new notifications to.	 *	@return boolean success.	 */	function update($project_name,$description,$is_public=1,$send_all_posts_to='') {		global $Language;		if (strlen($project_name) < 3) {			$this->setError($Language->getText('pm_projectgroup','error_min_name_length'));			return false;		}		if (strlen($description) < 10) {			$this->setError($Language->getText('pm_projectgroup','error_min_desc_length'));			return false;		}		if ($send_all_posts_to && !validate_email($send_all_posts_to)) {			$this->setInvalidEmailError();			return false;		}		$perm =& $this->Group->getPermission( session_get_user() );		if (!$perm || !is_object($perm) || !$perm->isPMAdmin()) {			$this->setPermissionDeniedError();			return false;		}		$res=db_query("UPDATE project_group_list SET			project_name='". htmlspecialchars($project_name) ."',			description='". htmlspecialchars($description) ."',			is_public='$is_public',			send_all_posts_to='$send_all_posts_to'			WHERE group_id='".$this->Group->getID()."'			AND group_project_id='".$this->getID()."'");		if (!$res || db_affected_rows($res) < 1) {			$this->setError('Error On Update: '.db_error());			return false;		}		return true;	}}?>

⌨️ 快捷键说明

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