ImapPlugin.php 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. public $mailbox;
  46. public $user;
  47. public $password;
  48. public $poll_frequency = 60;
  49. function initialize(){
  50. if(!isset($this->mailbox)){
  51. // TRANS: Exception thrown when configuration of the IMAP plugin is incorrect.
  52. throw new Exception(_m('A mailbox must be specified.'));
  53. }
  54. if(!isset($this->user)){
  55. // TRANS: Exception thrown when configuration of the IMAP plugin is incorrect.
  56. throw new Exception(_m('A user must be specified.'));
  57. }
  58. if(!isset($this->password)){
  59. // TRANS: Exception thrown when configuration of the IMAP plugin is incorrect.
  60. throw new Exception(_m('A password must be specified.'));
  61. }
  62. if(!isset($this->poll_frequency)){
  63. // TRANS: Exception thrown when configuration of the IMAP plugin is incorrect.
  64. // TRANS: poll_frequency is a setting that should not be translated.
  65. throw new Exception(_m('A poll_frequency must be specified.'));
  66. }
  67. return true;
  68. }
  69. function onStartQueueDaemonIoManagers(&$classes)
  70. {
  71. $classes[] = new ImapManager($this);
  72. }
  73. function onPluginVersion(array &$versions)
  74. {
  75. $versions[] = array('name' => 'IMAP',
  76. 'version' => GNUSOCIAL_VERSION,
  77. 'author' => 'Craig Andrews',
  78. 'homepage' => 'http://status.net/wiki/Plugin:IMAP',
  79. 'rawdescription' =>
  80. // TRANS: Plugin description.
  81. _m('The IMAP plugin allows for StatusNet to check a POP or IMAP mailbox for incoming mail containing user posts.'));
  82. return true;
  83. }
  84. }