[ Index ]
 

Code source de IMP H3 (4.1.5)

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/lib/ -> Quota.php (source)

   1  <?php
   2  /**
   3   * IMP_Quota:: provides an API for retrieving Quota details from a mail
   4   * server.
   5   *
   6   * $Horde: imp/lib/Quota.php,v 1.23.10.9 2007/01/02 13:54:56 jan Exp $
   7   *
   8   * Copyright 2002-2007 Mike Cochrane <mike@graftonhall.co.nz>
   9   *
  10   * See the enclosed file COPYING for license information (GPL). If you
  11   * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
  12   *
  13   * @author  Mike Cochrane <mike@graftonhall.co.nz>
  14   * @since   IMP 4.0
  15   * @package IMP_Quota
  16   */
  17  class IMP_Quota {
  18  
  19      /**
  20       * Hash containing connection parameters.
  21       *
  22       * @var array
  23       */
  24      var $_params = array();
  25  
  26      /**
  27       * Attempts to return a concrete Quota instance based on $driver.
  28       *
  29       * @param string $driver  The type of concrete Quota subclass to return.
  30       * @param array $params   A hash containing any additional configuration or
  31       *                        connection parameters a subclass might need.
  32       *
  33       * @return mixed  The newly created concrete Quota instance, or false
  34       *                on error.
  35       */
  36      function &factory($driver, $params = array())
  37      {
  38          $driver = basename($driver);
  39          require_once dirname(__FILE__) . '/Quota/' . $driver . '.php';
  40          $class = 'IMP_Quota_' . $driver;
  41          if (class_exists($class)) {
  42              $quota = &new $class($params);
  43          } else {
  44              $quota = false;
  45          }
  46  
  47          return $quota;
  48      }
  49  
  50      /**
  51       * Attempts to return a reference to a concrete Quota instance based on
  52       * $driver.
  53       *
  54       * It will only create a new instance if no Quota instance with the same
  55       * parameters currently exists.
  56       *
  57       * This should be used if multiple quota sources are required.
  58       *
  59       * This method must be invoked as: $var = &Quota::singleton()
  60       *
  61       * @param string $driver  The type of concrete Quota subclass to return.
  62       * @param array $params   A hash containing any additional configuration or
  63       *                        connection parameters a subclass might need.
  64       *
  65       * @return mixed  The created concrete Quota instance, or false on error.
  66       */
  67      function &singleton($driver, $params = array())
  68      {
  69          static $instances;
  70  
  71          if (!isset($instances)) {
  72              $instances = array();
  73          }
  74  
  75          $signature = serialize(array($driver, $params));
  76          if (!isset($instances[$signature])) {
  77              $instances[$signature] = &IMP_Quota::factory($driver, $params);
  78          }
  79  
  80          return $instances[$signature];
  81      }
  82  
  83      /**
  84       * Constructor.
  85       *
  86       * @param array $params  Hash containing connection parameters.
  87       */
  88      function IMP_Quota($params = array())
  89      {
  90          $this->_params = $params;
  91  
  92          /* If 'password' exists in params, it has been encrypted in the
  93           * session so we need to decrypt. */
  94          if (isset($this->_params['password'])) {
  95              $this->_params['password'] = Secret::read(Secret::getKey('imp'), $this->_params['password']);
  96          }
  97      }
  98  
  99      /**
 100       * Get quota information (used/allocated), in bytes.
 101       *
 102       * @return mixed  An associative array.
 103       *                'limit' = Maximum quota allowed
 104       *                'usage' = Currently used portion of quota (in bytes)
 105       *                Returns PEAR_Error on failure.
 106       */
 107      function getQuota()
 108      {
 109          return array('usage' => 0, 'limit' => 0);
 110      }
 111  
 112  }


Généré le : Thu Nov 29 12:30:07 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics