Changeset 356


Ignore:
Timestamp:
Jan 18, 2012, 10:21:43 AM (13 years ago)
Author:
chronos
Message:
  • Upraveno: Zrychlení kontroly uživatelských oprávnění pro opakované kontroly se stejnými podmínkami.
Location:
trunk
Files:
4 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/Modules/User/User.php

    r347 r356  
    3434  var $AnonymousUserId = 98;
    3535  var $OnlineStateTimeout = 600; // in seconds
     36  var $PermissionCache = array();
    3637
    3738  function __construct($Database, $System)
     
    226227  function CheckPermission($Module, $Operation, $ItemType = '', $ItemIndex = 0)
    227228  {
    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    {
    234253      // Check user-operation relation
    235254      $DbResult = $this->Database->select('PermissionUserAssignment', '*', '`User`="'.$this->User['Id'].'" AND `GroupOrOperation`="'.$OperationId.'" AND `Type`="Operation"');
     
    240259      while($DbRow = $DbResult->fetch_array())
    241260      {
    242          if($this->CheckGroupPermission($DbRow['GroupOrOperation'], $OperationId) == true) return(true);
     261       if($this->CheckGroupPermission($DbRow['GroupOrOperation'], $OperationId) == true) return(true);
    243262      }
    244263      return(false);
  • trunk/forms.php

    r302 r356  
    22
    33include_once('form_classes.php');
    4 include_once('database.php');
     4include_once('Common/Database.php');
    55
    66class Form
  • trunk/global.php

    r355 r356  
    66  else die('Nenalezen konfigurační soubor '.$ConfigFileName.'!');
    77 
    8 include_once('database.php');
     8include_once('Common/Database.php');
    99include_once('Common/Error.php');
    1010include_once('Common/Code.php');
     
    204204  $System = new System($Database);
    205205  $System->Config = &$Config;
    206   $System->ReloadList();
    207   $System->Install();
     206  //$System->ReloadList();
     207  //$System->Install();
    208208  $System->Init();
    209209  if(isset($_SERVER['REMOTE_ADDR'])) $System->Models['User']->Check();
  • trunk/system/generators/common.php

    r288 r356  
    11<?php
    22
    3 include_once('../../network_address.php');
     3include_once('../../Common/NetworkAddress.php');
    44
    55function GetMarkByComment($Comment)
Note: See TracChangeset for help on using the changeset viewer.