]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/AutoSandbox/AutoSandboxPlugin.php
[TRANSLATION] Update license and copyright notice in translation files
[quix0rs-gnu-social.git] / plugins / AutoSandbox / AutoSandboxPlugin.php
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
31 if (!defined('STATUSNET') && !defined('LACONICA')) {
32     exit(1);
33 }
34
35 define('AUTOSANDBOX', '0.1');
36
37 //require_once(INSTALLDIR.'/plugins/AutoSandbox/autosandbox.php');
38
39 class AutoSandboxPlugin extends Plugin
40 {
41     const PLUGIN_VERSION = '2.0.0';
42     var $contact;
43     var $debug;
44
45     function onInitializePlugin()
46     {
47         if(!isset($this->debug))
48         {
49             $this->debug = 0;
50         }
51
52         if(!isset($this->contact)) {
53            $default = common_config('newuser', 'default');
54            if (!empty($default)) {
55                $this->contact = $default;
56            }
57         }
58     }
59
60     function onPluginVersion(array &$versions)
61     {
62         $versions[] = array('name' => 'AutoSandbox',
63                             'version' => self::PLUGIN_VERSION,
64                             'author' => 'Sean Carmody',
65                             'homepage' => 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/AutoSandbox',
66                             'rawdescription' =>
67                             // TRANS: Plugin description.
68                             _m('Automatically sandboxes newly registered members.'));
69         return true;
70     }
71
72     function onStartRegistrationFormData($action)
73     {
74          // TRANS: User instructions after registration.
75          $instr = _m('Note you will initially be "sandboxed" so your posts will not appear in the public timeline.');
76
77          if (isset($this->contact)) {
78              $contactuser = User::getKV('nickname', $this->contact);
79              if ($contactuser instanceof User) {
80                  $contactlink = sprintf('@<a href="%s">%s</a>',
81                                         htmlspecialchars($contactuser->getProfile()->getUrl()),
82                                         htmlspecialchars($contactuser->getProfile()->getNickname()));
83                  // TRANS: User instructions after registration.
84                  // TRANS: %s is a clickable OStatus profile URL.
85                  $instr = sprintf(_m('Note you will initially be "sandboxed" so your posts will not appear in the public timeline. '.
86                    'Send a message to %s to speed up the unsandboxing process.'),$contactlink);
87              }
88          }
89
90          $output = common_markup_to_html($instr);
91          $action->elementStart('div', 'instructions');
92          $action->raw($output);
93          $action->elementEnd('div');
94     }
95
96     public function onEndUserRegister(Profile $profile)
97     {
98         $profile->sandbox();
99         if ($this->debug) {
100             common_log(LOG_WARNING, "AutoSandbox: sandboxed of $profile->nickname");
101         }
102     }
103 }