Add possibility to limit users
This commit is contained in:
parent
4bf8c98fcc
commit
b2bd7e0d25
@ -196,6 +196,14 @@ $dolibarr_main_force_https='0';
|
|||||||
# $dolibarr_main_prod='1';
|
# $dolibarr_main_prod='1';
|
||||||
|
|
||||||
|
|
||||||
|
# dolibarr_main_limit_users
|
||||||
|
# Can set a limit on the number of users it will be possible to create
|
||||||
|
# (the superadmin not included), can be used for a restricted mode.
|
||||||
|
# Default value: 0 (unlimited)
|
||||||
|
# Examples:
|
||||||
|
# $dolibarr_main_limit_users='0';
|
||||||
|
|
||||||
|
|
||||||
# This is an development feature to allow external components to overwrite
|
# This is an development feature to allow external components to overwrite
|
||||||
# some Dolibarr kernel files to be overwritten by versions provided by
|
# some Dolibarr kernel files to be overwritten by versions provided by
|
||||||
# third parties modules.
|
# third parties modules.
|
||||||
|
|||||||
@ -108,3 +108,4 @@ ConfirmCreateThirdParty=Are you sure you want to create a third party for this m
|
|||||||
LoginToCreate=Login to create
|
LoginToCreate=Login to create
|
||||||
NameToCreate=Name of third party to create
|
NameToCreate=Name of third party to create
|
||||||
YourRole=Your roles
|
YourRole=Your roles
|
||||||
|
YourQuotaOfUsersIsReached=Your quota of users is reached !
|
||||||
@ -108,3 +108,4 @@ ConfirmCreateThirdParty=Êtes-vous sûr de vouloir créer un tiers pour cet adh
|
|||||||
LoginToCreate=Login à créer
|
LoginToCreate=Login à créer
|
||||||
NameToCreate=Nom du tiers à créer
|
NameToCreate=Nom du tiers à créer
|
||||||
YourRole=Vos rôles
|
YourRole=Vos rôles
|
||||||
|
YourQuotaOfUsersIsReached=Votre quota d'utilisateurs est atteint !
|
||||||
@ -162,6 +162,8 @@ if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption=0;
|
|||||||
$conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
|
$conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
|
||||||
if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey='';
|
if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey='';
|
||||||
$conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
|
$conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
|
||||||
|
if (empty($dolibarr_main_limit_users)) $dolibarr_main_limit_users=0;
|
||||||
|
$conf->file->main_limit_users = $dolibarr_main_limit_users;
|
||||||
if (defined('TEST_DB_FORCE_TYPE')) $conf->db->type=constant('TEST_DB_FORCE_TYPE'); // For test purpose
|
if (defined('TEST_DB_FORCE_TYPE')) $conf->db->type=constant('TEST_DB_FORCE_TYPE'); // For test purpose
|
||||||
// Identifiant autres
|
// Identifiant autres
|
||||||
$conf->file->main_authentication = empty($dolibarr_main_authentication)?'':$dolibarr_main_authentication;
|
$conf->file->main_authentication = empty($dolibarr_main_authentication)?'':$dolibarr_main_authentication;
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
* Copyright (c) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (c) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
|
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
|
||||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||||
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
|
||||||
* Copyright (C) 2005 Lionel Cousteix <etm_ltd@tiscali.co.uk>
|
* Copyright (C) 2005 Lionel Cousteix <etm_ltd@tiscali.co.uk>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -23,16 +23,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/user.class.php
|
* \file htdocs/user.class.php
|
||||||
\brief Fichier de la classe utilisateur
|
* \brief Fichier de la classe utilisateur
|
||||||
\author Rodolphe Quiedeville
|
* \version $Id$
|
||||||
\author Jean-Louis Bergamo
|
|
||||||
\author Laurent Destailleur
|
|
||||||
\author Sebastien Di Cintio
|
|
||||||
\author Benoit Mortier
|
|
||||||
\author Regis Houssin
|
|
||||||
\author Lionel Cousteix
|
|
||||||
\version $Id$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php");
|
require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php");
|
||||||
@ -1800,6 +1793,36 @@ class User extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Return number of existing users
|
||||||
|
* \param limitToActive limit to active users
|
||||||
|
* \return int Number of users
|
||||||
|
*/
|
||||||
|
function getNbOfUsers($limitToActive=0)
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
$sql = "SELECT count(rowid) as nb";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."user";
|
||||||
|
$sql.= " WHERE entity = ".$conf->entity;
|
||||||
|
if ($limitToActive) $sql.= " AND statut = 1";
|
||||||
|
|
||||||
|
$resql=$this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
$nb=$obj->nb;
|
||||||
|
|
||||||
|
$this->db->free($resql);
|
||||||
|
return $nb;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$this->db->error();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
|
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
|
||||||
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||||
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
|
||||||
* Copyright (C) 2005 Lionel Cousteix <etm_ltd@tiscali.co.uk>
|
* Copyright (C) 2005 Lionel Cousteix <etm_ltd@tiscali.co.uk>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -151,10 +151,20 @@ if ($_POST["action"] == 'add' && $canadduser)
|
|||||||
$action="create"; // Go back to create page
|
$action="create"; // Go back to create page
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$edituser = new User($db);
|
||||||
|
|
||||||
|
if (!empty($conf->file->main_limit_users))
|
||||||
|
{
|
||||||
|
$nb = $edituser->getNbOfUsers(1);
|
||||||
|
if ($nb >= $conf->file->main_limit_users)
|
||||||
|
{
|
||||||
|
$message='<div class="error">'.$langs->trans("YourQuotaOfUsersIsReached").'</div>';
|
||||||
|
$action="create"; // Go back to create page
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (! $message)
|
if (! $message)
|
||||||
{
|
{
|
||||||
$edituser = new User($db);
|
|
||||||
|
|
||||||
$edituser->nom = $_POST["nom"];
|
$edituser->nom = $_POST["nom"];
|
||||||
$edituser->prenom = $_POST["prenom"];
|
$edituser->prenom = $_POST["prenom"];
|
||||||
$edituser->login = $_POST["login"];
|
$edituser->login = $_POST["login"];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user