Collect duplicative code into base Builtin classes.
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 22 Sep 2010 06:00:42 +0000 (00:00 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 22 Sep 2010 06:17:25 +0000 (00:17 -0600)
imp/config/prefs.php.dist
imp/lib/Search/Filter/Builtin.php [new file with mode: 0644]
imp/lib/Search/Filter/Bulk.php
imp/lib/Search/Filter/Mailinglist.php
imp/lib/Search/Vfolder/Builtin.php [new file with mode: 0644]
imp/lib/Search/Vfolder/Vinbox.php
imp/lib/Search/Vfolder/Vtrash.php

index 113e7f8..4760312 100644 (file)
@@ -394,7 +394,7 @@ $_prefs['vfolder'] = array(
     //         'disable' => true
     //     ))
     // ))
-    'value' => 'a:1:{i:0;C:25:"IMP_Search_Vfolder_Vinbox":175:{a:3:{s:1:"c";a:2:{i:0;C:23:"IMP_Search_Element_Flag":24:{[1,{"f":"\\seen","s":0}]}i:1;C:23:"IMP_Search_Element_Flag":27:{[1,{"f":"\\deleted","s":0}]}}s:1:"e";i:1;s:1:"v";i:1;}}}'
+    'value' => 'a:1:{i:0;C:25:"IMP_Search_Vfolder_Vinbox":30:{a:2:{s:1:"e";i:1;s:1:"v";i:1;}}}'
 );
 
 $_prefs['filter'] = array(
@@ -408,7 +408,7 @@ $_prefs['filter'] = array(
     //         'disable' => false
     //     ))
     // ))
-    'value' => 'a:2:{i:0;C:22:"IMP_Search_Filter_Bulk":88:{a:3:{s:1:"c";a:1:{i:0;C:23:"IMP_Search_Element_Bulk":5:{[1,0]}}s:1:"e";i:1;s:1:"v";i:1;}}i:1;C:29:"IMP_Search_Filter_Mailinglist":95:{a:3:{s:1:"c";a:1:{i:0;C:30:"IMP_Search_Element_Mailinglist":5:{[1,0]}}s:1:"e";i:1;s:1:"v";i:1;}}}'
+    'value' => 'a:2:{i:0;C:22:"IMP_Search_Filter_Bulk":30:{a:2:{s:1:"e";i:1;s:1:"v";i:1;}}i:1;C:29:"IMP_Search_Filter_Mailinglist":30:{a:2:{s:1:"e";i:1;s:1:"v";i:1;}}}'
 );
 
 
diff --git a/imp/lib/Search/Filter/Builtin.php b/imp/lib/Search/Filter/Builtin.php
new file mode 100644 (file)
index 0000000..ee97090
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+/**
+ * This class provides the base definition for built-in filters.
+ *
+ * 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_Search_Filter_Builtin extends IMP_Search_Filter
+{
+    /**
+     * Can this query be edited?
+     *
+     * @var boolean
+     */
+    protected $_canEdit = false;
+
+    /**
+     * List of serialize entries not to save.
+     *
+     * @var array
+     */
+    protected $_nosave = array('c', 'i', 'l');
+
+    /**
+     * Constructor.
+     *
+     * The 'add', 'id', 'label', and 'mboxes' parameters are ignored.
+     *
+     * @see parent::__construct()
+     */
+    public function __construct(array $opts = array())
+    {
+        $this->enabled = empty($opts['disable']);
+
+        $this->_init();
+    }
+
+    /**
+     * Initialization tasks.
+     */
+    abstract protected function _init();
+
+    /**
+     * Unserialization.
+     *
+     * @param string $data  Serialized data.
+     *
+     * @throws Exception
+     */
+    public function unserialize($data)
+    {
+        parent::unserialize($data);
+        $this->_init();
+    }
+
+}
index 4fde711..098b890 100644 (file)
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Search_Filter_Bulk extends IMP_Search_Filter
+class IMP_Search_Filter_Bulk extends IMP_Search_Filter_Builtin
 {
     /**
-     * Can this query be edited?
-     *
-     * @var boolean
-     */
-    protected $_canEdit = false;
-
-    /**
-     * List of serialize entries not to save.
-     *
-     * @var array
-     */
-    protected $_nosave = array('i', 'l');
-
-    /**
-     * Constructor.
-     *
-     * The 'add', 'id', 'label', and 'mboxes' parameters are ignored.
-     *
-     * @see parent::__construct()
-     */
-    public function __construct(array $opts = array())
-    {
-        $this->enabled = empty($opts['disable']);
-
-        $this->add(new IMP_Search_Element_Bulk());
-
-        $this->_init();
-    }
-
-    /**
      * Initialization tasks.
      */
     protected function _init()
     {
         $this->_id = 'filter_bulk';
         $this->_label = _("Bulk Messages");
-    }
 
-    /**
-     * Unserialization.
-     *
-     * @param string $data  Serialized data.
-     *
-     * @throws Exception
-     */
-    public function unserialize($data)
-    {
-        parent::unserialize($data);
-        $this->_init();
+        $this->add(new IMP_Search_Element_Bulk());
     }
 
 }
index 9ebde46..3fc936a 100644 (file)
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Search_Filter_Mailinglist extends IMP_Search_Filter
+class IMP_Search_Filter_Mailinglist extends IMP_Search_Filter_Builtin
 {
     /**
-     * Can this query be edited?
-     *
-     * @var boolean
-     */
-    protected $_canEdit = false;
-
-    /**
-     * List of serialize entries not to save.
-     *
-     * @var array
-     */
-    protected $_nosave = array('i', 'l');
-
-    /**
-     * Constructor.
-     *
-     * The 'add', 'id', 'label', and 'mboxes' parameters are ignored.
-     *
-     * @see parent::__construct()
-     */
-    public function __construct(array $opts = array())
-    {
-        $this->enabled = empty($opts['disable']);
-
-        $this->add(new IMP_Search_Element_Mailinglist());
-
-        $this->_init();
-    }
-
-    /**
      * Initialization tasks.
      */
     protected function _init()
     {
         $this->_id = 'filter_mlist';
         $this->_label = _("Mailing List Messages");
-    }
 
-    /**
-     * Unserialization.
-     *
-     * @param string $data  Serialized data.
-     *
-     * @throws Exception
-     */
-    public function unserialize($data)
-    {
-        parent::unserialize($data);
-        $this->_init();
+        $this->add(new IMP_Search_Element_Mailinglist());
     }
 
 }
diff --git a/imp/lib/Search/Vfolder/Builtin.php b/imp/lib/Search/Vfolder/Builtin.php
new file mode 100644 (file)
index 0000000..a9b88ad
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+/**
+ * This class provides the base definition for built-in Virtual Folders.
+ *
+ * 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_Search_Vfolder_Builtin extends IMP_Search_Vfolder
+{
+    /**
+     * Can this query be edited?
+     *
+     * @var boolean
+     */
+    protected $_canEdit = false;
+
+    /**
+     * List of serialize entries not to save.
+     *
+     * @var array
+     */
+    protected $_nosave = array('c', 'i', 'l', 'm');
+
+    /**
+     * Constructor.
+     *
+     * The 'add', 'id', 'label', and 'mboxes' parameters are not honored.
+     *
+     * @see parent::__construct()
+     */
+    public function __construct(array $opts = array())
+    {
+        $this->enabled = empty($opts['disable']);
+
+        $this->_init();
+    }
+
+    /**
+     * Initialization tasks.
+     */
+    abstract protected function _init();
+
+    /**
+     * Unserialization.
+     *
+     * @param string $data  Serialized data.
+     *
+     * @throws Exception
+     */
+    public function unserialize($data)
+    {
+        parent::unserialize($data);
+        $this->_init();
+    }
+
+}
index c42c6f0..31e73ab 100644 (file)
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Search_Vfolder_Vinbox extends IMP_Search_Vfolder
+class IMP_Search_Vfolder_Vinbox extends IMP_Search_Vfolder_Builtin
 {
     /**
-     * Can this query be edited?
-     *
-     * @var boolean
-     */
-    protected $_canEdit = false;
-
-    /**
-     * List of serialize entries not to save.
-     *
-     * @var array
-     */
-    protected $_nosave = array('i', 'l', 'm');
-
-    /**
-     * Constructor.
-     *
-     * The 'add', 'id', 'label', and 'mboxes' parameters are not honored.
-     *
-     * @see parent::__construct()
+     * Initialization tasks.
      */
-    public function __construct(array $opts = array())
+    protected function _init()
     {
-        $this->enabled = empty($opts['disable']);
+        $this->_id = 'vinbox';
+        $this->_label = _("Virtual Inbox");
 
         $this->add(new IMP_Search_Element_Flag(
             '\\seen',
@@ -47,17 +30,6 @@ class IMP_Search_Vfolder_Vinbox extends IMP_Search_Vfolder
             '\\deleted',
             false
         ));
-
-        $this->_init();
-    }
-
-    /**
-     * Initialization tasks.
-     */
-    protected function _init()
-    {
-        $this->_id = 'vinbox';
-        $this->_label = _("Virtual Inbox");
     }
 
     /**
@@ -76,17 +48,4 @@ class IMP_Search_Vfolder_Vinbox extends IMP_Search_Vfolder
         return parent::__get($name);
     }
 
-    /**
-     * Unserialization.
-     *
-     * @param string $data  Serialized data.
-     *
-     * @throws Exception
-     */
-    public function unserialize($data)
-    {
-        parent::unserialize($data);
-        $this->_init();
-    }
-
 }
