[Fusionforge-commits] r9811 - in trunk/gforge: common/include www/admin

Roland Mas lolando at libremir.placard.fr.eu.org
Fri May 21 09:49:52 CEST 2010


Author: lolando
Date: 2010-05-21 09:49:51 +0200 (Fri, 21 May 2010)
New Revision: 9811

Modified:
   trunk/gforge/common/include/session.php
   trunk/gforge/www/admin/admin_utils.php
Log:
Added session_require_perm and session_require_global_perm convenience functions, and try them out

Modified: trunk/gforge/common/include/session.php
===================================================================
--- trunk/gforge/common/include/session.php	2010-05-21 07:49:40 UTC (rev 9810)
+++ trunk/gforge/common/include/session.php	2010-05-21 07:49:51 UTC (rev 9811)
@@ -388,6 +388,32 @@
 }
 
 /**
+ *	session_require_perm() - Convenience function to easily enforce permissions
+ *
+ *	Calling page will terminate with error message if current user
+ *	fails checks.
+ *
+ */
+function session_require_perm ($section, $reference, $action = NULL, $reason='') {
+	if (!forge_check_perm ($section, $reference, $action)) {
+		exit_permission_denied ($reason);
+	}		
+}
+
+/**
+ *	session_require_perm() - Convenience function to easily enforce permissions
+ *
+ *	Calling page will terminate with error message if current user
+ *	fails checks.
+ *
+ */
+function session_require_global_perm ($section, $action = NULL, $reason='') {
+	if (!forge_check_global_perm ($section, $action)) {
+		exit_permission_denied ($reason);
+	}		
+}
+
+/**
  *	session_set_new() - Setup session for the given user
  *
  *	This function sets up SourceForge session for the given user,

Modified: trunk/gforge/www/admin/admin_utils.php
===================================================================
--- trunk/gforge/www/admin/admin_utils.php	2010-05-21 07:49:40 UTC (rev 9810)
+++ trunk/gforge/www/admin/admin_utils.php	2010-05-21 07:49:51 UTC (rev 9811)
@@ -22,7 +22,7 @@
  */
 
 function site_admin_header($params) {
-	session_require(array('group'=>'1','admin_flags'=>'A'));
+	session_require_global_perm ('forge_admin');
 
 	if (get_magic_quotes_gpc()) {
 		$GLOBALS['warning_msg'] = 'WARNING: Your installation is running with php magic_quotes_gpc ON, please change to OFF';




More information about the Fusionforge-commits mailing list