]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/Imap/ImapPlugin.php
Merge remote-tracking branch 'upstream/master' into social-master
[quix0rs-gnu-social.git] / plugins / Imap / ImapPlugin.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * IMAP plugin to allow StatusNet to grab incoming emails and handle them as new user posts
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             // TRANS: Exception thrown when configuration of the IMAP plugin is incorrect.
55             throw new Exception(_m('A mailbox must be specified.'));
56         }
57         if(!isset($this->user)){
58             // TRANS: Exception thrown when configuration of the IMAP plugin is incorrect.
59             throw new Exception(_m('A user must be specified.'));
60         }
61         if(!isset($this->password)){
62             // TRANS: Exception thrown when configuration of the IMAP plugin is incorrect.
63             throw new Exception(_m('A password must be specified.'));
64         }
65         if(!isset($this->poll_frequency)){
66             // TRANS: Exception thrown when configuration of the IMAP plugin is incorrect.
67             // TRANS: poll_frequency is a setting that should not be translated.
68             throw new Exception(_m('A poll_frequency must be specified.'));
69         }
70
71         return true;
72     }
73
74     function onStartQueueDaemonIoManagers(&$classes)
75     {
76         $classes[] = new ImapManager($this);
77     }
78
79     function onPluginVersion(array &$versions)
80     {
81         $versions[] = array('name' => 'IMAP',
82                             'version' => GNUSOCIAL_VERSION,
83                             'author' => 'Craig Andrews',
84                             'homepage' => 'http://status.net/wiki/Plugin:IMAP',
85                             'rawdescription' =>
86                             // TRANS: Plugin description.
87                             _m('The IMAP plugin allows for StatusNet to check a POP or IMAP mailbox for incoming mail containing user posts.'));
88         return true;
89     }
90 }