]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Imap/ImapPlugin.php
Merge remote branch 'gitorious/0.9.x' into 0.9.x
[quix0rs-gnu-social.git] / plugins / Imap / ImapPlugin.php
index 034444222210819e5cbab3f1fae1bd8d7c0d2172..8d8dbf223f1a80f57822a1995c574acdce8f1d95 100644 (file)
@@ -21,8 +21,9 @@
  *
  * @category  Plugin
  * @package   StatusNet
- * @author    Zach Copley <zach@status.net>
+ * @author   Craig Andrews <candrews@integralblue.com
  * @copyright 2009 StatusNet, Inc.
+ * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link      http://status.net/
  */
@@ -37,6 +38,7 @@ if (!defined('STATUSNET')) {
  * @category Plugin
  * @package  StatusNet
  * @author   Craig Andrews <candrews@integralblue.com
+ * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link     http://status.net/
  */
@@ -46,40 +48,59 @@ class ImapPlugin extends Plugin
     public $user;
     public $password;
     public $poll_frequency = 60;
-    public static $instances = array();
-    public static $daemon_added = array();
 
     function initialize(){
         if(!isset($this->mailbox)){
-            throw new Exception("must specify a mailbox");
+            throw new Exception(_m("A mailbox must be specified."));
         }
         if(!isset($this->user)){
-            throw new Exception("must specify a user");
+            throw new Exception(_m("A user must be specified."));
         }
         if(!isset($this->password)){
-            throw new Exception("must specify a password");
+            throw new Exception(_m("A password must be specified."));
         }
         if(!isset($this->poll_frequency)){
-            throw new Exception("must specify a poll_frequency");
+            throw new Exception(_m("A poll_frequency must be specified."));
         }
 
-        self::$instances[] = $this;
         return true;
     }
 
-    function cleanup(){
-        $index = array_search($this, self::$instances);
-        unset(self::$instances[$index]);
-        return true;
+    /**
+     * Load related modules when needed
+     *
+     * @param string $cls Name of the class to be loaded
+     *
+     * @return boolean hook value; true means continue processing, false means stop.
+     */
+    function onAutoload($cls)
+    {
+        $dir = dirname(__FILE__);
+
+        switch ($cls)
+        {
+        case 'ImapManager':
+        case 'IMAPMailHandler':
+            include_once $dir . '/'.strtolower($cls).'.php';
+            return false;
+        default:
+            return true;
+        }
     }
 
-    function onGetValidDaemons($daemons)
+    function onStartQueueDaemonIoManagers(&$classes)
     {
-        if(! self::$daemon_added){
-            array_push($daemons, INSTALLDIR .
-                       '/plugins/Imap/imapdaemon.php');
-            self::$daemon_added = true;
-        }
+        $classes[] = new ImapManager($this);
+    }
+
+    function onPluginVersion(&$versions)
+    {
+        $versions[] = array('name' => 'IMAP',
+                            'version' => STATUSNET_VERSION,
+                            'author' => 'Craig Andrews',
+                            'homepage' => 'http://status.net/wiki/Plugin:IMAP',
+                            'rawdescription' =>
+                            _m('The IMAP plugin allows for StatusNet to check a POP or IMAP mailbox for incoming mail containing user posts.'));
         return true;
     }
 }