Changeset 356 for trunk/Modules/User/User.php
- Timestamp:
- Jan 18, 2012, 10:21:43 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/User/User.php
r347 r356 34 34 var $AnonymousUserId = 98; 35 35 var $OnlineStateTimeout = 600; // in seconds 36 var $PermissionCache = array(); 36 37 37 38 function __construct($Database, $System) … … 226 227 function CheckPermission($Module, $Operation, $ItemType = '', $ItemIndex = 0) 227 228 { 228 $DbResult = $this->Database->select('PermissionOperation', 'Id', '`Module`="'.$Module.'" AND `Item`="'.$ItemType.'" AND `ItemId`='.$ItemIndex.' AND `Operation`="'.$Operation.'"'); 229 if($DbResult->num_rows > 0) 230 { 231 $DbRow = $DbResult->fetch_array(); 232 $OperationId = $DbRow['Id']; 233 229 // First try to check cache 230 if(in_array(array($Module, $Operation, $ItemType, $ItemType), $this->PermissionCache)) 231 { 232 $OperationId = array_search(array($Module, $Operation, $ItemType, $ItemType), $this->PermissionCache); 233 $PermissionExists = is_numeric($OperationId); 234 } else 235 { 236 // If no permission combination exists in cache, do new check of database items 237 $DbResult = $this->Database->select('PermissionOperation', 'Id', '`Module`="'.$Module.'" AND `Item`="'.$ItemType.'" AND `ItemId`='.$ItemIndex.' AND `Operation`="'.$Operation.'"'); 238 if($DbResult->num_rows > 0) 239 { 240 $DbRow = $DbResult->fetch_array(); 241 $OperationId = $DbRow['Id']; 242 $this->PermissionCache[$DbRow['Id']] = array($Module, $Operation, $ItemType, $ItemType); 243 $PermissionExists = true; 244 } else 245 { 246 $this->PermissionCache[$DbRow['Id'].'_'] = array($Module, $Operation, $ItemType, $ItemType); 247 $PermissionExists = false; 248 } 249 } 250 251 if($PermissionExists) 252 { 234 253 // Check user-operation relation 235 254 $DbResult = $this->Database->select('PermissionUserAssignment', '*', '`User`="'.$this->User['Id'].'" AND `GroupOrOperation`="'.$OperationId.'" AND `Type`="Operation"'); … … 240 259 while($DbRow = $DbResult->fetch_array()) 241 260 { 242 261 if($this->CheckGroupPermission($DbRow['GroupOrOperation'], $OperationId) == true) return(true); 243 262 } 244 263 return(false);
Note:
See TracChangeset
for help on using the changeset viewer.