AutoSandboxPlugin.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. /**
  3. * StatusNet, the distributed open-source microblogging tool
  4. *
  5. * Plugin to automatically sandbox newly registered users in an effort to beat
  6. * spammers. If the user proves to be legitimate, moderators can un-sandbox them.
  7. *
  8. * PHP version 5
  9. *
  10. * LICENCE: This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as published by
  12. * the Free Software Foundation, either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. * @category Plugin
  24. * @package StatusNet
  25. * @author Sean Carmody<seancarmody@gmail.com>
  26. * @copyright 2010
  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') && !defined('LACONICA')) {
  31. exit(1);
  32. }
  33. define('AUTOSANDBOX', '0.1');
  34. //require_once(INSTALLDIR.'/plugins/AutoSandbox/autosandbox.php');
  35. class AutoSandboxPlugin extends Plugin
  36. {
  37. var $contact;
  38. var $debug;
  39. function onInitializePlugin()
  40. {
  41. if(!isset($this->debug))
  42. {
  43. $this->debug = 0;
  44. }
  45. if(!isset($this->contact)) {
  46. $default = common_config('newuser', 'default');
  47. if (!empty($default)) {
  48. $this->contact = $default;
  49. }
  50. }
  51. }
  52. function onPluginVersion(array &$versions)
  53. {
  54. $versions[] = array('name' => 'AutoSandbox',
  55. 'version' => GNUSOCIAL_VERSION,
  56. 'author' => 'Sean Carmody',
  57. 'homepage' => 'http://status.net/wiki/Plugin:AutoSandbox',
  58. 'rawdescription' =>
  59. // TRANS: Plugin description.
  60. _m('Automatically sandboxes newly registered members.'));
  61. return true;
  62. }
  63. function onStartRegistrationFormData($action)
  64. {
  65. // TRANS: User instructions after registration.
  66. $instr = _m('Note you will initially be "sandboxed" so your posts will not appear in the public timeline.');
  67. if (isset($this->contact)) {
  68. $contactuser = User::getKV('nickname', $this->contact);
  69. if ($contactuser instanceof User) {
  70. $contactlink = sprintf('@<a href="%s">%s</a>',
  71. htmlspecialchars($contactuser->getProfile()->getUrl()),
  72. htmlspecialchars($contactuser->getProfile()->getNickname()));
  73. // TRANS: User instructions after registration.
  74. // TRANS: %s is a clickable OStatus profile URL.
  75. $instr = sprintf(_m('Note you will initially be "sandboxed" so your posts will not appear in the public timeline. '.
  76. 'Send a message to %s to speed up the unsandboxing process.'),$contactlink);
  77. }
  78. }
  79. $output = common_markup_to_html($instr);
  80. $action->elementStart('div', 'instructions');
  81. $action->raw($output);
  82. $action->elementEnd('div');
  83. }
  84. public function onEndUserRegister(Profile $profile)
  85. {
  86. $profile->sandbox();
  87. if ($this->debug) {
  88. common_log(LOG_WARNING, "AutoSandbox: sandboxed of $profile->nickname");
  89. }
  90. }
  91. }