[Vtigercrm-commits] [vtiger-commits] r5362 - /vtigercrm/branches/4.2/modules/Users/UserInfoUtil.php
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Tue Apr 25 15:14:23 EDT 2006
Author: allanbush
Date: Tue Apr 25 13:14:20 2006
New Revision: 5362
Log:
Cache all the tab permissions for all profiles in one query. Modified from mikecrowe's optimizations (http://forums.vtiger.com/viewtopic.php?t=3804). Refs #744.
Also removed the special case for the global MAX_TAB_PER variable as I don't know where this gets set or what it's suppost to do.
Modified:
vtigercrm/branches/4.2/modules/Users/UserInfoUtil.php
Modified: vtigercrm/branches/4.2/modules/Users/UserInfoUtil.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Users/UserInfoUtil.php (original)
+++ vtigercrm/branches/4.2/modules/Users/UserInfoUtil.php Tue Apr 25 13:14:20 2006
@@ -79,45 +79,39 @@
return $groupname;
}
-function getAllTabsPermission($profileid)
-{
- global $adb,$MAX_TAB_PER;
- $sql = "select * from profile2tab where profileid=" .$profileid ;
+function loadAllPerms()
+{
+ global $adb;
+ static $persistPermArray = Array();
+
+ if($persistPermArray) return $persistPermArray;
+
+ $sql = "select tabid, permissions, profileid from profile2tab";
$result = $adb->query($sql);
- $tab_perr_array = Array();
- if($MAX_TAB_PER !='')
- {
- $tab_perr_array = array_fill(0,$MAX_TAB_PER,0);
- }
$num_rows = $adb->num_rows($result);
for($i=0; $i<$num_rows; $i++)
{
- $tabid= $adb->query_result($result,$i,'tabid');
- $tab_per= $adb->query_result($result,$i,'permissions');
- $tab_perr_array[$tabid] = $tab_per;
- }
+ $tabid = $adb->query_result($result, $i, 'tabid');
+ $tab_per = $adb->query_result($result, $i, 'permissions');
+ $profileid = $adb->query_result($result, $i, 'profileid');
+ $persistPermArray[$profileid][$tabid] = $tab_per;
+ }
+ return $persistPermArray;
+}
+
+function getAllTabsPermission($profileid)
+{
+ $perm = loadAllPerms();
+ return $perm[$profileid];
+}
+
+function getTabsPermission($profileid)
+{
+ $perm = loadAllPerms();
+ $tab_perr_array = $perm[$profileid];
+ foreach( array(1,3,16,15,17,18,19,22) as $tabid )
+ $tab_perr_array[$tabid] = 0;
return $tab_perr_array;
-
-}
-
-function getTabsPermission($profileid)
-{
- global $adb;
- $sql = "select * from profile2tab where profileid=" .$profileid ;
- $result = $adb->query($sql);
- $tab_perr_array = Array();
- $num_rows = $adb->num_rows($result);
- for($i=0; $i<$num_rows; $i++)
- {
- $tabid= $adb->query_result($result,$i,'tabid');
- $tab_per= $adb->query_result($result,$i,'permissions');
- if($tabid != 1 && $tabid != 3 && $tabid != 16 && $tab_id != 15 && $tab_id != 17 && $tab_id != 18 && $tab_id != 19 && $tab_id != 22)
- {
- $tab_perr_array[$tabid] = $tab_per;
- }
- }
- return $tab_perr_array;
-
}
function getTabsActionPermission($profileid)
More information about the vtigercrm-commits
mailing list