Browse Source

- Merge with etenil : limit on nomber of accounts

pull/5/head
Jaussoin Timothée 14 years ago
parent
commit
62873073f4
  1. 1
      install/index.php
  2. 4
      install/part1.php
  3. 12
      system/Widget/widgets/Account/Account.php
  4. 11
      system/Widget/widgets/AccountAdd/AccountAdd.php
  5. 6
      system/Widget/widgets/Login/Login.php

1
install/index.php

@ -260,6 +260,7 @@ function perform_install()
'proxyEnabled' => get_checkbox('proxyEnabled'),
'proxyURL' => $_POST['proxyURL'],
'proxyPort' => $_POST['proxyPort'],
'maxUsers' => $_POST['maxUsers'],
),
);
if(!@file_put_contents('../config/conf.xml', make_xml($conf))) {

4
install/part1.php

@ -80,6 +80,10 @@
</select>
</p>
<p>
<label for="maxUsers">Maximum number of users (-1 is infinite)</label>
<input type="text" name="maxUsers" id="maxUsers" value="-1" />
</p>
<p>
<label for="boshCookieTTL">Bosh cookie's expiration (s)</label>
<input type="text" id="boshCookieTTL" name="boshCookieTTL" value="<?php echo (isset($_POST['boshCookieTTL'])? $_POST['boshCookieTTL'] : 3600);?>"/>

12
system/Widget/widgets/Account/Account.php

@ -163,6 +163,17 @@ class Account extends WidgetBase {
function build()
{
// Do we still allow user registration?
$conf = Conf::getServerConf();
$users = count(ConfVar::select(array()));
if($conf['maxUsers'] > -1 && $users > $conf['maxUsers']) {
echo '<br /><br /><br />';
echo '<div class="error">'.t('User registration is disabled.').'</div>';
return;
}
switch ($_GET['err']) {
case 'datamissing':
$warning = '
@ -214,7 +225,6 @@ class Account extends WidgetBase {
break;
}
$conf = Conf::getServerConf();
$submit = $this->genCallAjax('ajaxSubmit', "movim_parse_form('account')");
?>
<div id="content" style="width: 900px">

11
system/Widget/widgets/AccountAdd/AccountAdd.php

@ -93,6 +93,17 @@ class AccountAdd extends WidgetBase {
function build()
{
// Do we still allow user registration?
$conf = Conf::getServerConf();
$users = count(ConfVar::select(array()));
if($conf['maxUsers'] > -1 && $users > $conf['maxUsers']) {
echo '<br /><br /><br />';
echo '<div class="error">'.t('Account linkage disabled.').'</div>';
return;
}
switch ($_GET['err']) {
case 'datamissing':
$warning = '

6
system/Widget/widgets/Login/Login.php

@ -114,9 +114,13 @@ class Login extends WidgetBase {
<?php
$query = ConfVar::query();
$contacts = ConfVar::run_query($query);
$conf = Conf::getServerConf();
echo t('This server hosts %s accounts', count($contacts));
if(Conf::getServerConfElement("accountCreation") == 1) {
if($conf["accountCreation"] == 1
&& ($conf['maxUsers'] == -1
|| count($contacts) < $conf['maxUsers'])) {
?> -
<a href="?q=accountCreate"><?php echo t('Create a new account'); ?></a> -
<a href="?q=accountAdd"><?php echo t('Link my current account'); ?></a>

Loading…
Cancel
Save