Changeset 426 for trunk/user.php


Ignore:
Timestamp:
Oct 10, 2012, 8:28:07 PM (12 years ago)
Author:
chronos
Message:
  • Přidáno: Tlačítko zrušit u formulářů.
  • Opraveno: Chyba načítání informací o uživateli pokud neměl vazbu na Member/Customer.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/user.php

    r416 r426  
    3636  var $PermissionCache = array();
    3737  var $PermissionGroupCache = array();
     38  var $PermissionGroupCacheOp = array();
    3839
    3940  function Check()
     
    5455    if($Row['User'] != $this->AnonymousUserId)
    5556    {
    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']);     
    5758      $this->User = $Query->fetch_assoc();
    5859      $Result = USER_LOGGED;
     
    218219    }
    219220
    220 
    221221    // 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    }
    224237    return(false);
    225238  }
     
    227240  function CheckPermission($Module, $Operation, $ItemType = '', $ItemIndex = 0)
    228241  {
     242    //echo('Check '.$Module.' '.$Operation.' '.$ItemType.' '.$ItemIndex);
     243    //
    229244    // First try to check cache
    230245    if(in_array(array($Module, $Operation, $ItemType, $ItemType), $this->PermissionCache))
    231246    {
    232       $OperationId = array_search(array($Module, $Operation, $ItemType, $ItemType), $this->PermissionCache);
     247      $OperationId = array_search(array($Module, $Operation, $ItemType, $ItemIndex), $this->PermissionCache);
    233248      $PermissionExists = is_numeric($OperationId);
    234249    } else
     
    240255        $DbRow = $DbResult->fetch_array();
    241256        $OperationId = $DbRow['Id'];
    242         $this->PermissionCache[$DbRow['Id']] = array($Module, $Operation, $ItemType, $ItemType);       
     257        $this->PermissionCache[$DbRow['Id']] = array($Module, $Operation, $ItemType, $ItemIndex);
    243258        $PermissionExists = true;
    244259      } else
    245260      {         
    246         $this->PermissionCache[$DbRow['Id'].'_'] = array($Module, $Operation, $ItemType, $ItemType);       
     261        $this->PermissionCache[$DbRow['Id'].'_'] = array($Module, $Operation, $ItemType, $ItemIndex);       
    247262        $PermissionExists = false;
    248263      }
Note: See TracChangeset for help on using the changeset viewer.