[Fusionforge-commits] r10691 - trunk/src/common/include

Roland Mas lolando at libremir.placard.fr.eu.org
Sat Sep 25 18:19:33 CEST 2010


Author: lolando
Date: 2010-09-25 18:19:33 +0200 (Sat, 25 Sep 2010)
New Revision: 10691

Modified:
   trunk/src/common/include/Group.class.php
   trunk/src/common/include/GroupJoinRequest.class.php
Log:
Project creator is now stored in a special GroupJoinRequest rather than in user_group if USE_PFO_RBAC

Modified: trunk/src/common/include/Group.class.php
===================================================================
--- trunk/src/common/include/Group.class.php	2010-09-25 15:29:08 UTC (rev 10690)
+++ trunk/src/common/include/Group.class.php	2010-09-25 16:19:33 UTC (rev 10691)
@@ -37,6 +37,7 @@
 require_once $gfcommon.'survey/SurveyFactory.class.php';
 require_once $gfcommon.'survey/SurveyQuestionFactory.class.php';
 require_once $gfcommon.'include/gettext.php';
+require_once $gfcommon.'include/GroupJoinRequest.class.php';
 
 //the license_id of "Other/proprietary" license
 define('GROUP_LICENSE_OTHER',126);
@@ -357,7 +358,13 @@
 				db_rollback();
 				return false;
 			}
-	
+			
+			if (USE_PFO_RBAC) {
+				$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
 			//
@@ -376,6 +383,7 @@
 				db_rollback();
 				return false;
 			}
+			}
 	
 			if (!$this->fetchData($id)) {
 				db_rollback();
@@ -2269,6 +2277,16 @@
 		//	Set Default Roles
 		//
 		//
+		if (USE_PFO_RBAC) {
+			$idadmin_group = NULL ;
+			foreach (get_group_join_requests ($this) as $gjr) {
+				$idadmin_group = $gjr->getUserID() ;
+				break ;
+			}
+			if ($idadmin_group == NULL) {
+				$idadmin_group = $user->getID();
+			}
+		} else {
 
 		$admin_group = db_query_params ('SELECT user_id FROM user_group WHERE group_id=$1 AND admin_flags=$2',
 						array ($this->getID(),
@@ -2282,6 +2300,7 @@
 						$this->getID(),
 						'A')) ;
 		}
+		}
 
 		$role = new Role($this);
 		$todo = array_keys($role->defaults);
@@ -2306,9 +2325,13 @@
 					$r->addUser (user_get_object ($idadmin_group)) ;
 				}
 			}
-
-			RoleAnonymous::getInstance()->linkProject($this) ;
-			RoleLoggedIn::getInstance()->linkProject($this) ;
+			if ($this->isPublic()) {
+				RoleAnonymous::getInstance()->linkProject($this) ;
+				RoleLoggedIn::getInstance()->linkProject($this) ;
+			}
+			foreach (get_group_join_requests ($this) as $gjr) {
+				$gjr->delete (true) ;
+			}
 		}
 
 		//

Modified: trunk/src/common/include/GroupJoinRequest.class.php
===================================================================
--- trunk/src/common/include/GroupJoinRequest.class.php	2010-09-25 15:29:08 UTC (rev 10690)
+++ trunk/src/common/include/GroupJoinRequest.class.php	2010-09-25 16:19:33 UTC (rev 10691)
@@ -93,10 +93,10 @@
 	 *
 	 *	@param	int4 user_id.
 	 *	@param	text comments.
-	 *	@param	int4 request_date.
+	 *	@param	bool whether to send an email to the admin(s)
 	 * @return boolean Success.
 	 */
-	function create($user_id,$comments) {
+	function create($user_id,$comments,$send_email=true) {
 		$v = new Validator();
 		$v->check($user_id, "user_id");
 		$v->check(trim($comments), "comments");
@@ -133,16 +133,17 @@
 			$this->setError('GroupJoinRequest::create() Posting Failed '.db_error());
 			db_rollback();
 			return false;
-		} else {
-			if (!$this->fetchData($this->Group->getID(),$user_id)) {
-				db_rollback();
-				return false;
-			} else {
-				$this->sendJoinNotice();
-				db_commit();
-				return true;
-			}
 		}
+		
+		if (!$this->fetchData($this->Group->getID(),$user_id)) {
+			db_rollback();
+			return false;
+		}
+		if ($send_email) {
+			$this->sendJoinNotice();
+		}
+		db_commit();
+		return true;
 	}
 
     /**




More information about the Fusionforge-commits mailing list