123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- class UserLimitPlugin extends Plugin
- {
- public $maxUsers = null;
- public function onStartUserRegister(Profile $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(_m('Cannot register because the maximum number of users (%d) for this site was reached.',
- 'Cannot register because the maximum number of users (%d) for this site was reached.',
- $this->maxUsers),
- $this->maxUsers);
- throw new ClientException($msg);
- }
- }
- }
- function onPluginVersion(array &$versions)
- {
- $versions[] = array('name' => 'UserLimit',
- 'version' => GNUSOCIAL_VERSION,
- 'author' => 'Evan Prodromou',
- 'homepage' => 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/UserLimit',
- 'description' =>
-
- _m('Limit the number of users who can register.'));
- return true;
- }
- }
|