From c810f2485132fe124e671dee4f86eb721eee15e4 Mon Sep 17 00:00:00 2001 From: Sean Carmody Date: Thu, 18 Mar 2010 00:06:42 +1100 Subject: [PATCH] Added plugin AutoSandbox for spam-management: new users sandboxed by default --- plugins/AutoSandbox/AutoSandboxPlugin.php | 96 +++++++++++++++++++++++ plugins/AutoSandbox/LICENSE | 21 +++++ plugins/AutoSandbox/README | 39 +++++++++ 3 files changed, 156 insertions(+) create mode 100644 plugins/AutoSandbox/AutoSandboxPlugin.php create mode 100644 plugins/AutoSandbox/LICENSE create mode 100644 plugins/AutoSandbox/README diff --git a/plugins/AutoSandbox/AutoSandboxPlugin.php b/plugins/AutoSandbox/AutoSandboxPlugin.php new file mode 100644 index 0000000000..ffd8bf455e --- /dev/null +++ b/plugins/AutoSandbox/AutoSandboxPlugin.php @@ -0,0 +1,96 @@ +. + * + * @category Plugin + * @package StatusNet + * @author Sean Carmody + * @copyright 2010 + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +define('AUTOSANDBOX', '0.1'); + +//require_once(INSTALLDIR.'/plugins/AutoSandbox/autosandbox.php'); + +class AutoSandboxPlugin extends Plugin +{ + var $contact; + var $debug; + + function onInitializePlugin() + { + if(!isset($this->debug)) + { + $this->debug = 0; + } + + if(!isset($this->contact)) { + $default = common_config('newuser', 'default'); + if (!empty($default)) { + $this->contact = $default; + } + } + } + + function onPluginVersion(&$versions) + { + $versions[] = array('name' => 'AutoSandbox', + 'version' => STATUSNET_VERSION, + 'author' => 'Sean Carmody', + 'homepage' => 'http://status.net/wiki/Plugin:AutoSandbox', + 'rawdescription' => + _m('Automatically sandboxes newly registered members.')); + return true; + } + + function onStartRegistrationFormData($action) + { + + $instr = 'Note you will initially be "sandboxed" so your posts will not appear in the public timeline.'; + + if (isset($this->contact)) { + $contactuser = User::staticGet('nickname', $this->contact); + if (!empty($contactuser)) { + $contactlink = "@uri\">$contactuser->nickname"; + $instr = $instr . " Send a message to $contactlink to speed up the unsandboxing process."; + } + } + + $output = common_markup_to_html($instr); + $action->elementStart('div', 'instructions'); + $action->raw($output); + $action->elementEnd('div'); + } + + function onEndUserRegister(&$profile,&$user) + { + $profile->sandbox(); + if ($this->debug) { + common_log(LOG_WARNING, "AutoSandbox: sandboxed of $user->nickname"); + } + } +} diff --git a/plugins/AutoSandbox/LICENSE b/plugins/AutoSandbox/LICENSE new file mode 100644 index 0000000000..011faa4e78 --- /dev/null +++ b/plugins/AutoSandbox/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) 2010 Stubborn Mule - http://www.stubbornmule.net +AUTHORS: + Sean Carmody + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/plugins/AutoSandbox/README b/plugins/AutoSandbox/README new file mode 100644 index 0000000000..2f5d625f79 --- /dev/null +++ b/plugins/AutoSandbox/README @@ -0,0 +1,39 @@ +StatusNet AutoSandbox plugin 0.1 03/16/10 +========================================= +Automatically sandboxes newly registered users as a spam-management technique. +Only really suits small sites where all users can be hand-moderated. A moderator +will then have to unbox legimate users, using the following built-in script: + +./scripts/userrole.php -n username -r moderator + +(replace 'username' with the nickname of the user you wish to make a moderator). + +The following note will be added to the top of the Registration form: + +"Note you will initially be "sandboxed" so your posts will not appear in the +public timeline." + +This can be followed by the following extra information if a contact user (denoted +here by XXX) is specified: + +"Send a message to @XXX to speed up the unsandboxing process." + +If no contact user is specified, it will default to the "Default subscription" user +who automatically subscribes to new users (set in Admin -> User). + +Use: +1. Add plugin: + +Default usage: +addPlugin('AutoSandbox'); + +Specify a contact user (replace 'someuser' with appropriate username): +addPlugin('AutoSandbox', array('contact' => 'someuser')); + +Stop contact user from defaulting to the Defaul subscription: +addPlugin('AutoSandbox', array('contact' => '')); + +Changelog +========= +0.1 initial release + -- 2.39.5