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

Roland Mas lolando at libremir.placard.fr.eu.org
Mon Sep 20 22:08:29 CEST 2010


Author: lolando
Date: 2010-09-20 22:08:28 +0200 (Mon, 20 Sep 2010)
New Revision: 10560

Modified:
   trunk/src/common/include/Role.class.php
Log:
Allow PFO-RBAC roles to be created

Modified: trunk/src/common/include/Role.class.php
===================================================================
--- trunk/src/common/include/Role.class.php	2010-09-20 18:06:01 UTC (rev 10559)
+++ trunk/src/common/include/Role.class.php	2010-09-20 20:08:28 UTC (rev 10560)
@@ -198,6 +198,35 @@
 			return false;
 		}
 
+		if (USE_PFO_RBAC) {
+			db_begin();
+			$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)));
+			if (db_numrows($res)) {
+				$this->setError('Cannot create a role with this name (already used)');
+				db_rollback () ;
+				return false;
+			}
+			
+			$res = db_query_params ('INSERT INTO pfo_role (home_group_id, role_name) VALUES ($1, $2)',
+						array ($this->Group->getID(),
+						       htmlspecialchars($role_name))) ;
+			if (!$res) {
+				$this->setError('create::'.db_error());
+				db_rollback();
+				return false;
+			}
+			$role_id=db_insertid($res,'role','role_id');
+			if (!$role_id) {
+				$this->setError('create::db_insertid::'.db_error());
+				db_rollback();
+				return false;
+			}
+
+			$this->update ($data) ;
+			
+			$this->normalizeData () ;
+		} 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)));
@@ -248,6 +277,7 @@
 				}
 			}
 		}
+		}
 		if (!$this->fetchData($role_id)) {
 			db_rollback();
 			return false;




More information about the Fusionforge-commits mailing list