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

📄 group.class

📁 GForge 3.0 协作开发平台 支持CVS, mailing lists, bug tracking, message boards/forums, task management, perman
💻 CLASS
📖 第 1 页 / 共 3 页
字号:
	 */	function setStatus(&$user, $status) {		global $Language;		$perm =& $this->getPermission($user);		if (!$perm || !is_object($perm)) {			$this->setError($Language->getText('general','permnotget'));			return false;		}		if (!$perm->isSuperUser()) {			$this->setError($Language->getText('general','permdenied'));			return false;		}		//	Projects in 'A' status can only go to 'H' or 'D'		//	Projects in 'D' status can only go to 'A'		//	Projects in 'P' status can only go to 'A' OR 'D'		//	Projects in 'I' status can only go to 'P'		//	Projects in 'H' status can only go to 'A' OR 'D'		$allowed_status_changes = array(			'AH'=>1,'AD'=>1,'DA'=>1,'PA'=>1,'PD'=>1,			'IP'=>1,'HA'=>1,'HD'=>1		);			  		// Check that status transition is valid		if ($this->getStatus() != $status			&& !$allowed_status_changes[$this->getStatus().$status]) {			$this->setError('Invalid Status Change');			return false;		}		db_begin();		$res = db_query("			UPDATE groups			SET status='$status'			WHERE group_id='". $this->getID()."'		");		if (!$res || db_affected_rows($res) < 1) {			$this->setError('ERROR: DB: Could not change group status: '.db_error());			db_rollback();			return false;		}		if ($status=='A') {			// Activate LDAP group, if not yet			if (!sf_ldap_check_group($this->getID())) {				if (!sf_ldap_create_group($this->getID())) {					$this->setError(sf_ldap_get_error_msg());					db_rollback();					return false;				}				if (!$this->activateUsers()) {					db_rollback();					return false;				}			}		/* Otherwise, the group is not active, and make sure that		   LDAP group is not active either */		} else if (sf_ldap_check_group($this->getID())) {			if (!sf_ldap_remove_group($this->getID())) {				$this->setError(sf_ldap_get_error_msg());				db_rollback();				return false;			}		}		// Make sure that active group have default trackers		if ($status=='A') {			$ats = new ArtifactTypes($this);			if (!$ats || !is_object($ats)) {				$this->setError('Error creating ArtifactTypes object');				db_rollback();				return false;			} else if ($ats->isError()) {				$this->setError($ats->getErrorMessage());				db_rollback();				return false;			}			if (!$ats->createTrackers()) {				$this->setError($ats->getErrorMessage());				db_rollback();				return false;			}		}		db_commit();		// Log the audit trail		if ($status != $this->getStatus()) {			$this->addHistory('status', $this->getStatus());		}		$this->data_array['status'] = $status;		return true;	}	/**	 *	isProject - Simple boolean test to see if it's a project or not.	 *	 *	@return	boolean is_project.	 */	function isProject() {		if ($this->getType()==1) {			return true;		} else {			return false;		}	}	/**	 *	isPublic - Simply returns the is_public flag from the database.	 *	 *	@return	boolean	is_public.	 */	function isPublic() {		return $this->data_array['is_public'];	}	/**	 *	isActive - Database field status of 'A' returns true.	 *	 *	@return	boolean	is_active.	 */	function isActive() {		if ($this->getStatus()=='A') {			return true;		} else {			return false;		}	}	/**	 *  getUnixName - the unix_name	 *	 *  @return	string	unix_name.	 */	function getUnixName() {		return strtolower($this->data_array['unix_group_name']);	}	/**	 *  getPublicName - the full-length public name.	 *	 *  @return	string	The group_name.	 */	function getPublicName() {		return htmlspecialchars($this->data_array['group_name']);	}	/**	 *  getRegisterPurpose - the text description of the purpose of this project.	 *	 *  @return	string	The description.	 */	function getRegisterPurpose() {		return $this->data_array['register_purpose'];	}	/**	 *  getDescription	- the text description of this project.	 *	 *  @return	string	The description.	 */	function getDescription() {		return $this->data_array['short_description'];	}	/**	 *  getStartDate - the unix time this project was registered.	 *	 *  @return int (unix time) of registration.	 */	function getStartDate() {		return $this->data_array['register_time'];	}	/**	 *  getLogoImageID - the id of the logo in the database for this project.	 *	 *  @return	int	The ID of logo image in db_images table (or 100 if none).	 */	function getLogoImageID() {		return $this->data_array['logo_image_id'];	}	/**	 *  getUnixBox - the hostname of the unix box where this project is located.	 *	 *  @return	string	The name of the unix machine for the group.	 */	function getUnixBox() {		return $this->data_array['unix_box'];	}	/**	 *  getDomain - the hostname.domain where their web page is located.	 *	 *  @return	string	The name of the group [web] domain.	 */	function getDomain() {		return $this->data_array['http_domain'];	}	/**	 *  getLicense	- the license they chose.	 *	 *  @return	string	ident of group license.	 */	function getLicense() {		return $this->data_array['license'];	}	/**	 *  getLicenseOther - optional string describing license.	 *	 *  @return	string	The custom license.	 */	function getLicenseOther() {		if ($this->getLicense() == 'other') {			return $this->data_array['license_other'];		} else {			return '';		}	}	/**	 *  getRegistrationPurpose - the text description of the purpose of this project.	 *	 *  @return	string	The application for project hosting.	 */	function getRegistrationPurpose() {		return $this->data_array['register_purpose'];	}	/*		Common Group preferences for tools	*/	/**	 *	enableAnonCVS - whether or not this group has opted to enable Anonymous CVS.	 *	 *	@return boolean enable_cvs.	 */	function enableAnonCVS() {		return $this->data_array['enable_anoncvs'];	}	/**	 *	enablePserver - whether or not this group has opted to enable Pserver.	 *	 *	@return boolean	enable_pserver.	 */	function enablePserver() {		return $this->data_array['enable_pserver'];	}	/**	 *	usesCVS - whether or not this group has opted to use CVS.	 *	 *	@return	boolean	uses_cvs.	 */	function usesCVS() {		return $this->data_array['use_cvs'];	}	/**	 *	usesMail - whether or not this group has opted to use mailing lists.	 *	 *	@return	boolean uses_mail.	 */	function usesMail() {		return $this->data_array['use_mail'];	}	/**	 * 	usesNews - whether or not this group has opted to use news.	 *	 *	@return	boolean	uses_news.	 */	function usesNews() {		return $this->data_array['use_news'];	}	/**	 *	usesForum - whether or not this group has opted to use discussion forums.	 *	 *  @return	boolean	uses_forum.	 */	function usesForum() {		return $this->data_array['use_forum'];	}	   	/**	 *  usesStats - whether or not this group has opted to use stats.	 *	 *  @return	boolean	uses_stats.	 */	function usesStats() {		return $this->data_array['use_stats'];	}	/**	 *  usesFRS - whether or not this group has opted to use file release system.	 *	 *  @return	boolean	uses_frs.	 */	function usesFRS() {		return $this->data_array['use_frs'];	}	/**	 *  usesTracker - whether or not this group has opted to use tracker.	 *	 *  @return	boolean	uses_tracker.	 */	function usesTracker() {		return $this->data_array['use_tracker'];	}	/**	 *  usesDocman - whether or not this group has opted to use docman.	 *	 *  @return	boolean	uses_docman.	 */	function usesDocman() {		return $this->data_array['use_docman'];	}	/**	 *  usesFTP - whether or not this group has opted to use FTP.	 *	 *  @return	boolean	uses_ftp.	 */	function usesFTP() {		return $this->data_array['use_ftp'];	}	/**	 *  usesSurvey - whether or not this group has opted to use surveys.	 *	 *  @return	boolean	uses_survey.	 */	function usesSurvey() {		return $this->data_array['use_survey'];	}	   	/**	 *  usesPM - whether or not this group has opted to Project Manager.	 *	 *  @return	boolean	uses_projman.	 */	function usesPM() {		return $this->data_array['use_pm'];	}	function getPlugins() {		if (!isset($this->plugins_data)) {			$this->plugins_data = array () ;			$sql="SELECT group_plugin.plugin_id, plugins.plugin_name							  FROM group_plugin, plugins				  WHERE group_plugin.group_id='".$this->getID()."								AND group_plugin.plugin_id = plugins.plugin_id" ;			$res=db_query($sql);			$rows = db_numrows($res);			for ($i=0; $i<$rows; $i++) {				$plugin_id = db_result($res,$i,'plugin_id');				$this->plugins_data[$plugin_id] = db_result($res,$i,'plugin_name');			}		}		return $this->plugins_data ;	}	function usesPlugin($pluginname) {		$plugins_data = $this->getPlugins() ;		foreach ($plugins_data as $p_id => $p_name) {			if ($p_name == $pluginname) {				return true ;			}		}		return false ;	}	function setPluginUse($pluginname, $val=true) {		if ($val == $this->usesPlugin($pluginname)) {			// State is already good, returning			return true ;		}		$sql="SELECT plugin_id			  FROM plugins			  WHERE plugin_name = '" . $pluginname . "'" ;		$res=db_query($sql);		$rows = db_numrows($res);		if ($rows == 0) {			// Error: no plugin by that name			return false ;		}		$plugin_id = db_result($res,0,'plugin_id');		// Invalidate cache		unset ($this->plugins_data) ;		if ($val) {			$sql="INSERT INTO group_plugin (group_id, plugin_id)							  VALUES (". $this->getID() . ", ". $plugin_id .")" ;			$res=db_query($sql);			return $res ;		} else {			$sql="DELETE FROM group_plugin							  WHERE group_id = ". $this->getID() . "								AND plugin_id = ". $plugin_id ;			$res=db_query($sql);			return $res ;		}	}	/**	 *  getDocEmailAddress - get email address to send doc notifications to.	 *	 *  @return	string	email address.	 */	function getDocEmailAddress() {		return $this->data_array['new_doc_address'];	}	/**	 *  DocEmailAll - whether or not this group has opted to use receive notices on all doc updates.	 *	 *  @return	boolean	email_on_all_doc_updates.	 */	function docEmailAll() {		return $this->data_array['send_all_docs'];	}	/**	 *	getHomePage - The URL for this project's home page.	 *	 *	@return	string	homepage URL.	 */	function getHomePage() {		return $this->data_array['homepage'];	}	/**	 *	getPermission - Return a Permission for this Group and the specified User.	 *	 *	@param	object	The user you wish to get permission for (usually the logged in user).	 *	@return	object	The Permission.	 */	function &getPermission(&$_user) {		return permission_get_object(&$this, &$_user);	}	/**	 *	userIsAdmin - Return if for this Group the User is admin.	 *	 *	@return boolean	is_admin.	 */	function userIsAdmin() {		$perm =& $this->getPermission( session_get_user() );		return $perm->isAdmin();	}	/*		Basic functions to add/remove users to/from a group		and update their permissions	*/	/**	 *	addUser - controls adding a user to a group.	 *  	 *  @param	string	Unix name of the user to add.	 *	@return	boolean	success.	 *	@access public.	 */	function addUser($user_unix_name) {		/*			Admins can add users to groups		*/		$perm =& $this->getPermission( session_get_user() );		if (!$perm || !is_object($perm) || !$perm->isAdmin()) {			$this->setError('You Are Not An Admin For This Group');			return false;		}		db_begin();				/*			get user id for this user's unix_name		*/		$res_newuser = db_query("SELECT * FROM users WHERE user_name='" . strtolower($user_unix_name) . "'");		if (db_numrows($res_newuser) > 0) {			//			//	make sure user is active			//			if (db_result($res_newuser,0,'status') != 'A') {				$this->setError('User is not active. Only active users can be added.');				db_rollback();				return false;			}			//			//	user was found - set new user_id var			//			$form_newuid = db_result($res_newuser,0,'user_id');			//			//	if not already a member, add them			//			$res_member = db_query("SELECT user_id FROM user_group ".				"WHERE user_id='$form_newuid' AND group_id='". $this->getID() ."'");			if (db_numrows($res_member) < 1) {				//				//	user was not already a member				//				//	if no unix account, give them a unix_uid				//				if ( !db_result($res_newuser,0,'unix_uid') ) {					$user=&user_get_object($form_newuid,$res_newuser);					if (!$user->setUpUnixUID()) {						$this->setError('ERROR: Cannot assign UNIX uid to the user');						db_rollback();						return false;					}					if (!sf_ldap_create_user($form_newuid)) {						$this->setError(sf_ldap_get_error_msg());						db_rollback();

⌨️ 快捷键说明

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