[Fusionforge-commits] r14708 - in trunk: . src/common/include

Roland Mas lolando at fusionforge.org
Tue Oct 25 15:38:22 CEST 2011


Author: lolando
Date: 2011-10-25 15:38:21 +0200 (Tue, 25 Oct 2011)
New Revision: 14708

Modified:
   trunk/
   trunk/src/common/include/RBAC.php
Log:
Avoid unneeded queries when updating a role

Modified: trunk/src/common/include/RBAC.php
===================================================================
--- trunk/src/common/include/RBAC.php	2011-10-25 12:34:53 UTC (rev 14707)
+++ trunk/src/common/include/RBAC.php	2011-10-25 13:38:21 UTC (rev 14708)
@@ -278,6 +278,11 @@
 	}
 
 	function setSetting ($section, $reference, $value) {
+		$cur = $this->getSettingRaw($section, $reference);
+		if (($value == $cur) && ($cur != NULL)) {
+			return true;
+		}
+
 		$role_id = $this->getID () ;
 
 		$res = db_query_params ('DELETE FROM pfo_role_setting WHERE role_id=$1 AND section_name=$2 AND ref_id=$3',
@@ -371,6 +376,14 @@
      * @return number|boolean
      */
     function getSetting($section, $reference) {
+	    $r = $this->getSettingRaw($section, $reference);
+	    if ($r == NULL) {
+		    return 0;
+	    }
+	    return $r;
+    }
+
+    function getSettingRaw($section, $reference) {
         if (isset ($this->perms_array[$section][$reference])) {
 			$value = $this->perms_array[$section][$reference] ;
 		} else {
@@ -482,7 +495,7 @@
 			$hook_params['section'] = $section ;
 			$hook_params['reference'] = $reference ;
 			$hook_params['value'] = $value ;
-			$hook_params['result'] = 0 ;
+			$hook_params['result'] = NULL ;
 			plugin_hook_by_reference ("role_get_setting", $hook_params);
 			return $hook_params['result'] ;
 			break ;




More information about the Fusionforge-commits mailing list