Driver -> Base
authorJan Schneider <jan@horde.org>
Mon, 23 Aug 2010 13:48:21 +0000 (15:48 +0200)
committerJan Schneider <jan@horde.org>
Mon, 23 Aug 2010 13:50:31 +0000 (15:50 +0200)
32 files changed:
framework/Lock/lib/Horde/Lock.php
framework/Lock/lib/Horde/Lock/Driver.php
framework/Lock/lib/Horde/Lock/Null.php
framework/Lock/lib/Horde/Lock/Sql.php
framework/SessionHandler/lib/Horde/SessionHandler.php
framework/SessionHandler/lib/Horde/SessionHandler/Base.php [new file with mode: 0644]
framework/SessionHandler/lib/Horde/SessionHandler/Builtin.php
framework/SessionHandler/lib/Horde/SessionHandler/Driver.php [deleted file]
framework/SessionHandler/lib/Horde/SessionHandler/External.php
framework/SessionHandler/lib/Horde/SessionHandler/Ldap.php
framework/SessionHandler/lib/Horde/SessionHandler/Memcache.php
framework/SessionHandler/lib/Horde/SessionHandler/Sql.php
framework/SessionHandler/lib/Horde/SessionHandler/Stack.php
framework/SessionHandler/package.xml
framework/Token/lib/Horde/Token/Base.php [new file with mode: 0644]
framework/Token/lib/Horde/Token/Driver.php [deleted file]
framework/Token/package.xml
imp/lib/Compose.php
imp/lib/Quota/Base.php [new file with mode: 0644]
imp/lib/Quota/Command.php
imp/lib/Quota/Driver.php [deleted file]
imp/lib/Quota/Hook.php
imp/lib/Quota/Imap.php
imp/lib/Quota/Maildir.php
imp/lib/Quota/Mdaemon.php
imp/lib/Quota/Mercury32.php
imp/lib/Quota/Null.php
imp/lib/Quota/Sql.php
imp/lib/Sentmail/Base.php [new file with mode: 0644]
imp/lib/Sentmail/Driver.php [deleted file]
imp/lib/Sentmail/Null.php
imp/lib/Sentmail/Sql.php

index fd3588b..92219c8 100644 (file)
@@ -27,7 +27,7 @@ class Horde_Lock
      * @param array $params  A hash containing any additional configuration or
      *                       connection parameters a subclass might need.
      *
-     * @return Horde_Lock_Driver  The newly created concrete instance.
+     * @return Horde_Lock_Base  The newly created concrete instance.
      * @throws Horde_Lock_Exception
      */
     static public function factory($driver, $params = array())