index e9a343b..1f4cca9 100644 (file)
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Search_Vfolder_Vtrash extends IMP_Search_Vfolder
+class IMP_Search_Vfolder_Vtrash extends IMP_Search_Vfolder_Builtin
 {
     /**
-     * Can this query be edited?
-     *
-     * @var boolean
-     */
-    public $canEdit = false;
-
-    /**
      * Display this virtual folder in the preferences screen?
      *
      * @var boolean
@@ -29,38 +22,17 @@ class IMP_Search_Vfolder_Vtrash extends IMP_Search_Vfolder
     public $prefDisplay = false;
 
     /**
-     * List of serialize entries not to save.
-     *
-     * @var array
-     */
-    protected $_nosave = array('i', 'l', 'm');
-
-    /**
-     * Constructor.
-     *
-     * The 'add', 'id', 'label', and 'mboxes' parameters are not honored.
-     *
-     * @see parent::__construct()
+     * Initialization tasks.
      */
-    public function __construct(array $opts = array())
+    protected function _init()
     {
-        $this->enabled = empty($opts['disable']);
+        $this->_id = 'vtrash';
+        $this->_label = _("Virtual Trash");
 
         $this->add(new IMP_Search_Element_Flag(
             '\\deleted',
             true
         ));
-
-        $this->_init();
-    }
-
-    /**
-     * Initialization tasks.
-     */
-    protected function _init()
-    {
-        $this->_id = 'vtrash';
-        $this->_label = _("Virtual Trash");
     }
 
     /**
@@ -79,17 +51,4 @@ class IMP_Search_Vfolder_Vtrash extends IMP_Search_Vfolder
         return parent::__get($name);
     }
 
-    /**
-     * Unserialization.
-     *
-     * @param string $data  Serialized data.
-     *
-     * @throws Exception
-     */
-    public function unserialize($data)
-    {
-        parent::unserialize($data);
-        $this->_init();
-    }
-
 }