summaryrefslogtreecommitdiff
path: root/plugins/UserLimit
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-09-23 09:50:46 -0400
committerEvan Prodromou <evan@status.net>2010-09-23 09:50:46 -0400
commit0f1fc36a05c8d858827718255bef20e8d0c0d3f6 (patch)
tree7be7f3fabe27e9780c37de7483807d28ef3dfcf4 /plugins/UserLimit
parent77609e0c4a1b76748ab320027b0696aced92b52c (diff)
parent5f409a0d7caa3b075657eef947deb7b62452b82d (diff)
Merge branch '0.9.x'
Diffstat (limited to 'plugins/UserLimit')
-rw-r--r--plugins/UserLimit/UserLimitPlugin.php92
-rw-r--r--plugins/UserLimit/locale/UserLimit.pot21
2 files changed, 113 insertions, 0 deletions
diff --git a/plugins/UserLimit/UserLimitPlugin.php b/plugins/UserLimit/UserLimitPlugin.php
new file mode 100644
index 000000000..ab3187299
--- /dev/null
+++ b/plugins/UserLimit/UserLimitPlugin.php
@@ -0,0 +1,92 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Plugin to limit number of users that can register (best for cloud providers)
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Action
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @copyright 2009 StatusNet Inc.
+ * @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')) {
+ exit(1);
+}
+
+/**
+ * Plugin to limit number of users that can register (best for cloud providers)
+ *
+ * For cloud providers whose freemium model is based on how many
+ * users can register. We use it on the StatusNet Cloud.
+ *
+ * @category Plugin
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ *
+ * @seeAlso Location
+ */
+
+class UserLimitPlugin extends Plugin
+{
+ public $maxUsers = null;
+
+ function onStartUserRegister(&$user, &$profile)
+ {
+ $this->_checkMaxUsers();
+ return true;
+ }
+
+ function onStartRegistrationTry($action)
+ {
+ $this->_checkMaxUsers();
+ return true;
+ }
+
+ function _checkMaxUsers()
+ {
+ if (!is_null($this->maxUsers)) {
+
+ $cls = new User();
+
+ $cnt = $cls->count();
+
+ if ($cnt >= $this->maxUsers) {
+ $msg = sprintf(_('Cannot register; maximum number of users (%d) reached.'),
+ $this->maxUsers);
+
+ throw new ClientException($msg);
+ }
+ }
+ }
+
+ function onPluginVersion(&$versions)
+ {
+ $versions[] = array('name' => 'UserLimit',
+ 'version' => STATUSNET_VERSION,
+ 'author' => 'Evan Prodromou',
+ 'homepage' => 'http://status.net/wiki/Plugin:UserLimit',
+ 'description' =>
+ _m('Limit the number of users who can register.'));
+ return true;
+ }
+}
diff --git a/plugins/UserLimit/locale/UserLimit.pot b/plugins/UserLimit/locale/UserLimit.pot
new file mode 100644
index 000000000..54952712e
--- /dev/null
+++ b/plugins/UserLimit/locale/UserLimit.pot
@@ -0,0 +1,21 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-09-22 22:34+0000\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: UserLimitPlugin.php:89
+msgid "Limit the number of users who can register."
+msgstr ""