Changeset 416 for trunk


Ignore:
Timestamp:
Oct 7, 2012, 9:30:38 PM (12 years ago)
Author:
chronos
Message:
  • Upraveno: Optimalizace zrychlení načítání skupin práv.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/user.php

    r415 r416  
    3535  var $OnlineStateTimeout = 600; // in seconds
    3636  var $PermissionCache = array();
     37  var $PermissionGroupCache = array();
    3738
    3839  function Check()
     
    194195  function CheckGroupPermission($GroupId, $OperationId)
    195196  {
    196     // Check group-group relation
    197     $DbResult = $this->Database->select('PermissionGroupAssignment', '*', '`Group`="'.$GroupId.'" AND `AssignedGroup` IS NOT NULL');
    198     while($DbRow = $DbResult->fetch_array())
    199     {
    200        if($this->CheckGroupPermission($DbRow['AssignedGroup'], $OperationId) == true) return(true);
    201     }
     197    $PermissionExists = false;
     198    // First try to check cache group-group relation
     199    if(array_key_exists($GroupId, $this->PermissionGroupCache))
     200    {
     201      $PermissionExists = true;
     202    } else
     203    {         
     204      // If no permission combination exists in cache, do new check of database items           
     205      $DbResult = $this->Database->select('PermissionGroupAssignment', '*', '`Group`="'.$GroupId.'" AND `AssignedGroup` IS NOT NULL');     
     206      $DbRow = array();
     207      while($DbRow[] = $DbResult->fetch_array());     
     208      $this->PermissionGroupCache[$GroupId] = $DbRow;
     209      $PermissionExists = true;
     210    }
     211    if($PermissionExists)
     212    {
     213      foreach($this->PermissionGroupCache[$GroupId] as $DbRow)
     214      {
     215        if($DbRow['AssignedGroup'] != '')
     216        if($this->CheckGroupPermission($DbRow['AssignedGroup'], $OperationId) == true) return(true);
     217      }
     218    }
     219
    202220
    203221    // Check group-operation relation
Note: See TracChangeset for help on using the changeset viewer.