index 86f2197..b9b3e5a 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * The Horde_Lock_Driver class defines the Horde_Lock driver API.
+ * The Horde_Lock_Base class defines the Horde_Lock driver API.
  *
  * Copyright 2008-2010 The Horde Project (http://www.horde.org/)
  *
@@ -11,7 +11,7 @@
  * @category Horde
  * @package  Lock
  */
-abstract class Horde_Lock_Driver
+abstract class Horde_Lock_Base
 {
     /**
      * Driver parameters.
index 5be8789..b180a84 100644 (file)
@@ -11,7 +11,7 @@
  * @category Horde
  * @package  Lock
  */
-class Horde_Lock_Null extends Horde_Lock_Driver
+class Horde_Lock_Null extends Horde_Lock_Base
 {
     /**
      * Return an array of information about the requested lock.
index 251beeb..d874e8b 100644 (file)
@@ -28,7 +28,7 @@
  * @category Horde
  * @package  Lock
  */
-class Horde_Lock_Sql extends Horde_Lock_Driver
+class Horde_Lock_Sql extends Horde_Lock_Base
 {
     /**
      * Handle for the current database connection.
@@ -73,7 +73,7 @@ class Horde_Lock_Sql extends Horde_Lock_Driver
     /**
      * Return an array of information about the requested lock.
      *
-     * @see Horde_Lock_Driver::getLockInfo()
+     * @see Horde_Lock_Base::getLockInfo()
      */
     public function getLockInfo($lockid)
     {
@@ -95,7 +95,7 @@ class Horde_Lock_Sql extends Horde_Lock_Driver
      * Return a list of valid locks with the option to limit the results
      * by principal, scope and/or type.
      *
-     * @see Horde_Lock_Driver::getLocks()
+     * @see Horde_Lock_Base::getLocks()
      */
     public function getLocks($scope = null, $principal = null, $type = null)
     {
@@ -137,7 +137,7 @@ class Horde_Lock_Sql extends Horde_Lock_Driver
     /**
      * Extend the valid lifetime of a valid lock to now + $newtimeout.
      *
-     * @see Horde_Lock_Driver::resetLock()
+     * @see Horde_Lock_Base::resetLock()
      */
     public function resetLock($lockid, $extend)
     {
@@ -166,7 +166,7 @@ class Horde_Lock_Sql extends Horde_Lock_Driver
      * Sets a lock on the requested principal and returns the generated lock
      * ID.
      *
-     * @see Horde_Lock_Driver::setLock()
+     * @see Horde_Lock_Base::setLock()
      */
     public function setLock($requestor, $scope, $principal,
                             $lifetime = 1, $type = Horde_Lock::TYPE_SHARED)
@@ -205,7 +205,7 @@ class Horde_Lock_Sql extends Horde_Lock_Driver
     /**
      * Removes a lock given the lock ID.
      *
-     * @see Horde_Lock_Driver::clearLock()
+     * @see Horde_Lock_Base::clearLock()
      */
     public function clearLock($lockid)
     {
index ce26e01..e6e578a 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Horde_SessionHandler:: defines an API for implementing custom PHP session
+ * Horde_SessionHandler defines an API for implementing custom PHP session
  * handlers.
  *
  * Copyright 2002-2010 The Horde Project (http://www.horde.org/)
diff --git a/framework/SessionHandler/lib/Horde/SessionHandler/Base.php b/framework/SessionHandler/lib/Horde/SessionHandler/Base.php
new file mode 100644 (file)
index 0000000..10d65fb
--- /dev/null
@@ -0,0 +1,332 @@
+<?php
+/**
+ * Horde_SessionHandler_Base is the abstract class that all drivers inherit
+ * from.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @package  SessionHandler
+ */
+abstract class Horde_SessionHandler_Base
+{
+    /**
+     * Hash containing connection parameters.
+     *
+     * @var array
+     */
+    protected $_params = array();
+
+    /**
+     * Initial session data signature.
+     *
+     * @var string
+     */
+    protected $_sig;
+
+    /**
+     * Force saving the session data?
+     *
+     * @var boolean
+     */
+    protected $_force = false;
+
+    /**
+     * Has a connection been made to the backend?
+     *
+     * @var boolean
+     */
+    protected $_connected = false;
+
+    /**
+     * A logger instance.
+     *
+     * @var Horde_Log_Logger
+     */
+    protected $_logger;
+
+    /**
+     * Session variable name.
+     *
+     * @var string
+     */
+    protected $_session = 'horde_sh';
+
+    /**
+     * Constructor.
+     *
+     * @param array $params  Parameters:
+     * <pre>
+     * 'logger' - (Horde_Log_Logger) A logger instance.
+     *            DEFAULT: No logging
+     * 'noset' - (boolean) If true, don't set the save handler.
+     *           DEFAULT: false
+     * 'parse' - (callback) A callback function that parses session
+     *           information into an array. Is passed the raw session data
+     *           as the only argument; expects either false or an array of
+     *           session data as a return.
+     *           DEFAULT: No
+     * </pre>
+     */
+    public function __construct(array $params = array())
+    {
+        $params = array_merge($this->_params, $params);
+
+        if (isset($params['logger'])) {
+            $this->_logger = $params['logger'];
+            unset($params['logger']);
+        }
+
+        $this->_params = $params;
+
+        register_shutdown_function(array($this, 'shutdown'));
+
+        if (empty($this->_params['noset'])) {
+            ini_set('session.save_handler', 'user');
+            session_set_save_handler(
+                array($this, 'open'),
+                array($this, 'close'),
+                array($this, 'read'),
+                array($this, 'write'),
+                array($this, 'destroy'),
+                array($this, 'gc')
+            );
+        }
+    }
+
+    /**
+     * Destructor.
+     */
+    public function __destruct()
+    {
+        /* This is necessary as of PHP 5.0.5 because objects are not available
+         * when the write() handler is called at the end of a session
+         * access. */
+        session_write_close();
+    }
+
+    /**
+     * Shutdown function.
+     *
+     * Used to determine if we need to write the session to avoid a session
+     * timeout, even though the session is unchanged.
+     * Theory: On initial login, set the current time plus half of the max
+     * lifetime in the session.  Then check this timestamp before saving.
+     * If we exceed, force a write of the session and set a new timestamp.
+     * Why half the maxlifetime?  It guarantees that if we are accessing the
+     * server via a periodic mechanism (think folder refreshing in IMP) that
+     * we will catch this refresh.
+     */
+    public function shutdown()
+    {
+        $curr_time = time();
+
+        if (!isset($_SESSION[$this->_session]) ||
+            ($curr_time >= $_SESSION[$this->_session])) {
+            $_SESSION[$this->_session] = $curr_time + (ini_get('session.gc_maxlifetime') / 2);
+            $this->_force = true;
+        }
+    }
+
+    /**
+     * Open the backend.
+     *
+     * @param string $save_path     The path to the session object.
+     * @param string $session_name  The name of the session.
+     *
+     * @return boolean  True on success, false otherwise.
+     */
+    public function open($save_path = null, $session_name = null)
+    {
+        if (!$this->_connected) {
+            try {
+                $this->_open($save_path, $session_name);
+            } catch (Horde_SessionHandler_Exception $e) {
+                if ($this->_logger) {
+                    $this->_logger->log($e, 'ERR');
+                }
+                return false;
+            }
+
+            $this->_connected = true;
+        }
+
+        return true;
+    }
+
+    /**
+     * Open the backend.
+     *
+     * @param string $save_path     The path to the session object.
+     * @param string $session_name  The name of the session.
+     *
+     * @throws Horde_SessionHandler_Exception
+     */
+    abstract protected function _open($save_path = null, $session_name = null);
+
+    /**
+     * Close the backend.
+     *
+     * @return boolean  True on success, false otherwise.
+     */
+    public function close()
+    {
+        try {
+            $this->_close();
+        } catch (Horde_SessionHandler_Exception $e) {
+            if ($this->_logger) {
+                $this->_logger->log($e, 'ERR');
+            }
+            return false;
+        }
+
+        $this->_connected = false;
+        return true;
+    }
+
+    /**
+     * Close the backend.
+     *
+     * @throws Horde_SessionHandler_Exception
+     */
+    abstract protected function _close();
+
+    /**
+     * Read the data for a particular session identifier from the backend.
+     * This method should only be called internally by PHP via
+     * session_set_save_handler().
+     *
+     * @param string $id  The session identifier.
+     *
+     * @return string  The session data.
+     */
+    public function read($id)
+    {
+        $result = $this->_read($id);
+        $this->_sig = md5($result);
+        return $result;
+    }
+
+    /**
+     * Read the data for a particular session identifier from the backend.
+     *
+     * @param string $id  The session identifier.
+     *
+     * @return string  The session data.
+     */
+    abstract protected function _read($id);
+
+    /**
+     * Write session data to the backend.
+     * This method should only be called internally by PHP via
+     * session_set_save_handler().
+     *
+     * @param string $id            The session identifier.
+     * @param string $session_data  The session data.
+     *
+     * @return boolean  True on success, false otherwise.
+     */
+    public function write($id, $session_data)
+    {
+        if (!$this->_force && ($this->_sig == md5($session_data))) {
+            if ($this->_logger) {
+                $this->_logger->log('Session data unchanged (id = ' . $id . ')', 'DEBUG');
+            }
+            return true;
+        }
+
+        return $this->_write($id, $session_data);
+    }
+
+    /**
+     * Write session data to the backend.
+     *
+     * @param string $id            The session identifier.
+     * @param string $session_data  The session data.
+     *
+     * @return boolean  True on success, false otherwise.
+     */
+    abstract protected function _write($id, $session_data);
+
+    /**
+     * Destroy the data for a particular session identifier in the backend.
+     * This method should only be called internally by PHP via
+     * session_set_save_handler().
+     *
+     * @param string $id  The session identifier.
+     *
+     * @return boolean  True on success, false otherwise.
+     */
+    abstract public function destroy($id);
+
+    /**
+     * Garbage collect stale sessions from the backend.
+     * This method should only be called internally by PHP via
+     * session_set_save_handler().
+     *
+     * @param integer $maxlifetime  The maximum age of a session.
+     *
+     * @return boolean  True on success, false otherwise.
+     */
+    abstract public function gc($maxlifetime = 300);
+
+    /**
+     * Get session data read-only.
+     *
+     * @param string $id  The session identifier.
+     *
+     * @return string  The session data.
+     */
+    protected function _readOnly($id)
+    {
+        return $this->read($id);
+    }
+
+    /**
+     * Get a list of the valid session identifiers.
+     *
+     * @return array  A list of valid session identifiers.
+     * @throws Horde_SessionHandler_Exception
+     */
+    abstract public function getSessionIDs();
+
+    /**
+     * Returns a list of authenticated users and data about their session.
+     *
+     * @return array  For authenticated users, the sessionid as a key and the
+     *                session information as value. If no parsing function
+     *                was provided, will always return an empty array.
+     * @throws Horde_SessionHandler_Exception
+     */
+    public function getSessionsInfo()
+    {
+        $info = array();
+
+        if (empty($this->_params['parse']) ||
+            !is_callable($this->_params['parse'])) {
+            return $info;
+        }
+
+        $sessions = $this->getSessionIDs();
+
+        foreach ($sessions as $id) {
+            try {
+                $data = $this->_readOnly($id);
+            } catch (Horde_SessionHandler_Exception $e) {
+                continue;
+            }
+
+            $data = call_user_func($this->_params['parse'], $data);
+            if ($data !== false) {
+                $info[$id] = $data;
+            }
+        }
+
+        return $info;
+    }
+
+}
index 06f8434..7e9c95e 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * SessionHandler:: implementation for PHP's built-in session handler.
+ * Horde_SessionHandler implementation for PHP's built-in session handler.
  * This doesn't do any session handling itself - instead, it exists to allow
  * utility features to be used with the built-in PHP handler.
  *
@@ -13,7 +13,7 @@
  * @category Horde
  * @package  SessionHandler
  */
-class Horde_SessionHandler_Builtin extends Horde_SessionHandler_Driver
+class Horde_SessionHandler_Builtin extends Horde_SessionHandler_Base
 {
     /**
      * Constructor.
diff --git a/framework/SessionHandler/lib/Horde/SessionHandler/Driver.php b/framework/SessionHandler/lib/Horde/SessionHandler/Driver.php
deleted file mode 100644 (file)
index 04bb041..0000000
+++ /dev/null
@@ -1,332 +0,0 @@
-<?php
-/**
- * Horde_SessionHandler_Driver:: is the abstract class that all drivers
- * inherit from.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author   Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @package  SessionHandler
- */
-abstract class Horde_SessionHandler_Driver
-{
-    /**
-     * Hash containing connection parameters.
-     *
-     * @var array
-     */
-    protected $_params = array();
-
-    /**
-     * Initial session data signature.
-     *
-     * @var string
-     */
-    protected $_sig;
-
-    /**
-     * Force saving the session data?
-     *
-     * @var boolean
-     */
-    protected $_force = false;
-
-    /**
-     * Has a connection been made to the backend?
-     *
-     * @var boolean
-     */
-    protected $_connected = false;
-
-    /**
-     * A logger instance.
-     *
-     * @var Horde_Log_Logger
-     */
-    protected $_logger;
-
-    /**
-     * Session variable name.
-     *
-     * @var string
-     */
-    protected $_session = 'horde_sh';
-
-    /**
-     * Constructor.
-     *
-     * @param array $params  Parameters:
-     * <pre>
-     * 'logger' - (Horde_Log_Logger) A logger instance.
-     *            DEFAULT: No logging
-     * 'noset' - (boolean) If true, don't set the save handler.
-     *           DEFAULT: false
-     * 'parse' - (callback) A callback function that parses session
-     *           information into an array. Is passed the raw session data
-     *           as the only argument; expects either false or an array of
-     *           session data as a return.
-     *           DEFAULT: No
-     * </pre>
-     */
-    public function __construct(array $params = array())
-    {
-        $params = array_merge($this->_params, $params);
-
-        if (isset($params['logger'])) {
-            $this->_logger = $params['logger'];
-            unset($params['logger']);
-        }
-
-        $this->_params = $params;
-
-        register_shutdown_function(array($this, 'shutdown'));
-
-        if (empty($this->_params['noset'])) {
-            ini_set('session.save_handler', 'user');
-            session_set_save_handler(
-                array($this, 'open'),
-                array($this, 'close'),
-                array($this, 'read'),
-                array($this, 'write'),
-                array($this, 'destroy'),
-                array($this, 'gc')
-            );
-        }
-    }
-
-    /**
-     * Destructor.
-     */
-    public function __destruct()
-    {
-        /* This is necessary as of PHP 5.0.5 because objects are not available
-         * when the write() handler is called at the end of a session
-         * access. */
-        session_write_close();
-    }
-
-    /**
-     * Shutdown function.
-     *
-     * Used to determine if we need to write the session to avoid a session
-     * timeout, even though the session is unchanged.
-     * Theory: On initial login, set the current time plus half of the max
-     * lifetime in the session.  Then check this timestamp before saving.
-     * If we exceed, force a write of the session and set a new timestamp.
-     * Why half the maxlifetime?  It guarantees that if we are accessing the
-     * server via a periodic mechanism (think folder refreshing in IMP) that
-     * we will catch this refresh.
-     */
-    public function shutdown()
-    {
-        $curr_time = time();
-
-        if (!isset($_SESSION[$this->_session]) ||
-            ($curr_time >= $_SESSION[$this->_session])) {
-            $_SESSION[$this->_session] = $curr_time + (ini_get('session.gc_maxlifetime') / 2);
-            $this->_force = true;
-        }
-    }
-
-    /**
-     * Open the backend.
-     *
-     * @param string $save_path     The path to the session object.
-     * @param string $session_name  The name of the session.
-     *
-     * @return boolean  True on success, false otherwise.
-     */
-    public function open($save_path = null, $session_name = null)
-    {
-        if (!$this->_connected) {
-            try {
-                $this->_open($save_path, $session_name);
-            } catch (Horde_SessionHandler_Exception $e) {
-                if ($this->_logger) {
-                    $this->_logger->log($e, 'ERR');
-                }
-                return false;
-            }
-
-            $this->_connected = true;
-        }
-
-        return true;
-    }
-
-    /**
-     * Open the backend.
-     *
-     * @param string $save_path     The path to the session object.
-     * @param string $session_name  The name of the session.
-     *
-     * @throws Horde_SessionHandler_Exception
-     */
-    abstract protected function _open($save_path = null, $session_name = null);
-
-    /**
-     * Close the backend.
-     *
-     * @return boolean  True on success, false otherwise.
-     */
-    public function close()
-    {
-        try {
-            $this->_close();
-        } catch (Horde_SessionHandler_Exception $e) {
-            if ($this->_logger) {
-                $this->_logger->log($e, 'ERR');
-            }
-            return false;
-        }
-
-        $this->_connected = false;
-        return true;
-    }
-
-    /**
-     * Close the backend.
-     *
-     * @throws Horde_SessionHandler_Exception
-     */
-    abstract protected function _close();
-
-    /**
-     * Read the data for a particular session identifier from the backend.
-     * This method should only be called internally by PHP via
-     * session_set_save_handler().
-     *
-     * @param string $id  The session identifier.
-     *
-     * @return string  The session data.
-     */
-    public function read($id)
-    {
-        $result = $this->_read($id);
-        $this->_sig = md5($result);
-        return $result;
-    }
-
-    /**
-     * Read the data for a particular session identifier from the backend.
-     *
-     * @param string $id  The session identifier.
-     *
-     * @return string  The session data.
-     */
-    abstract protected function _read($id);
-
-    /**
-     * Write session data to the backend.
-     * This method should only be called internally by PHP via
-     * session_set_save_handler().
-     *
-     * @param string $id            The session identifier.
-     * @param string $session_data  The session data.
-     *
-     * @return boolean  True on success, false otherwise.
-     */
-    public function write($id, $session_data)
-    {
-        if (!$this->_force && ($this->_sig == md5($session_data))) {
-            if ($this->_logger) {
-                $this->_logger->log('Session data unchanged (id = ' . $id . ')', 'DEBUG');
-            }
-            return true;
-        }
-
-        return $this->_write($id, $session_data);
-    }
-
-    /**
-     * Write session data to the backend.
-     *
-     * @param string $id            The session identifier.
-     * @param string $session_data  The session data.
-     *
-     * @return boolean  True on success, false otherwise.
-     */
-    abstract protected function _write($id, $session_data);
-
-    /**
-     * Destroy the data for a particular session identifier in the backend.
-     * This method should only be called internally by PHP via
-     * session_set_save_handler().
-     *
-     * @param string $id  The session identifier.
-     *
-     * @return boolean  True on success, false otherwise.
-     */
-    abstract public function destroy($id);
-
-    /**
-     * Garbage collect stale sessions from the backend.
-     * This method should only be called internally by PHP via
-     * session_set_save_handler().
-     *
-     * @param integer $maxlifetime  The maximum age of a session.
-     *
-     * @return boolean  True on success, false otherwise.
-     */
-    abstract public function gc($maxlifetime = 300);
-
-    /**
-     * Get session data read-only.
-     *
-     * @param string $id  The session identifier.
-     *
-     * @return string  The session data.
-     */
-    protected function _readOnly($id)
-    {
-        return $this->read($id);
-    }
-
-    /**
-     * Get a list of the valid session identifiers.
-     *
-     * @return array  A list of valid session identifiers.
-     * @throws Horde_SessionHandler_Exception
-     */
-    abstract public function getSessionIDs();
-
-    /**
-     * Returns a list of authenticated users and data about their session.
-     *
-     * @return array  For authenticated users, the sessionid as a key and the
-     *                session information as value. If no parsing function
-     *                was provided, will always return an empty array.
-     * @throws Horde_SessionHandler_Exception
-     */
-    public function getSessionsInfo()
-    {
-        $info = array();
-
-        if (empty($this->_params['parse']) ||
-            !is_callable($this->_params['parse'])) {
-            return $info;
-        }
-
-        $sessions = $this->getSessionIDs();
-
-        foreach ($sessions as $id) {
-            try {
-                $data = $this->_readOnly($id);
-            } catch (Horde_SessionHandler_Exception $e) {
-                continue;
-            }
-
-            $data = call_user_func($this->_params['parse'], $data);
-            if ($data !== false) {
-                $info[$id] = $data;
-            }
-        }
-
-        return $info;
-    }
-
-}
index 147e4a5..8f4abe1 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Horde_SessionHandler_External:: implements an external save handler defined
+ * Horde_SessionHandler_External implements an external save handler defined
  * via driver configuration parameters.
  *
  * Copyright 2010 The Horde Project (http://www.horde.org/)
@@ -12,7 +12,7 @@
  * @category Horde
  * @package  SessionHandler
  */
-class Horde_SessionHandler_External extends Horde_SessionHandler_Driver
+class Horde_SessionHandler_External extends Horde_SessionHandler_Base
 {
     /**
      * Constructor.
index 7d811c5..ade950c 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * SessionHandler implementation for LDAP directories.
+ * Horde_SessionHandler implementation for LDAP directories.
  *
  * This code is adapted from the comments at
  * http://www.php.net/session-set-save-handler.
@@ -13,7 +13,7 @@
  * @category Horde
  * @package  SessionHandler
  */
-class Horde_SessionHandler_Ldap extends Horde_SessionHandler_Driver
+class Horde_SessionHandler_Ldap extends Horde_SessionHandler_Base
 {
     /**
      * Horde_Ldap object.
index f48dff9..59661fa 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * SessionHandler implementation for memcache.
+ * Horde_SessionHandler implementation for memcache.
  *
  * Copyright 2005-2010 The Horde Project (http://www.horde.org/)
  *
@@ -12,7 +12,7 @@
  * @category Horde
  * @package  SessionHandler
  */
-class Horde_SessionHandler_Memcache extends Horde_SessionHandler_Driver
+class Horde_SessionHandler_Memcache extends Horde_SessionHandler_Base
 {
     /**
      * Memcache object.
index 0bbbad8..61618dc 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * SessionHandler implementation for SQL databases.
+ * Horde_SessionHandler implementation for SQL databases.
  *
  * The table structure can be found in:
  *   horde/scripts/sql/horde_sessionhandler.sql.
@@ -14,7 +14,7 @@
  * @category Horde
  * @package  SessionHandler
  */
-class Horde_SessionHandler_Sql extends Horde_SessionHandler_Driver
+class Horde_SessionHandler_Sql extends Horde_SessionHandler_Base
 {
     /**
      * Handle for the current database connection.
index 76c82d4..7e40187 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /**
- * Horde_SessionHandler_Stack:: is an implementation that will loop through
- * a given list of Horde_SessionHandler_Drivers to return the session
+ * Horde_SessionHandler_Stack is an implementation that will loop through a
+ * given list of Horde_SessionHandler drivers to return the session
  * information.  This driver allows for use of caching backends on top of
  * persistent backends.
  *
@@ -14,7 +14,7 @@
  * @category Horde
  * @package  SessionHandler
  */
-class Horde_SessionHandler_Stack extends Horde_SessionHandler_Driver
+class Horde_SessionHandler_Stack extends Horde_SessionHandler_Base
 {
     /**
      * Stack of sessionhandlers.
index 2caac1b..cce1f5e 100644 (file)
@@ -50,7 +50,7 @@
     <dir name="Horde">
      <dir name="SessionHandler">
       <file name="Builtin.php" role="php" />
-      <file name="Driver.php" role="php" />
+      <file name="Base.php" role="php" />
       <file name="Exception.php" role="php" />
       <file name="External.php" role="php" />
       <file name="Ldap.php" role="php" />
@@ -99,7 +99,7 @@
   <filelist>
    <install as="Horde/SessionHandler.php" name="lib/Horde/SessionHandler.php" />
    <install as="Horde/SessionHandler/Builtin.php" name="lib/Horde/SessionHandler/Builtin.php" />
-   <install as="Horde/SessionHandler/Driver.php" name="lib/Horde/SessionHandler/Driver.php" />
+   <install as="Horde/SessionHandler/Base.php" name="lib/Horde/SessionHandler/Base.php" />
    <install as="Horde/SessionHandler/Exception.php" name="lib/Horde/SessionHandler/Exception.php" />
    <install as="Horde/SessionHandler/External.php" name="lib/Horde/SessionHandler/External.php" />
    <install as="Horde/SessionHandler/Ldap.php" name="lib/Horde/SessionHandler/Ldap.php" />
diff --git a/framework/Token/lib/Horde/Token/Base.php b/framework/Token/lib/Horde/Token/Base.php
new file mode 100644 (file)
index 0000000..d6407f5
--- /dev/null
@@ -0,0 +1,112 @@
+<?php
+/**
+ * The Horde_Token_Driver:: class provides a common abstracted interface for
+ * a token driver.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author   Max Kalika <max@horde.org>
+ * @author   Chuck Hagenbuch <chuck@horde.org>
+ * @category Horde
+ * @package  Token
+ */
+abstract class Horde_Token_Driver
+{
+    /**
+     * Logger.
+     *
+     * @var Horde_Log_Logger
+     */
+    protected $_logger;
+
+    /**
+     * Hash of parameters necessary to use the chosen backend.
+     *
+     * @var array
+     */
+    protected $_params = array();
+
+    /**
+     * Constructor.
+     *
+     * @param array $params  Optional parameters:
+     * <pre>
+     * 'logger' - (Horde_Log_Logger) A logger object.
+     * </pre>
+     */
+    public function __construct($params)
+    {
+        if (isset($params['logger'])) {
+            $this->_logger = $params['logger'];
+            unset($params['logger']);
+        }
+
+        $this->_params = $params;
+    }
+
+    /**
+     * Checks if the given token has been previously used. First
+     * purges all expired tokens. Then retrieves current tokens for
+     * the given ip address. If the specified token was not found,
+     * adds it.
+     *
+     * @param string $token  The value of the token to check.
+     *
+     * @return boolean  True if the token has not been used, false otherwise.
+     * @throws Horde_Token_Exception
+     */
+    public function verify($token)
+    {
+        $this->purge();
+
+        if ($this->exists($token)) {
+            return false;
+        }
+
+        $this->add($token);
+        return true;
+    }
+
+    /**
+     * Does the token exist?
+     *
+     * @param string $tokenID  Token ID.
+     *
+     * @return boolean  True if the token exists.
+     * @throws Horde_Token_Exception
+     */
+    abstract public function exists($tokenID);
+
+    /**
+     * Add a token ID.
+     *
+     * @param string $tokenID  Token ID to add.
+     *
+     * @throws Horde_Token_Exception
+     */
+    abstract public function add($tokenID);
+
+    /**
+     * Delete all expired connection IDs.
+     *
+     * @throws Horde_Token_Exception
+     */
+    abstract public function purge();
+
+    /**
+     * Encodes the remote address.
+     *
+     * @return string  Encoded address.
+     */
+    protected function _encodeRemoteAddress()
+    {
+        return isset($_SERVER['REMOTE_ADDR'])
+            ? base64_encode($_SERVER['REMOTE_ADDR'])
+            : '';
+    }
+
+
+}
diff --git a/framework/Token/lib/Horde/Token/Driver.php b/framework/Token/lib/Horde/Token/Driver.php
deleted file mode 100644 (file)
index d6407f5..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-<?php
-/**
- * The Horde_Token_Driver:: class provides a common abstracted interface for
- * a token driver.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author   Max Kalika <max@horde.org>
- * @author   Chuck Hagenbuch <chuck@horde.org>
- * @category Horde
- * @package  Token
- */
-abstract class Horde_Token_Driver
-{
-    /**
-     * Logger.
-     *
-     * @var Horde_Log_Logger
-     */
-    protected $_logger;
-
-    /**
-     * Hash of parameters necessary to use the chosen backend.
-     *
-     * @var array
-     */
-    protected $_params = array();
-
-    /**
-     * Constructor.
-     *
-     * @param array $params  Optional parameters:
-     * <pre>
-     * 'logger' - (Horde_Log_Logger) A logger object.
-     * </pre>
-     */
-    public function __construct($params)
-    {
-        if (isset($params['logger'])) {
-            $this->_logger = $params['logger'];
-            unset($params['logger']);
-        }
-
-        $this->_params = $params;
-    }
-
-    /**
-     * Checks if the given token has been previously used. First
-     * purges all expired tokens. Then retrieves current tokens for
-     * the given ip address. If the specified token was not found,
-     * adds it.
-     *
-     * @param string $token  The value of the token to check.
-     *
-     * @return boolean  True if the token has not been used, false otherwise.
-     * @throws Horde_Token_Exception
-     */
-    public function verify($token)
-    {
-        $this->purge();
-
-        if ($this->exists($token)) {
-            return false;
-        }
-
-        $this->add($token);
-        return true;
-    }
-
-    /**
-     * Does the token exist?
-     *
-     * @param string $tokenID  Token ID.
-     *
-     * @return boolean  True if the token exists.
-     * @throws Horde_Token_Exception
-     */
-    abstract public function exists($tokenID);
-
-    /**
-     * Add a token ID.
-     *
-     * @param string $tokenID  Token ID to add.
-     *
-     * @throws Horde_Token_Exception
-     */
-    abstract public function add($tokenID);
-
-    /**
-     * Delete all expired connection IDs.
-     *
-     * @throws Horde_Token_Exception
-     */
-    abstract public function purge();
-
-    /**
-     * Encodes the remote address.
-     *
-     * @return string  Encoded address.
-     */
-    protected function _encodeRemoteAddress()
-    {
-        return isset($_SERVER['REMOTE_ADDR'])
-            ? base64_encode($_SERVER['REMOTE_ADDR'])
-            : '';
-    }
-
-
-}
index 0ff03e8..2b16147 100644 (file)
@@ -27,7 +27,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
  </stability>
  <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
  <notes>* Add Horde_Token_Exception::.
- * Move driver code into Horde_Token_Driver::.
+ * Move driver code into sub-classes.
  * Use exceptions, not PEAR_Errors.
  * Initial Horde 4 package.
  </notes>
@@ -36,7 +36,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
    <dir name="lib">
     <dir name="Horde">
      <dir name="Token">
-      <file name="Driver.php" role="php" />
+      <file name="Base.php" role="php" />
       <file name="Exception.php" role="php" />
       <file name="File.php" role="php" />
       <file name="Null.php" role="php" />
@@ -81,7 +81,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
  </dependencies>
  <phprelease>
   <filelist>
-   <install name="lib/Horde/Token/Driver.php" as="Horde/Token/Driver.php" />
+   <install name="lib/Horde/Token/Base.php" as="Horde/Token/Base.php" />
    <install name="lib/Horde/Token/Exception.php" as="Horde/Token/Exception.php" />
    <install name="lib/Horde/Token/File.php" as="Horde/Token/File.php" />
    <install name="lib/Horde/Token/Null.php" as="Horde/Token/Null.php" />
index fe0b2d3..5a95ea9 100644 (file)
@@ -769,7 +769,7 @@ class IMP_Compose
         $timelimit = $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_timelimit');
         if ($timelimit !== true) {
             $sentmail = $GLOBALS['injector']->getInstance('IMP_Sentmail');
-            if (!is_subclass_of($sentmail, 'IMP_Sentmail_Driver')) {
+            if (!($sentmail instanceof IMP_Sentmail_Base)) {
                 Horde::logMessage('The permission for the maximum number of recipients per time period has been enabled, but no backend for the sent-mail logging has been configured for IMP.', 'ERR');
                 throw new IMP_Compose_Exception(_("The system is not properly configured. A detailed error description has been logged for the administrator."));
             }
diff --git a/imp/lib/Quota/Base.php b/imp/lib/Quota/Base.php
new file mode 100644 (file)
index 0000000..5138824
--- /dev/null
@@ -0,0 +1,107 @@
+<?php
+/**
+ * The IMP_Quota_Base:: class is the abstract class that all driver
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/gpl.html GPL
+ * @package  IMP
+ */
+abstract class IMP_Quota_Base
+{
+    /**
+     * Driver parameters.
+     *
+     * @var array
+     */
+    protected $_params = array(
+        'unit' => 'MB'
+    );
+
+    /**
+     * Constructor.
+     *
+     * @param array $params  Parameters:
+     * <pre>
+     * 'format' - (string) The formats of the quota messages in the user
+     *            interface. Must be a hash with the four possible elements
+     *            'long', 'short', 'nolimit_long', and 'nolimit_short'. The
+     *            strings will be passed through sprintf().
+     * 'unit' - (string) What storage unit the quota messages should be
+     *          displayed in. Either 'GB', 'MB', or 'KB'.
+     * </pre>
+     */
+    public function __construct(array $params = array())
+    {
+        $this->_params = array_merge($this->_params, $params);
+
+        $this->_params['format'] = array(
+            'long' => isset($this->_params['format']['long'])
+                ? $this->_params['format']['long']
+                : _("Quota status: %.2f %s / %.2f %s  (%.2f%%)"),
+            'short' => isset($this->_params['format']['short'])
+                ? $this->_params['format']['short']
+                : _("%.0f%% of %.0f %s"),
+            'nolimit_long' => isset($this->_params['format']['nolimit_long'])
+                ? $this->_params['format']['nolimit_long']
+                : _("Quota status: %.2f %s / NO LIMIT"),
+            'nolimit_short' => isset($this->_params['format']['nolimit_short'])
+                ? $this->_params['format']['nolimit_short']
+                : _("%.0f %s")
+        );
+    }
+
+    /**
+     * Get quota information (used/allocated), in bytes.
+     *
+     * @return array  An array with the following keys:
+     *                'limit' = Maximum quota allowed
+     *                'usage' = Currently used portion of quota (in bytes)
+     * @throws IMP_Exception
+     */
+    abstract public function getQuota();
+
+    /**
+     * Returns the quota messages variants, including sprintf placeholders.
+     *
+     * @return array  An array with quota message templates.
+     */
+    public function getMessages()
+    {
+        return $this->_params['format'];
+    }
+
+    /**
+     * Determine the units of storage to display in the quota message.
+     *
+     * @return array  An array of size and unit type.
+     */
+    public function getUnit()
+    {
+        $unit = $this->_params['unit'];
+
+        switch ($unit) {
+        case 'GB':
+            $calc = 1024 * 1024 * 1024.0;
+            break;
+
+        case 'KB':
+            $calc = 1024.0;
+            break;
+
+        case 'MB':
+        default:
+            $calc = 1024 * 1024.0;
+            $unit = 'MB';
+            break;
+        }
+
+        return array($calc, $unit);
+    }
+
+}
index 070b7c6..624d1d9 100644 (file)
@@ -17,7 +17,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Quota_Command extends IMP_Quota_Driver
+class IMP_Quota_Command extends IMP_Quota_Base
 {
     /**
      * Constructor.
diff --git a/imp/lib/Quota/Driver.php b/imp/lib/Quota/Driver.php
deleted file mode 100644 (file)
index 96b1100..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-<?php
-/**
- * The IMP_Quota_Driver:: class is the abstract class that all driver
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author   Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license  http://www.fsf.org/copyleft/gpl.html GPL
- * @package  IMP
- */
-abstract class IMP_Quota_Driver
-{
-    /**
-     * Driver parameters.
-     *
-     * @var array
-     */
-    protected $_params = array(
-        'unit' => 'MB'
-    );
-
-    /**
-     * Constructor.
-     *
-     * @param array $params  Parameters:
-     * <pre>
-     * 'format' - (string) The formats of the quota messages in the user
-     *            interface. Must be a hash with the four possible elements
-     *            'long', 'short', 'nolimit_long', and 'nolimit_short'. The
-     *            strings will be passed through sprintf().
-     * 'unit' - (string) What storage unit the quota messages should be
-     *          displayed in. Either 'GB', 'MB', or 'KB'.
-     * </pre>
-     */
-    public function __construct(array $params = array())
-    {
-        $this->_params = array_merge($this->_params, $params);
-
-        $this->_params['format'] = array(
-            'long' => isset($this->_params['format']['long'])
-                ? $this->_params['format']['long']
-                : _("Quota status: %.2f %s / %.2f %s  (%.2f%%)"),
-            'short' => isset($this->_params['format']['short'])
-                ? $this->_params['format']['short']
-                : _("%.0f%% of %.0f %s"),
-            'nolimit_long' => isset($this->_params['format']['nolimit_long'])
-                ? $this->_params['format']['nolimit_long']
-                : _("Quota status: %.2f %s / NO LIMIT"),
-            'nolimit_short' => isset($this->_params['format']['nolimit_short'])
-                ? $this->_params['format']['nolimit_short']
-                : _("%.0f %s")
-        );
-    }
-
-    /**
-     * Get quota information (used/allocated), in bytes.
-     *
-     * @return array  An array with the following keys:
-     *                'limit' = Maximum quota allowed
-     *                'usage' = Currently used portion of quota (in bytes)
-     * @throws IMP_Exception
-     */
-    abstract public function getQuota();
-
-    /**
-     * Returns the quota messages variants, including sprintf placeholders.
-     *
-     * @return array  An array with quota message templates.
-     */
-    public function getMessages()
-    {
-        return $this->_params['format'];
-    }
-
-    /**
-     * Determine the units of storage to display in the quota message.
-     *
-     * @return array  An array of size and unit type.
-     */
-    public function getUnit()
-    {
-        $unit = $this->_params['unit'];
-
-        switch ($unit) {
-        case 'GB':
-            $calc = 1024 * 1024 * 1024.0;
-            break;
-
-        case 'KB':
-            $calc = 1024.0;
-            break;
-
-        case 'MB':
-        default:
-            $calc = 1024 * 1024.0;
-            $unit = 'MB';
-            break;
-        }
-
-        return array($calc, $unit);
-    }
-
-}
index 8dfcd7e..6a07813 100644 (file)
@@ -19,7 +19,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Quota_Hook extends IMP_Quota_Driver
+class IMP_Quota_Hook extends IMP_Quota_Base
 {
     /**
      * Get quota information (used/allocated), in bytes.
index de52e90..404b67b 100644 (file)
@@ -12,7 +12,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Quota_Imap extends IMP_Quota_Driver
+class IMP_Quota_Imap extends IMP_Quota_Base
 {
     /**
      * Constructor.
index 03aa4ec..885e599 100644 (file)
@@ -16,7 +16,7 @@
  * @package  IMP
  * @todo     Add config param for storage vs message quota
  */
-class IMP_Quota_Maildir extends IMP_Quota_Driver
+class IMP_Quota_Maildir extends IMP_Quota_Base
 {
     /**
      * Constructor.
index 3e7817f..4724f49 100644 (file)
@@ -12,7 +12,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Quota_Mdaemon extends IMP_Quota_Driver
+class IMP_Quota_Mdaemon extends IMP_Quota_Base
 {
     /**
      * Constructor.
index 05764c6..c0608d7 100644 (file)
@@ -30,7 +30,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Quota_Mercury32 extends IMP_Quota_Driver
+class IMP_Quota_Mercury32 extends IMP_Quota_Base
 {
     /**
      * Constructor.
index 20da360..bf768ee 100644 (file)
@@ -12,7 +12,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Quota_Null extends IMP_Quota_Driver
+class IMP_Quota_Null extends IMP_Quota_Base
 {
     /**
      * Get quota information (used/allocated), in bytes.
index 1657d4a..8c24bfe 100644 (file)
@@ -15,7 +15,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Quota_Sql extends IMP_Quota_Driver
+class IMP_Quota_Sql extends IMP_Quota_Base
 {
     /**
      * DB object.
diff --git a/imp/lib/Sentmail/Base.php b/imp/lib/Sentmail/Base.php
new file mode 100644 (file)
index 0000000..74c1792
--- /dev/null
@@ -0,0 +1,111 @@
+<?php
+/**
+ * The IMP_Sentmail_Base:: class is the abstract class that all driver
+ * implementations inherit from.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author   Jan Schneider <jan@horde.org>
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @package  IMP
+ */
+abstract class IMP_Sentmail_Base
+{
+    /**
+     * Hash containing configuration parameters.
+     *
+     * @var array
+     */
+    protected $_params = array();
+
+    /**
+     * Constructor.
+     *
+     * @throws IMP_Exception
+     */
+    public function __construct($params = array())
+    {
+        $this->_params = array_merge($this->_params, $params);
+    }
+
+    /**
+     * Logs an attempt to send a message.
+     *
+     * @param string $action            Why the message was sent, i.e. "new",
+     *                                  "reply", "forward", etc.
+     * @param string $message_id        The Message-ID.
+     * @param string|array $recipients  The list of message recipients.
+     * @param boolean $success          Whether the attempt was successful.
+     */
+    public function log($action, $message_id, $recipients, $success = true)
+    {
+        if (!is_array($recipients)) {
+            $recipients = array($recipients);
+        }
+
+        foreach ($recipients as $addresses) {
+            $addresses = Horde_Mime_Address::bareAddress($addresses, $_SESSION['imp']['maildomain'], true);
+            foreach ($addresses as $recipient) {
+                $this->_log($action, $message_id, $recipient, $success);
+            }
+        }
+    }
+
+    /**
+     * Garbage collect log entries.
+     */
+    public function gc()
+    {
+        $this->_deleteOldEntries(time() - ((isset($this->_params['threshold']) ? $this->_params['threshold'] : 0) * 86400));
+    }
+
+    /**
+     * Logs an attempt to send a message per recipient.
+     *
+     * @param string $action      Why the message was sent, i.e. "new",
+     *                            "reply", "forward", etc.
+     * @param string $message_id  The Message-ID.
+     * @param string $recipients  A message recipient.
+     * @param boolean $success    Whether the attempt was successful.
+     */
+    abstract protected function _log($action, $message_id, $recipient,
+                                     $success);
+
+    /**
+     * Returns the favourite recipients.
+     *
+     * @param integer $limit  Return this number of recipients.
+     * @param array $filter   A list of messages types that should be returned.
+     *                        A value of null returns all message types.
+     *
+     * @return array  A list with the $limit most favourite recipients.
+     * @throws IMP_Exception
+     */
+    abstract public function favouriteRecipients($limit,
+                                                 $filter = array('new', 'forward', 'reply', 'redirect'));
+
+    /**
+     * Returns the number of recipients within a certain time period.
+     *
+     * @param integer $hours  Time period in hours.
+     * @param boolean $user   Return the number of recipients for the current
+     *                        user?
+     *
+     * @return integer  The number of recipients in the given time period.
+     * @throws IMP_Exception
+     */
+    abstract public function numberOfRecipients($hours, $user = false);
+
+    /**
+     * Deletes all log entries older than a certain date.
+     *
+     * @param integer $before  Unix timestamp before that all log entries
+     *                         should be deleted.
+     */
+    abstract protected function _deleteOldEntries($before);
+
+}
diff --git a/imp/lib/Sentmail/Driver.php b/imp/lib/Sentmail/Driver.php
deleted file mode 100644 (file)
index d8c0bdf..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-<?php
-/**
- * The IMP_Sentmail_Driver:: class is the abstract class that all driver
- * implementations inherit from.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author   Jan Schneider <jan@horde.org>
- * @author   Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @package  IMP
- */
-abstract class IMP_Sentmail_Driver
-{
-    /**
-     * Hash containing configuration parameters.
-     *
-     * @var array
-     */
-    protected $_params = array();
-
-    /**
-     * Constructor.
-     *
-     * @throws IMP_Exception
-     */
-    public function __construct($params = array())
-    {
-        $this->_params = array_merge($this->_params, $params);
-    }
-
-    /**
-     * Logs an attempt to send a message.
-     *
-     * @param string $action            Why the message was sent, i.e. "new",
-     *                                  "reply", "forward", etc.
-     * @param string $message_id        The Message-ID.
-     * @param string|array $recipients  The list of message recipients.
-     * @param boolean $success          Whether the attempt was successful.
-     */
-    public function log($action, $message_id, $recipients, $success = true)
-    {
-        if (!is_array($recipients)) {
-            $recipients = array($recipients);
-        }
-
-        foreach ($recipients as $addresses) {
-            $addresses = Horde_Mime_Address::bareAddress($addresses, $_SESSION['imp']['maildomain'], true);
-            foreach ($addresses as $recipient) {
-                $this->_log($action, $message_id, $recipient, $success);
-            }
-        }
-    }
-
-    /**
-     * Garbage collect log entries.
-     */
-    public function gc()
-    {
-        $this->_deleteOldEntries(time() - ((isset($this->_params['threshold']) ? $this->_params['threshold'] : 0) * 86400));
-    }
-
-    /**
-     * Logs an attempt to send a message per recipient.
-     *
-     * @param string $action      Why the message was sent, i.e. "new",
-     *                            "reply", "forward", etc.
-     * @param string $message_id  The Message-ID.
-     * @param string $recipients  A message recipient.
-     * @param boolean $success    Whether the attempt was successful.
-     */
-    abstract protected function _log($action, $message_id, $recipient,
-                                     $success);
-
-    /**
-     * Returns the favourite recipients.
-     *
-     * @param integer $limit  Return this number of recipients.
-     * @param array $filter   A list of messages types that should be returned.
-     *                        A value of null returns all message types.
-     *
-     * @return array  A list with the $limit most favourite recipients.
-     * @throws IMP_Exception
-     */
-    abstract public function favouriteRecipients($limit,
-                                                 $filter = array('new', 'forward', 'reply', 'redirect'));
-
-    /**
-     * Returns the number of recipients within a certain time period.
-     *
-     * @param integer $hours  Time period in hours.
-     * @param boolean $user   Return the number of recipients for the current
-     *                        user?
-     *
-     * @return integer  The number of recipients in the given time period.
-     * @throws IMP_Exception
-     */
-    abstract public function numberOfRecipients($hours, $user = false);
-
-    /**
-     * Deletes all log entries older than a certain date.
-     *
-     * @param integer $before  Unix timestamp before that all log entries
-     *                         should be deleted.
-     */
-    abstract protected function _deleteOldEntries($before);
-
-}
index 7066a11..d73f448 100644 (file)
@@ -12,7 +12,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Sentmail_Null extends IMP_Sentmail_Driver
+class IMP_Sentmail_Null extends IMP_Sentmail_Base
 {
     /**
      * Garbage collect log entries.
index 7220796..80c97a2 100644 (file)
@@ -32,7 +32,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Sentmail_Sql extends IMP_Sentmail_Driver
+class IMP_Sentmail_Sql extends IMP_Sentmail_Base
 {
     /**
      * Handle for the current database connection.