[Fusionforge-commits] r11779 - in trunk/src: common/include www/admin

Franck VILLAUME nerville at libremir.placard.fr.eu.org
Sun Dec 12 19:31:34 CET 2010


Author: nerville
Date: 2010-12-12 19:31:33 +0100 (Sun, 12 Dec 2010)
New Revision: 11779

Modified:
   trunk/src/common/include/Group.class.php
   trunk/src/common/include/Role.class.php
   trunk/src/www/admin/groupdelete.php
Log:
initial fix group delete: missing unlink for specific role in the project

Modified: trunk/src/common/include/Group.class.php
===================================================================
--- trunk/src/common/include/Group.class.php	2010-12-12 12:53:14 UTC (rev 11778)
+++ trunk/src/common/include/Group.class.php	2010-12-12 18:31:33 UTC (rev 11779)
@@ -367,17 +367,17 @@
 			}
 
 			if (USE_PFO_RBAC) {
-				$gjr = new GroupJoinRequest ($this) ;
-				$gjr->create ($user->getID(),
-					      'Fake GroupJoinRequest to store the creator of a project',
-					      false) ;
+				$gjr = new GroupJoinRequest($this);
+				$gjr->create($user->getID(),
+					     'Fake GroupJoinRequest to store the creator of a project',
+					     false);
 			} else {
 			//
 			// Now, make the user an admin
 			//
-			$res=db_query_params ('INSERT INTO user_group (user_id, group_id, admin_flags,
+			$res=db_query_params('INSERT INTO user_group (user_id, group_id, admin_flags,
 				cvs_flags, artifact_flags, forum_flags, role_id)
-				VALUES ($1, $2, $3, $4, $5, $6, $7)', 
+				VALUES ($1, $2, $3, $4, $5, $6, $7)',
 					      array($user->getID(),
 						    $id,
 						    'A',
@@ -1452,7 +1452,7 @@
 			return false;
 		}
 
-		db_begin();
+		//db_begin();
 		//
 		//	Remove all the members
 		//
@@ -1466,6 +1466,16 @@
 		// Failsafe until user_group table is gone
 		$res = db_query_params('DELETE FROM user_group WHERE group_id=$1',
 					array($this->getID()));
+
+		// unlink roles to this project
+		if ($this->isPublic()) {
+			$ra = RoleAnonymous::getInstance();
+			$rl = RoleLoggedIn::getInstance();
+			$ra->unlinkProject($this);
+			$rl->unlinkProject($this);
+		}
+		// @todo : unlink all the other roles created in the project...
+
 		//
 		//	Delete Trackers
 		//
@@ -1706,9 +1716,6 @@
 		}
 
 		db_commit();
-		if (!$res) {
-			return false;
-		}
 
 		$hook_params = array();
 		$hook_params['group'] = $this;
@@ -1744,12 +1751,12 @@
 	*/
 
 	/**
-	 *	addUser - controls adding a user to a group.
-	 *  
-	 *  @param	string	Unix name of the user to add OR integer user_id.
-	 *	@param	int	The role_id this user should have.
-	 *	@return	boolean	success.
-	 *	@access public
+	 * addUser - controls adding a user to a group.
+	 *
+	 * @param	string	Unix name of the user to add OR integer user_id.
+	 * @param	int	The role_id this user should have.
+	 * @return	boolean	success.
+	 * @access	public
 	 */
 	function addUser($user_identifier,$role_id) {
 		global $SYS;
@@ -1798,7 +1805,7 @@
 			}
 			
 			if (USE_PFO_RBAC) {
-				$role->addUser (user_get_object ($user_id)) ;
+				$role->addUser(user_get_object ($user_id)) ;
 				if (!$SYS->sysCheckCreateGroup($this->getID())){
 					$this->setError($SYS->getErrorMessage());
 					db_rollback();
@@ -1814,29 +1821,29 @@
 			//
 			//	if not already a member, add them
 			//
-			$res_member = db_query_params ('SELECT user_id 
+			$res_member = db_query_params('SELECT user_id 
 				FROM user_group 
 				WHERE user_id=$1 AND group_id=$2',
-						       array ($user_id, $this->getID())) ;
+						       array($user_id, $this->getID()));
 
 			if (db_numrows($res_member) < 1) {
 				//
 				//	Create this user's row in the user_group table
 				//
-				$res = db_query_params ('INSERT INTO user_group 
+				$res = db_query_params('INSERT INTO user_group 
 					(user_id,group_id,admin_flags,forum_flags,project_flags,
 					doc_flags,cvs_flags,member_role,release_flags,artifact_flags)
 					VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)',
-							array ($user_id,
-							       $this->getID(),
-							       '',
-							       0,
-							       0,
-							       0,
-							       1,
-							       100,
-							       0,
-							       0)) ;
+							array($user_id,
+							      $this->getID(),
+							      '',
+							      0,
+							      0,
+							      0,
+							      1,
+							      100,
+							      0,
+							      0));
 
 				//verify the insert worked
 				if (!$res || db_affected_rows($res) < 1) {
@@ -1876,7 +1883,7 @@
 				//  user was already a member
 				//  make sure they are set up 
 				//
-				$user=&user_get_object($user_id,$res_newuser);
+				$user= user_get_object($user_id,$res_newuser);
 				$user->fetchData($user->getID());
 				$role = new Role($this,$role_id);
 				if (!$role || !is_object($role)) {
@@ -1974,7 +1981,7 @@
 						array($this->getID(),
 						      $user_id));
 			if (!$res || db_affected_rows($res) < 1) {
-				$this->setError(sprintf(_('ERROR: User not removed: %s'), db_error()));
+				$this->setError(_('ERROR: User not removed:').' '.db_error());
 				db_rollback();
 				return false;
 			}
@@ -1991,7 +1998,7 @@
 						array($this->getID(),
 						      $user_id));
 		if (!$res) {
-			$this->setError(sprintf(_('ERROR: DB: artifact: %s'), db_error()));
+			$this->setError(_('ERROR: DB: artifact:').' '.db_error());
 			db_rollback();
 			return false;
 		}
@@ -2373,25 +2380,25 @@
 		// Set permissions for roles
 		if (USE_PFO_RBAC) {
 			if ($this->isPublic()) {
-				$ra = RoleAnonymous::getInstance() ;
-				$rl = RoleLoggedIn::getInstance() ;
-				$ra->linkProject ($this) ;
-				$rl->linkProject ($this) ;
+				$ra = RoleAnonymous::getInstance();
+				$rl = RoleLoggedIn::getInstance();
+				$ra->linkProject($this);
+				$rl->linkProject($this);
 
-				$ra->setSetting ('project_read', $this->getID(), 1) ;
-				$rl->setSetting ('project_read', $this->getID(), 1) ;
+				$ra->setSetting('project_read', $this->getID(), 1);
+				$rl->setSetting('project_read', $this->getID(), 1);
 
-				$ra->setSetting ('frs', $this->getID(), 1) ;
-				$rl->setSetting ('frs', $this->getID(), 1) ;
+				$ra->setSetting('frs', $this->getID(), 1);
+				$rl->setSetting('frs', $this->getID(), 1);
 
-				$ra->setSetting ('docman', $this->getID(), 1) ;
-				$rl->setSetting ('docman', $this->getID(), 1) ;
+				$ra->setSetting('docman', $this->getID(), 1);
+				$rl->setSetting('docman', $this->getID(), 1);
 
-				$ff = new ForumFactory ($this) ;
+				$ff = new ForumFactory($this);
 				foreach ($ff->getAllForumIds() as $fid) {
-					$f = forum_get_object ($fid) ;
+					$f = forum_get_object($fid);
 					if ($f->isPublic()) {
-						$l = $f->getModerationLevel() ;
+						$l = $f->getModerationLevel();
 						if ($l == 0) {
 							$rl->setSetting('forum', $fid, 3);
 						} else {
@@ -2471,10 +2478,10 @@
 
 
 	/**
-	 *	sendApprovalEmail - Send new project email.
+	 * sendApprovalEmail - Send new project email.
 	 *
-	 *	@return	boolean	success.
-	 *	@access public
+	 * @return	boolean	success.
+	 * @access	public
 	 */
 	function sendApprovalEmail() {
 		$admins = RBACEngine::getInstance()->getUsersByAllowedAction ('project_admin', $this->getID()) ;
@@ -2534,27 +2541,27 @@
 
 
 	/**
-	 *	sendRejectionEmail - Send project rejection email.
+	 * sendRejectionEmail - Send project rejection email.
 	 *
-	 *	This function sends out a rejection message to a user who
-	 *	registered a project.
+	 * This function sends out a rejection message to a user who
+	 * registered a project.
 	 *
-	 *	@param	int	The id of the response to use.
-	 *	@param	string	The rejection message.
-	 *	@return completion status.
-	 *	@access public
+	 * @param	int	The id of the response to use.
+	 * @param	string	The rejection message.
+	 * @return	boolean	completion status.
+	 * @access	public
 	 */
 	function sendRejectionEmail($response_id, $message="zxcv") {
 		$submitters = array () ;
 		if (USE_PFO_RBAC) {
 			foreach (get_group_join_requests ($this) as $gjr) {
-				$submitters[] =  user_get_object($gjr->getUserID()) ;
+				$submitters[] = user_get_object($gjr->getUserID());
 			}
 		} else {
 			$res = db_query_params("SELECT u.user_id FROM users u, user_group ug WHERE ug.group_id=$1 AND u.user_id=ug.user_id",
 					       $this->getID());
-			while ($arr = db_fetch_array ($res)) {
-				$submitter[] =& user_get_object($arr['user_id']);
+			while ($arr = db_fetch_array($res)) {
+				$submitter[] = user_get_object($arr['user_id']);
 			}
 		}
 
@@ -2564,7 +2571,7 @@
 		}
 
 		foreach ($submitters as $admin) {
-			setup_gettext_for_user ($admin) ;
+			setup_gettext_for_user($admin);
 
 			$response=sprintf(_('Your project registration for %3$s has been denied.
 
@@ -2593,27 +2600,27 @@
 	}
 
 	/**
-	 *	sendNewProjectNotificationEmail - Send new project notification email.
+	 * sendNewProjectNotificationEmail - Send new project notification email.
 	 *
-	 *	This function sends out a notification email to the
-	 *	SourceForge admin user when a new project is
-	 *	submitted.
+	 * This function sends out a notification email to the
+	 * SourceForge admin user when a new project is
+	 * submitted.
 	 *
-	 *	@return	boolean	success.
-	 *	@access public
+	 * @return	boolean	success.
+	 * @access	public
 	 */
 	function sendNewProjectNotificationEmail() {
 		// Get the user who wants to register the project
-		$submitters = array () ;
+		$submitters = array();
 		if (USE_PFO_RBAC) {
 			foreach (get_group_join_requests ($this) as $gjr) {
-				$submitters[] =  user_get_object($gjr->getUserID()) ;
+				$submitters[] = user_get_object($gjr->getUserID());
 			}
 		} else {
 			$res = db_query_params("SELECT u.user_id FROM users u, user_group ug WHERE ug.group_id=$1 AND u.user_id=ug.user_id",
 					       $this->getID());
 			while ($arr = db_fetch_array ($res)) {
-				$submitter[] =& user_get_object($arr['user_id']);
+				$submitter[] = user_get_object($arr['user_id']);
 			}
 		}
 		if (count ($submitters) < 1) {
@@ -2680,13 +2687,13 @@
 
 
 
-/**
- *	validateGroupName - Validate the group name
- *
- *	@param	string	Group name.
- *
- *	@return	an error false and set an error is the group name is invalide otherwise return true
- */
+	/**
+	 * validateGroupName - Validate the group name
+	 *
+	 * @param	string	Group name.
+	 *
+	 * @return	boolean	an error false and set an error is the group name is invalide otherwise return true
+	 */
 	function validateGroupName($group_name) {
 		if (strlen($group_name)<3) {
 			$this->setError(_('Group name is too short'));
@@ -2764,24 +2771,24 @@
 	}
 
 	/**
-	 *	getUnixStatus - Status of activation of unix account.
+	 * getUnixStatus - Status of activation of unix account.
 	 *
-	 *	@return	char	(N)one, (A)ctive, (S)uspended or (D)eleted
+	 * @return	char	(N)one, (A)ctive, (S)uspended or (D)eleted
 	 */
 	function getUnixStatus() {
 		return $this->data_array['unix_status'];
 	}
 	
 	/**
-	 *	setUnixStatus - Sets status of activation of unix account.
+	 * setUnixStatus - Sets status of activation of unix account.
 	 *
-	 *	@param	string	The unix status.
-	 *	N	no_unix_account
+	 * @param	string	The unix status.
+	 * 	N	no_unix_account
 	 *	A	active
 	 *	S	suspended
 	 *	D	deleted
 	 *
-	 *	@return	boolean success.
+	 * @return	boolean success.
 	 */
 	function setUnixStatus($status) {
 		global $SYS;
@@ -2818,9 +2825,9 @@
 	}
 	
 	/**
-	 *	getUsers - Get the users of a group
+	 * getUsers - Get the users of a group
 	 *
-	 *	@return array of user's objects.
+	 * @return array of user's objects.
 	 */
 	function getUsers($onlylocal = true) {
 		if (!isset($this->membersArr)) {

Modified: trunk/src/common/include/Role.class.php
===================================================================
--- trunk/src/common/include/Role.class.php	2010-12-12 12:53:14 UTC (rev 11778)
+++ trunk/src/common/include/Role.class.php	2010-12-12 18:31:33 UTC (rev 11779)
@@ -34,16 +34,16 @@
 	var $Group;
 
 	/**
-	 *  Role($group,$id) - CONSTRUCTOR.
+	 * Role($group,$id) - CONSTRUCTOR.
 	 *
-	 *  @param  object	 The Group object.
-	 *  @param  int	 The role_id.
+	 * @param	object	The Group object.
+	 * @param	int	The role_id.
 	 */
-	function Role ($Group,$role_id=false) {
+	function Role($Group, $role_id = false) {
 		$this->BaseRole();
 		if (USE_PFO_RBAC) {
 			if (!$Group || !is_object($Group) || $Group->isError()) {
-				$Group = NULL ;
+				$Group = NULL;
 			}
 		} else {
 			if (!$Group || !is_object($Group) || $Group->isError()) {
@@ -53,16 +53,16 @@
 		}
 		$this->Group =& $Group;
 
-		$hook_params = array ();
+		$hook_params = array();
 		$hook_params['role'] =& $this;
-		plugin_hook ("role_get", $hook_params);
+		plugin_hook("role_get", $hook_params);
 
 		if (isset ($GLOBALS['default_roles'])) {
-			$this->defaults = array_merge_recursive ($this->defaults,
-								 $GLOBALS['default_roles']) ;
+			$this->defaults = array_merge_recursive($this->defaults,
+								$GLOBALS['default_roles']);
 			foreach ($this->defaults as $k => $v) {
-				if (!array_key_exists ($GLOBALS['default_roles'], $k)) {
-					unset ($this->defaults[$k]) ;
+				if (!array_key_exists($GLOBALS['default_roles'], $k)) {
+					unset($this->defaults[$k]);
 				}
 			}
 		}
@@ -76,12 +76,12 @@
 	}
 
 	/**
-	 *	setName - set the name of this role.
+	 * setName - set the name of this role.
 	 *
-	 *	@param	string	The new name of this role.
-	 *      @return boolean True if updated OK
+	 * @param	string	The new name of this role.
+	 * @return	boolean	True if updated OK
 	 */
-	function setName ($role_name) { // From the PFO spec
+	function setName($role_name) { // From the PFO spec
 		if ($role_name == '') {
 			$this->setError('Cannot set a role name to empty');
 			return false;
@@ -91,24 +91,24 @@
 				db_begin();
 				if ($this->Group == NULL) {
 					$res = db_query_params('SELECT role_name FROM pfo_role WHERE home_group_id IS NULL AND role_name=$1',
-							       array (htmlspecialchars($role_name)));
+							       array(htmlspecialchars($role_name)));
 					if (db_numrows($res)) {
 						$this->setError('Cannot create a role with this name (already used)');
-						db_rollback () ;
+						db_rollback();
 						return false;
 					}
 				} else {
 					$res = db_query_params('SELECT role_name FROM pfo_role WHERE home_group_id=$1 AND role_name=$2',
-							       array ($this->Group->getID(), htmlspecialchars($role_name)));
+							       array($this->Group->getID(), htmlspecialchars($role_name)));
 					if (db_numrows($res)) {
 						$this->setError('Cannot create a role with this name (already used)');
-						db_rollback () ;
+						db_rollback();
 						return false;
 					}
 				}
-				$res = db_query_params ('UPDATE pfo_role SET role_name=$1 WHERE role_id=$2',
-							array (htmlspecialchars($role_name),
-							       $this->getID())) ;
+				$res = db_query_params('UPDATE pfo_role SET role_name=$1 WHERE role_id=$2',
+							array(htmlspecialchars($role_name),
+							       $this->getID()));
 				if (!$res || db_affected_rows($res) < 1) {
 					$this->setError('update::name::'.db_error());
 					return false;
@@ -117,45 +117,45 @@
 			} else {
 				// Check if role_name is not already used.
 				$res = db_query_params('SELECT role_name FROM role WHERE group_id=$1 AND role_name=$2',
-						       array ($this->Group->getID(), htmlspecialchars($role_name)));
+						       array($this->Group->getID(), htmlspecialchars($role_name)));
 				if (db_numrows($res)) {
 					$this->setError('Cannot create a role with this name (already used)');
 					return false;
 				}
 				
-				$res = db_query_params ('UPDATE role SET role_name=$1 WHERE group_id=$2 AND role_id=$3',
-							array (htmlspecialchars($role_name),
+				$res = db_query_params('UPDATE role SET role_name=$1 WHERE group_id=$2 AND role_id=$3',
+							array(htmlspecialchars($role_name),
 							       $this->Group->getID(),
-							       $this->getID())) ;
+							       $this->getID()));
 				if (!$res || db_affected_rows($res) < 1) {
 					$this->setError('update::name::'.db_error());
 					return false;
 				}
 			}
 		}
-		return true ;
+		return true;
 	}
 
 	/**
-	 *	isPublic - is this role public (accessible from projects
-	 *      other than its home project)?
+	 * isPublic - is this role public (accessible from projects
+	 * other than its home project)?
 	 *
-	 *	@return	boolean True if public
+	 * @return	boolean True if public
 	 */
 	function isPublic() {	// From the PFO spec
 		return $this->data_array['is_public'];
 	}
 
 	/**
-	 *	setPublic - set the public flag for this role.
+	 * setPublic - set the public flag for this role.
 	 *
-	 *	@param	boolean	The new value of the flag.
-	 *      @return boolean True if updated OK
+	 * @param	boolean	The new value of the flag.
+	 * @return	boolean	True if updated OK
 	 */
-	function setPublic ($flag) { // From the PFO spec
-		$res = db_query_params ('UPDATE pfo_role SET is_public=$1 WHERE role_id=$2',
-					array ($flag?'true':'false',
-					       $this->getID())) ;
+	function setPublic($flag) { // From the PFO spec
+		$res = db_query_params('UPDATE pfo_role SET is_public=$1 WHERE role_id=$2',
+					array($flag?'true':'false',
+					       $this->getID()));
 		if (!$res || db_affected_rows($res) < 1) {
 			$this->setError('update::is_public::'.db_error());
 			return false;
@@ -163,16 +163,16 @@
 		return true;
 	}
 
-	function getHomeProject () { // From the PFO spec
-		return $this->Group ;
+	function getHomeProject() { // From the PFO spec
+		return $this->Group;
 	}
 
 	/**
-	 *	create - create a new role in the database.
+	 * create - create a new role in the database.
 	 *
-	 *	@param	string	The name of the role.
-	 *	@param	array	A multi-dimensional array of data in this format: $data['section_name']['ref_id']=$val
-	 *	@return integer	The id on success or false on failure.
+	 * @param	string	The name of the role.
+	 * @param	array	A multi-dimensional array of data in this format: $data['section_name']['ref_id']=$val
+	 * @return	integer	The id on success or false on failure.
 	 */
 	function create($role_name,$data,$newproject=false) {
 		if (USE_PFO_RBAC) {
@@ -321,8 +321,8 @@
 		for ($i=0; $i<count($keys); $i++) {
 
 			if ($keys[$i] == 'forum') {
-				$res = db_query_params ('SELECT group_forum_id FROM forum_group_list WHERE group_id=$1',
-							array ($this->Group->getID())) ;
+				$res = db_query_params('SELECT group_forum_id FROM forum_group_list WHERE group_id=$1',
+							array($this->Group->getID()));
 				if (!$res) {
 					$this->setError('Error: Forum'.db_error());
 					return false;
@@ -331,24 +331,24 @@
 					$data[$keys[$i]][db_result($res,$j,'group_forum_id')]= $arr[$keys[$i]];
 				}
 			} elseif ($keys[$i] == 'pm') {
-				$res = db_query_params ('SELECT group_project_id FROM project_group_list WHERE group_id=$1',
-							array ($this->Group->getID())) ;
+				$res = db_query_params('SELECT group_project_id FROM project_group_list WHERE group_id=$1',
+							array($this->Group->getID()));
 				if (!$res) {
 					$this->setError('Error: TaskMgr'.db_error());
 					return false;
 				}
 				for ($j=0; $j<db_numrows($res); $j++) {
-					$data[$keys[$i]][db_result($res,$j,'group_project_id')]= $arr[$keys[$i]];
+					$data[$keys[$i]][db_result($res, $j, 'group_project_id')]= $arr[$keys[$i]];
 				}
 			} elseif ($keys[$i] == 'tracker') {
-				$res = db_query_params ('SELECT group_artifact_id FROM artifact_group_list WHERE group_id=$1',
-							array ($this->Group->getID())) ;
+				$res = db_query_params('SELECT group_artifact_id FROM artifact_group_list WHERE group_id=$1',
+							array($this->Group->getID()));
 				if (!$res) {
 					$this->setError('Error: Tracker'.db_error());
 					return false;
 				}
 				for ($j=0; $j<db_numrows($res); $j++) {
-					$data[$keys[$i]][db_result($res,$j,'group_artifact_id')]= $arr[$keys[$i]];
+					$data[$keys[$i]][db_result($res, $j, 'group_artifact_id')]= $arr[$keys[$i]];
 				}
 			} else {
 				$data[$keys[$i]][0]= $arr[$keys[$i]];
@@ -359,9 +359,9 @@
 	}
 	
 	/**
-	 *	delete - delete a role in the database.
+	 * delete - delete a role in the database.
 	 *
-	 *	@return	boolean	True on success or false on failure.
+	 * @return	boolean	True on success or false on failure.
 	 */
 	function delete() {
 		if (USE_PFO_RBAC) {
@@ -370,7 +370,7 @@
 					$this->setPermissionDeniedError();
 					return false;
 				}
-			} elseif (!forge_check_perm ('project_admin', $this->Group->getID())) {
+			} elseif (!forge_check_perm('project_admin', $this->Group->getID())) {
 				$this->setPermissionDeniedError();
 				return false;
 			}
@@ -379,7 +379,7 @@
 					     array($this->getID()));
 			assert($res);
 			if (db_numrows($res) > 0) {
-				$this->setError('Cannot remove a non empty role.');
+				$this->setError(_('Cannot remove a non empty role.'));
 				return false;
 			}
 
@@ -392,7 +392,7 @@
 			}
 			
 			$res=db_query_params('DELETE FROM role_project_refs WHERE role_id=$1',
-					     array($this->getID())) ;
+					     array($this->getID()));
 			if (!$res || db_affected_rows($res) < 1) {
 				$this->setError('delete::name::'.db_error());
 				db_rollback();
@@ -400,7 +400,7 @@
 			}
 			
 			$res=db_query_params('DELETE FROM pfo_role_setting WHERE role_id=$1',
-					     array($this->getID())) ;
+					     array($this->getID()));
 			if (!$res || db_affected_rows($res) < 1) {
 				$this->setError('delete::name::'.db_error());
 				db_rollback();
@@ -408,7 +408,7 @@
 			}
 			
 			$res=db_query_params('DELETE FROM pfo_role WHERE role_id=$1',
-					     array($this->getID())) ;
+					     array($this->getID()));
 			if (!$res || db_affected_rows($res) < 1) {
 				$this->setError('delete::name::'.db_error());
 				db_rollback();
@@ -422,7 +422,7 @@
 			
 			//	Cannot delete role_id=1
 			if ($this->getID() == 1) {
-				$this->setError('Cannot Delete Default Role.');
+				$this->setError(_('Cannot Delete Default Role.'));
 				return false;
 			}
 			$perm =& $this->Group->getPermission();
@@ -435,14 +435,14 @@
 					     array($this->getID()));
 			assert($res);
 			if (db_numrows($res) > 0) {
-				$this->setError('Cannot remove a non empty role.');
+				$this->setError(_('Cannot remove a non empty role.'));
 				return false;
 			}
 		
 			db_begin();
 			
 			$res=db_query_params('DELETE FROM role WHERE group_id=$1 AND role_id=$2',
-					     array($this->Group->getID(), $this->getID())) ;
+					     array($this->Group->getID(), $this->getID()));
 			if (!$res || db_affected_rows($res) < 1) {
 				$this->setError('delete::name::'.db_error());
 				db_rollback();
@@ -455,6 +455,12 @@
 		}
 	}
 
+	/**
+	 * setUser -
+	 * @param	int	User ID
+	 *
+	 * @return	boolean	True on success or false on failure.
+	 */
 	function setUser($user_id) {
 		global $SYS;
 		if (USE_PFO_RBAC) {
@@ -480,9 +486,9 @@
 		//
 		//	See if role is actually changing
 		//
-		$res = db_query_params ('SELECT role_id FROM user_group WHERE user_id=$1 AND group_id=$2',
-					array ($user_id,
-					       $this->Group->getID())) ;
+		$res = db_query_params('SELECT role_id FROM user_group WHERE user_id=$1 AND group_id=$2',
+					array($user_id,
+					       $this->Group->getID()));
 		$old_roleid=db_result($res,0,0);
 		if ($this->getID() == $old_roleid) {
 			db_commit();
@@ -491,7 +497,7 @@
 		//
 		//	Get the old role so we can compare new values to old
 		//
-		$oldrole= new Role($this->Group,$old_roleid);
+		$oldrole= new Role($this->Group, $old_roleid);
 		if (!$oldrole || !is_object($oldrole) || $oldrole->isError()) {
 			$this->setError($oldrole->getErrorMessage());
 			db_rollback();
@@ -503,13 +509,13 @@
 		//	If not, no sense updating it
 		//
 		$arr1 = array_keys($this->setting_array);
-		for ($i=0; $i<count($arr1); $i++) {	
+		for ($i = 0; $i < count($arr1); $i++) {
 		//	array_values($Report->adjust_days)
 			$arr2 = array_keys($this->setting_array[$arr1[$i]]);
 			for ($j=0; $j<count($arr2); $j++) {
 				$usection_name=$arr1[$i];
-				$uref_id=$arr2[$j];
-				$uvalue=$this->setting_array[$usection_name][$uref_id];
+				$uref_id = $arr2[$j];
+				$uvalue = $this->setting_array[$usection_name][$uref_id];
 				if (!$uref_id) {
 					$uref_id=0;
 				}
@@ -590,25 +596,25 @@
 		}
 	//	if ($update_usergroup) {
 			$res = db_query_params ('UPDATE user_group
-                               SET admin_flags=$1,
-   				   forum_flags=$2,
-   				   project_flags=$3,
-   				   doc_flags=$4,
-   				   cvs_flags=$5,
-   				   release_flags=$6,
-   				   artifact_flags=$7,
-   				   role_id=$8
-                               WHERE user_id=$9 AND group_id=$10',
-   						array ($this->getVal('projectadmin',0),
-						       $this->getVal('forumadmin',0),
-						       $this->getVal('pmadmin',0),
-						       $this->getVal('docman',0),
-						       $this->getVal('scm',0),
-						       $this->getVal('frs',0),
-						       $this->getVal('trackeradmin',0),
-						       $this->getID(),
-						       $user_id,
-						       $this->Group->getID()));
+			       SET admin_flags=$1,
+				   forum_flags=$2,
+				   project_flags=$3,
+				   doc_flags=$4,
+				   cvs_flags=$5,
+				   release_flags=$6,
+				   artifact_flags=$7,
+				   role_id=$8
+			       WHERE user_id=$9 AND group_id=$10',
+						array($this->getVal('projectadmin', 0),
+						      $this->getVal('forumadmin', 0),
+						      $this->getVal('pmadmin', 0),
+						      $this->getVal('docman', 0),
+						      $this->getVal('scm', 0),
+						      $this->getVal('frs', 0),
+						      $this->getVal('trackeradmin', 0),
+						      $this->getID(),
+						      $user_id,
+						      $this->Group->getID()));
 			if (!$res) {
 				$this->setError('::update::usergroup::'.db_error());
 				db_rollback();
@@ -617,13 +623,12 @@
 
 	//	}
 
-		$hook_params = array ();
+		$hook_params = array();
 		$hook_params['role'] =& $this;
 		$hook_params['role_id'] = $this->getID();
 		$hook_params['user_id'] = $user_id;
-		plugin_hook ("role_setuser", $hook_params);
+		plugin_hook("role_setuser", $hook_params);
 
-
 		db_commit();
 		return true;
 		}

Modified: trunk/src/www/admin/groupdelete.php
===================================================================
--- trunk/src/www/admin/groupdelete.php	2010-12-12 12:53:14 UTC (rev 11778)
+++ trunk/src/www/admin/groupdelete.php	2010-12-12 18:31:33 UTC (rev 11779)
@@ -27,15 +27,15 @@
 require_once $gfcommon.'include/license.php';
 require_once $gfwww.'admin/admin_utils.php';
 
-session_require_global_perm ('forge_admin');
+session_require_global_perm('forge_admin');
 
-$group_id=getIntFromGet('group_id');
+$group_id = getIntFromGet('group_id');
 
 $group = group_get_object($group_id);
 if (!$group || !is_object($group)) {
 	exit_no_group();
 } elseif ($group->isError()) {
-	exit_error($group->getErrorMessage(),'admin');
+	exit_error($group->getErrorMessage(), 'admin');
 }
 
 if (getStringFromPost('submit')) {
@@ -45,7 +45,7 @@
 	if (!$group->delete($sure, $reallysure, $reallyreallysure)) {
 		exit_error($group->getErrorMessage(), 'admin');
 	} else {
-		plugin_hook('delete_link',$_GET['group_id']);
+		plugin_hook('delete_link',$group_id);
 		$feedback = _('Project successfully deleted');
 		session_redirect('/admin/?feedback='.urlencode($feedback));
 	}
@@ -56,7 +56,7 @@
 echo '<h1>'.$title.'</h1>';
 ?>
 
-<form action="<?php echo getStringFromServer('PHP_SELF').'?group_id='.$group_id; ?>" method="post">
+<form action="<?php echo '?group_id='.$group_id; ?>" method="post">
 <input type="checkbox" value="1" name="sure" /> <?php echo _('Confirm Delete'); ?><br />
 <input type="checkbox" value="1" name="reallysure" /> <?php echo _('Confirm Delete'); ?><br />
 <input type="checkbox" value="1" name="reallyreallysure" /> <?php echo _('Confirm Delete'); ?><br />




More information about the Fusionforge-commits mailing list