ImapPlugin.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. if (!defined('STATUSNET')) {
  31. exit(1);
  32. }
  33. /**
  34. * IMAP plugin to allow StatusNet to grab incoming emails and handle them as new user posts
  35. *
  36. * @category Plugin
  37. * @package StatusNet
  38. * @author Craig Andrews <candrews@integralblue.com
  39. * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
  40. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  41. * @link http://status.net/
  42. */
  43. class ImapPlugin extends Plugin
  44. {
  45. const PLUGIN_VERSION = '2.0.0';
  46. public $mailbox;
  47. public $user;
  48. public $password;
  49. public $poll_frequency = 60;
  50. function initialize(){
  51. if(!isset($this->mailbox)){
  52. // TRANS: Exception thrown when configuration of the IMAP plugin is incorrect.
  53. throw new Exception(_m('A mailbox must be specified.'));
  54. }
  55. if(!isset($this->user)){
  56. // TRANS: Exception thrown when configuration of the IMAP plugin is incorrect.
  57. throw new Exception(_m('A user must be specified.'));
  58. }
  59. if(!isset($this->password)){
  60. // TRANS: Exception thrown when configuration of the IMAP plugin is incorrect.
  61. throw new Exception(_m('A password must be specified.'));
  62. }
  63. if(!isset($this->poll_frequency)){
  64. // TRANS: Exception thrown when configuration of the IMAP plugin is incorrect.
  65. // TRANS: poll_frequency is a setting that should not be translated.
  66. throw new Exception(_m('A poll_frequency must be specified.'));
  67. }
  68. return true;
  69. }
  70. function onStartQueueDaemonIoManagers(&$classes)
  71. {
  72. $classes[] = new ImapManager($this);
  73. }
  74. function onPluginVersion(array &$versions)
  75. {
  76. $versions[] = array('name' => 'IMAP',
  77. 'version' => self::PLUGIN_VERSION,
  78. 'author' => 'Craig Andrews',
  79. 'homepage' => 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/IMAP',
  80. 'rawdescription' =>
  81. // TRANS: Plugin description.
  82. _m('The IMAP plugin allows for StatusNet to check a POP or IMAP mailbox for incoming mail containing user posts.'));
  83. return true;
  84. }
  85. }