[ Index ]
 

Code source de Horde 3.1.3

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/Horde/IMAP/ -> ACL.php (source)

   1  <?php
   2  /**
   3   * Contains functions related to managing
   4   * Access Control Lists.
   5   *
   6   * $Horde: framework/IMAP/IMAP/ACL.php,v 1.2.12.10 2006/02/03 03:07:57 selsky Exp $
   7   *
   8   * Copyright 2003-2006 Chris Hastie <imp@oak-wood.co.uk>
   9   *
  10   * See the enclosed file COPYING for license information (LGPL). If you
  11   * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
  12   *
  13   * @author  Chris Hastie <imp@oak-wood.co.uk>
  14   * @since   Horde 3.0
  15   * @package Horde_IMAP
  16   */
  17  class IMAP_ACL {
  18  
  19      /**
  20       * Hash containing connection parameters.
  21       *
  22       * @var array
  23       */
  24      var $_params = array();
  25  
  26      /**
  27       * Boolean indicating if the driver is supported by the server
  28       *
  29       * @var boolean
  30       */
  31      var $_supported = false;
  32  
  33      /**
  34       * Any PEAR_Error that occured but couldn't be returned directly.
  35       *
  36       * @var PEAR_Error
  37       */
  38      var $_error = null;
  39  
  40      /**
  41       * Hash containing the list of possible rights and a human
  42       * readable description of each
  43       *
  44       * Array (
  45       *     right-id => right-description
  46       * )
  47       *
  48       * @var array
  49       */
  50      var $_rightsList = array();
  51  
  52      /**
  53       * Array containing user names that cannot have their access
  54       * rights changed.
  55       *
  56       * @var boolean
  57       */
  58      var $_protected;
  59  
  60      /**
  61       * Constructor.
  62       *
  63       * @param array $params  Hash containing connection parameters.
  64       */
  65      function IMAP_ACL($params = array())
  66      {
  67          $this->_params = $params;
  68      }
  69  
  70      /**
  71       * Attempts to retrieve the existing ACL for a folder from
  72       * the current IMAP server.
  73       *
  74       * @param string folder  The folder to get the ACL for
  75       *
  76       * @return array  A hash containing information on the ACL
  77       *                Array (
  78       *                    user => Array (
  79       *                                right => 1
  80       *                            )
  81       *                )
  82       */
  83      function getACL($folder)
  84      {
  85          return false;
  86      }
  87  
  88      /**
  89       * Sets the ACL on an IMAP server
  90       *
  91       * @param string $folder  The folder on which to edit the ACL
  92       *
  93       * @param string $share_user  The user to grant rights to
  94       *
  95       * @param array $acl  An array, the keys of which are the
  96       *                    rights to be granted (see RFC 2086)
  97       *
  98       * @return mixed  True on success, false on failure unless
  99       *                server doesn't support ACLs, returns 'no_support'
 100       */
 101      function createACL($folder, $share_user, $acl)
 102      {
 103          return false;
 104      }
 105  
 106      /**
 107       * Edits an ACL on an IMAP server
 108       *
 109       * @param string $folder  The folder on which to edit the ACL
 110       *
 111       * @param string $share_user  The user to grant rights to
 112       *
 113       * @param array $acl  An array, the keys of which are the
 114       *                    rights to be granted (see RFC 2086)
 115       *
 116       * @return mixed  True on success, false on failure unless
 117       *                server doesn't support ACLs, returns 'no_support'
 118       */
 119      function editACL($folder, $share_user, $acl)
 120      {
 121          return false;
 122      }
 123  
 124      /**
 125       * Can a user edit the ACL for this folder? Returns true if $user
 126       * permission to edit the ACL on $folder
 127       *
 128       * @param string $folder  The folder name
 129       *
 130       * @param string $user  A user name
 131       *
 132       * @return boolean  True if $user has 'a' right
 133       */
 134      function canEdit($folder, $user)
 135      {
 136          return true;
 137      }
 138  
 139      function getRights()
 140      {
 141          return $this->_rightsList;
 142      }
 143  
 144      function getProtected()
 145      {
 146          return $this->_protected;
 147      }
 148  
 149      function isSupported()
 150      {
 151          return $this->_supported;
 152      }
 153  
 154      function getError()
 155      {
 156          $error = $this->_error;
 157          $this->_error = null;
 158          return $error;
 159      }
 160  
 161      /**
 162       * Attempts to return an ACL instance based on $driver.
 163       *
 164       * @param string $driver  The type of concrete ACL subclass to return.
 165       * @param array $params   A hash containing any additional configuration or
 166       *                        connection parameters a subclass might need.
 167       *
 168       * @return mixed  The newly created concrete ACL instance, or false
 169       *                on error.
 170       */
 171      function &factory($driver, $params = array())
 172      {
 173          $driver = basename($driver);
 174          require_once dirname(__FILE__) . '/ACL/' . $driver . '.php';
 175          $class = 'IMAP_ACL_' . $driver;
 176          if (class_exists($class)) {
 177              $acl = &new $class($params);
 178          } else {
 179              $acl = false;
 180          }
 181  
 182          return $acl;
 183      }
 184  
 185      /**
 186       * Attempts to return a reference to a concrete ACL instance
 187       * based on $driver.  It will only create a new instance if no
 188       * ACL instance with the same parameters currently exists.
 189       *
 190       * This method must be invoked as: $var = &IMAP_ACL::singleton()
 191       *
 192       * @param string $driver  The type of concrete ACL subclass to return.
 193       * @param array $params   A hash containing any additional configuration or
 194       *                        connection parameters a subclass might need.
 195       *
 196       * @return mixed  The created concrete ACL instance, or false on error.
 197       */
 198      function &singleton($driver, $params = array())
 199      {
 200          static $instances;
 201  
 202          if (!isset($instances)) {
 203              $instances = array();
 204          }
 205  
 206          $signature = serialize(array($driver, $params));
 207          if (!isset($instances[$signature])) {
 208              $instances[$signature] = &IMAP_ACL::factory($driver, $params);
 209          }
 210  
 211          return $instances[$signature];
 212      }
 213  
 214  }


Généré le : Sun Feb 25 18:01:28 2007 par Balluche grâce à PHPXref 0.7