Changeset 426 for trunk/user.php
- Timestamp:
- Oct 10, 2012, 8:28:07 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/user.php
r416 r426 36 36 var $PermissionCache = array(); 37 37 var $PermissionGroupCache = array(); 38 var $PermissionGroupCacheOp = array(); 38 39 39 40 function Check() … … 54 55 if($Row['User'] != $this->AnonymousUserId) 55 56 { 56 $Query = $this->Database->query('SELECT User.*, UserCustomerRel.Customer AS Member FROM User JOIN UserCustomerRel ON UserCustomerRel.User=User.Id WHERE User.Id='.$Row['User']);57 $Query = $this->Database->query('SELECT User.*, UserCustomerRel.Customer AS Member FROM User LEFT JOIN UserCustomerRel ON UserCustomerRel.User=User.Id WHERE User.Id='.$Row['User']); 57 58 $this->User = $Query->fetch_assoc(); 58 59 $Result = USER_LOGGED; … … 218 219 } 219 220 220 221 221 // Check group-operation relation 222 $DbResult = $this->Database->select('PermissionGroupAssignment', '*', '`Group`="'.$GroupId.'" AND `AssignedOperation`="'.$OperationId.'"'); 223 if($DbResult->num_rows > 0) return(true); 222 if(array_key_exists($GroupId.','.$OperationId, $this->PermissionGroupCacheOp)) 223 { 224 $PermissionExists = true; 225 } else 226 { 227 // If no permission combination exists in cache, do new check of database items 228 $DbResult = $this->Database->select('PermissionGroupAssignment', '*', '`Group`="'.$GroupId.'" AND `AssignedOperation`="'.$OperationId.'"'); 229 if($DbResult->num_rows > 0) $this->PermissionGroupCacheOp[$GroupId.','.$OperationId] = true; 230 else $this->PermissionGroupCacheOp[$GroupId.','.$OperationId] = false; 231 $PermissionExists = true; 232 } 233 if($PermissionExists) 234 { 235 return($this->PermissionGroupCacheOp[$GroupId.','.$OperationId]); 236 } 224 237 return(false); 225 238 } … … 227 240 function CheckPermission($Module, $Operation, $ItemType = '', $ItemIndex = 0) 228 241 { 242 //echo('Check '.$Module.' '.$Operation.' '.$ItemType.' '.$ItemIndex); 243 // 229 244 // First try to check cache 230 245 if(in_array(array($Module, $Operation, $ItemType, $ItemType), $this->PermissionCache)) 231 246 { 232 $OperationId = array_search(array($Module, $Operation, $ItemType, $Item Type), $this->PermissionCache);247 $OperationId = array_search(array($Module, $Operation, $ItemType, $ItemIndex), $this->PermissionCache); 233 248 $PermissionExists = is_numeric($OperationId); 234 249 } else … … 240 255 $DbRow = $DbResult->fetch_array(); 241 256 $OperationId = $DbRow['Id']; 242 $this->PermissionCache[$DbRow['Id']] = array($Module, $Operation, $ItemType, $Item Type);257 $this->PermissionCache[$DbRow['Id']] = array($Module, $Operation, $ItemType, $ItemIndex); 243 258 $PermissionExists = true; 244 259 } else 245 260 { 246 $this->PermissionCache[$DbRow['Id'].'_'] = array($Module, $Operation, $ItemType, $Item Type);261 $this->PermissionCache[$DbRow['Id'].'_'] = array($Module, $Operation, $ItemType, $ItemIndex); 247 262 $PermissionExists = false; 248 263 }
Note:
See TracChangeset
for help on using the changeset viewer.