]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/Imap/ImapPlugin.php
Localisation updates from http://translatewiki.net.
[quix0rs-gnu-social.git] / plugins / Imap / ImapPlugin.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * Plugin to add a StatusNet Facebook application
6  *
7  * PHP version 5
8  *
9  * LICENCE: This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU Affero General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU Affero General Public License for more details.
18  *
19  * You should have received a copy of the GNU Affero General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  * @category  Plugin
23  * @package   StatusNet
24  * @author   Craig Andrews <candrews@integralblue.com
25  * @copyright 2009 StatusNet, Inc.
26  * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
27  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
28  * @link      http://status.net/
29  */
30
31 if (!defined('STATUSNET')) {
32     exit(1);
33 }
34
35 /**
36  * IMAP plugin to allow StatusNet to grab incoming emails and handle them as new user posts
37  *
38  * @category Plugin
39  * @package  StatusNet
40  * @author   Craig Andrews <candrews@integralblue.com
41  * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
42  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
43  * @link     http://status.net/
44  */
45 class ImapPlugin extends Plugin
46 {
47     public $mailbox;
48     public $user;
49     public $password;
50     public $poll_frequency = 60;
51
52     function initialize(){
53         if(!isset($this->mailbox)){
54             throw new Exception(_m("A mailbox must be specified."));
55         }
56         if(!isset($this->user)){
57             throw new Exception(_m("A user must be specified."));
58         }
59         if(!isset($this->password)){
60             throw new Exception(_m("A password must be specified."));
61         }
62         if(!isset($this->poll_frequency)){
63             throw new Exception(_m("A poll_frequency must be specified."));
64         }
65
66         return true;
67     }
68
69     /**
70      * Load related modules when needed
71      *
72      * @param string $cls Name of the class to be loaded
73      *
74      * @return boolean hook value; true means continue processing, false means stop.
75      */
76     function onAutoload($cls)
77     {
78         $dir = dirname(__FILE__);
79
80         switch ($cls)
81         {
82         case 'ImapManager':
83         case 'IMAPMailHandler':
84             include_once $dir . '/'.strtolower($cls).'.php';
85             return false;
86         default:
87             return true;
88         }
89     }
90
91     function onStartQueueDaemonIoManagers(&$classes)
92     {
93         $classes[] = new ImapManager($this);
94     }
95
96     function onPluginVersion(&$versions)
97     {
98         $versions[] = array('name' => 'IMAP',
99                             'version' => STATUSNET_VERSION,
100                             'author' => 'Craig Andrews',
101                             'homepage' => 'http://status.net/wiki/Plugin:IMAP',
102                             'rawdescription' =>
103                             _m('The IMAP plugin allows for StatusNet to check a POP or IMAP mailbox for incoming mail containing user posts.'));
104         return true;
105     }
106 }