[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/web_cache/src/ -> lmbFullPageCacheUserRule.class.php (source)

   1  <?php
   2  /*
   3   * Limb PHP Framework
   4   *
   5   * @link http://limb-project.com 
   6   * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
   7   * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
   8   */
   9  
  10  /**

  11   * class lmbFullPageCacheUserRule.

  12   *

  13   * @package web_cache

  14   * @version $Id: lmbFullPageCacheUserRule.class.php 5945 2007-06-06 08:31:43Z pachanga $

  15   */
  16  class lmbFullPageCacheUserRule
  17  {
  18    protected $user_groups = array();
  19  
  20    function __construct($user_groups)
  21    {
  22      $this->user_groups = $user_groups;
  23    }
  24  
  25    function isSatisfiedBy($request)
  26    {
  27      $user = $request->getUser();
  28  
  29      $positive_groups = array();
  30      $negative_groups = array();
  31  
  32      foreach($this->user_groups as $group)
  33      {
  34        if($group{0} == '!')
  35          $negative_groups[] = substr($group, 1);
  36        else
  37          $positive_groups[] = $group;
  38      }
  39  
  40      $res = true;
  41  
  42      if($positive_groups)
  43        $res = (array_intersect($positive_groups, $user->getGroups()) == $positive_groups);
  44  
  45      if($res && $negative_groups)
  46        $res &= !(array_intersect($negative_groups, $user->getGroups()) == $negative_groups);
  47  
  48      return $res;
  49    }
  50  }
  51  
  52  ?>


Generated: Fri Aug 29 04:49:26 2008 Cross-referenced by PHPXref 0.7