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

Roland Mas lolando at libremir.placard.fr.eu.org
Fri Sep 24 17:07:55 CEST 2010


Author: lolando
Date: 2010-09-24 17:07:55 +0200 (Fri, 24 Sep 2010)
New Revision: 10674

Modified:
   trunk/src/common/include/session.php
Log:
Less SQL (and fewer references to the user_group table), more code reuse

Modified: trunk/src/common/include/session.php
===================================================================
--- trunk/src/common/include/session.php	2010-09-24 15:03:58 UTC (rev 10673)
+++ trunk/src/common/include/session.php	2010-09-24 15:07:55 UTC (rev 10674)
@@ -495,16 +495,11 @@
  *	@return none
  */
 function session_set_admin() {
-	$res = db_query_params ('SELECT user_id FROM user_group WHERE admin_flags=$1 AND group_id=1',
-				array ('A'));
-	if (!$res) {
-		exit_error(db_error(),'');
-	}
-	if (db_numrows($res) == 0) {
+	$admins = RBACEngine::getInstance()->getUsersByAllowedAction ('forge_admin', -1) ;
+	if (count ($admins) == 0) {
 		exit_error(_('No admin users ?'),'');
 	}
-	$id = db_result ($res, 0, 0);
-	session_set_new ($id);
+	session_set_new ($admins[0]->getID());
 }
 
 /**




More information about the Fusionforge-commits mailing list