dolibarr/htdocs/core/modules/modUser.class.php

264 lines
9.3 KiB
PHP
Raw Permalink Normal View History

2005-08-23 13:13:03 +02:00
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
2012-12-30 15:13:49 +01:00
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
2005-08-23 13:13:03 +02:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
2005-08-23 13:13:03 +02:00
* (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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2011-08-01 01:24:38 +02:00
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2005-08-23 13:13:03 +02:00
*/
/**
2009-07-30 00:52:08 +02:00
* \defgroup user Module user management
2008-12-05 00:06:45 +01:00
* \brief Module pour gerer les utilisateurs
* \file htdocs/core/modules/modUser.class.php
2008-12-05 00:06:45 +01:00
* \ingroup user
* \brief Fichier de description et activation du module Utilisateur
2008-10-01 21:10:17 +02:00
*/
2005-08-23 13:13:03 +02:00
include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
2005-08-23 13:13:03 +02:00
/**
2012-10-03 00:30:50 +02:00
* Classe de description et activation du module User
2008-10-01 21:10:17 +02:00
*/
2005-08-23 13:13:03 +02:00
class modUser extends DolibarrModules
{
2008-10-01 21:10:17 +02:00
/**
2011-09-26 16:22:35 +02:00
* Constructor. Define names, constants, directories, boxes, permissions
*
2012-01-04 21:23:50 +01:00
* @param DoliDB $db Database handler
2008-10-01 21:10:17 +02:00
*/
function __construct($db)
2008-10-01 21:10:17 +02:00
{
global $conf;
2012-01-04 21:23:50 +01:00
$this->db = $db;
2008-10-01 21:10:17 +02:00
$this->numero = 0;
$this->family = "base"; // Family for module (or "base" if core module)
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i','',get_class($this));
2008-10-01 21:10:17 +02:00
$this->description = "Gestion des utilisateurs (requis)";
$this->always_enabled = 1; // Can't be disabled
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this->version = 'dolibarr';
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
2008-10-01 21:10:17 +02:00
$this->special = 0;
$this->picto='group';
// Data directories to create when module is enabled
$this->dirs = array("/users/temp");
2008-10-01 21:10:17 +02:00
// Config pages
2010-03-31 08:23:28 +02:00
$this->config_page_url = array("user.php");
2008-10-01 21:10:17 +02:00
// Dependancies
2008-10-01 21:10:17 +02:00
$this->depends = array();
$this->requiredby = array();
$this->langfiles = array("main","users","companies");
// Constants
2008-10-01 21:10:17 +02:00
$this->const = array();
// Boxes
2008-10-01 21:10:17 +02:00
$this->boxes = array();
// Permissions
$this->rights = array();
$this->rights_class = 'user';
$this->rights_admin_allowed = 1; // Admin is always granted of permission (even when module is disabled)
$r=0;
$r++;
$this->rights[$r][0] = 251;
2010-10-28 21:31:11 +02:00
$this->rights[$r][1] = 'Consulter les autres utilisateurs';
2008-10-01 21:10:17 +02:00
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
2008-10-01 21:10:17 +02:00
$this->rights[$r][4] = 'user';
$this->rights[$r][5] = 'lire';
2010-11-07 18:45:51 +01:00
2008-10-01 21:10:17 +02:00
$r++;
$this->rights[$r][0] = 252;
2010-10-28 21:31:11 +02:00
$this->rights[$r][1] = 'Consulter les permissions des autres utilisateurs';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'user_advance';
2010-10-28 21:31:11 +02:00
$this->rights[$r][5] = 'readperms';
2010-11-07 18:45:51 +01:00
2010-10-28 21:31:11 +02:00
$r++;
$this->rights[$r][0] = 253;
2010-11-08 18:21:52 +01:00
$this->rights[$r][1] = 'Creer/modifier utilisateurs internes et externes';
2008-10-01 21:10:17 +02:00
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'user';
$this->rights[$r][5] = 'creer';
2008-10-01 21:10:17 +02:00
$r++;
2010-10-28 21:31:11 +02:00
$this->rights[$r][0] = 254;
2010-11-08 18:21:52 +01:00
$this->rights[$r][1] = 'Creer/modifier utilisateurs externes seulement';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'user_advance';
$this->rights[$r][5] = 'write';
$r++;
$this->rights[$r][0] = 255;
2010-10-28 21:31:11 +02:00
$this->rights[$r][1] = 'Modifier le mot de passe des autres utilisateurs';
2008-10-01 21:10:17 +02:00
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'user';
$this->rights[$r][5] = 'password';
$r++;
2010-11-08 18:21:52 +01:00
$this->rights[$r][0] = 256;
2008-10-01 21:10:17 +02:00
$this->rights[$r][1] = 'Supprimer ou desactiver les autres utilisateurs';
$this->rights[$r][2] = 'd';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'user';
$this->rights[$r][5] = 'supprimer';
2010-11-07 18:45:51 +01:00
2008-10-01 21:10:17 +02:00
$r++;
2010-11-08 18:21:52 +01:00
$this->rights[$r][0] = 341;
2010-10-29 07:38:33 +02:00
$this->rights[$r][1] = 'Consulter ses propres permissions';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 1;
2011-09-26 16:22:35 +02:00
$this->rights[$r][4] = 'self_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
2010-10-29 07:38:33 +02:00
$this->rights[$r][5] = 'readperms';
2010-11-07 18:45:51 +01:00
2010-10-29 07:38:33 +02:00
$r++;
2010-11-08 18:21:52 +01:00
$this->rights[$r][0] = 342;
2008-10-01 21:10:17 +02:00
$this->rights[$r][1] = 'Creer/modifier ses propres infos utilisateur';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 1;
$this->rights[$r][4] = 'self';
$this->rights[$r][5] = 'creer';
$r++;
2010-11-08 18:21:52 +01:00
$this->rights[$r][0] = 343;
2008-10-01 21:10:17 +02:00
$this->rights[$r][1] = 'Modifier son propre mot de passe';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 1;
$this->rights[$r][4] = 'self';
$this->rights[$r][5] = 'password';
2010-11-07 18:45:51 +01:00
2008-10-01 21:10:17 +02:00
$r++;
2010-11-08 18:21:52 +01:00
$this->rights[$r][0] = 344;
2010-10-28 21:31:11 +02:00
$this->rights[$r][1] = 'Modifier ses propres permissions';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 1;
2011-05-05 09:02:22 +02:00
$this->rights[$r][4] = 'self_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
2010-10-28 21:31:11 +02:00
$this->rights[$r][5] = 'writeperms';
2010-11-07 18:45:51 +01:00
2010-10-28 21:31:11 +02:00
$r++;
$this->rights[$r][0] = 351;
$this->rights[$r][1] = 'Consulter les groupes';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
2011-05-05 09:02:22 +02:00
$this->rights[$r][4] = 'group_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
2010-10-28 21:31:11 +02:00
$this->rights[$r][5] = 'read';
2010-11-07 18:45:51 +01:00
2010-10-28 21:31:11 +02:00
$r++;
$this->rights[$r][0] = 352;
$this->rights[$r][1] = 'Consulter les permissions des groupes';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
2011-05-05 09:02:22 +02:00
$this->rights[$r][4] = 'group_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
2010-10-28 21:31:11 +02:00
$this->rights[$r][5] = 'readperms';
2010-11-07 18:45:51 +01:00
2010-10-28 21:31:11 +02:00
$r++;
$this->rights[$r][0] = 353;
$this->rights[$r][1] = 'Creer/modifier les groupes et leurs permissions';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
2011-05-05 09:02:22 +02:00
$this->rights[$r][4] = 'group_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
2010-10-28 21:31:11 +02:00
$this->rights[$r][5] = 'write';
2010-11-07 18:45:51 +01:00
2010-10-28 21:31:11 +02:00
$r++;
$this->rights[$r][0] = 354;
$this->rights[$r][1] = 'Supprimer ou desactiver les groupes';
$this->rights[$r][2] = 'd';
$this->rights[$r][3] = 0;
2011-05-05 09:02:22 +02:00
$this->rights[$r][4] = 'group_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
2010-10-28 21:31:11 +02:00
$this->rights[$r][5] = 'delete';
$r++;
$this->rights[$r][0] = 358;
2008-10-01 21:10:17 +02:00
$this->rights[$r][1] = 'Exporter les utilisateurs';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'user';
$this->rights[$r][5] = 'export';
// Exports
//--------
$r=0;
$r++;
$this->export_code[$r]=$this->rights_class.'_'.$r;
$this->export_label[$r]='Liste des utilisateurs Dolibarr et attributs';
$this->export_permission[$r]=array(array("user","user","export"));
2014-02-25 04:39:41 +01:00
$this->export_fields_array[$r]=array('u.rowid'=>"Id",'u.login'=>"Login",'u.lastname'=>"Lastname",'u.firstname'=>"Firstname",'u.office_phone'=>'Phone','u.office_fax'=>'Fax','u.email'=>'EMail','u.datec'=>"DateCreation",'u.tms'=>"DateLastModification",'u.admin'=>"Administrator",'u.statut'=>'Status','u.note'=>"Note",'u.datelastlogin'=>'LastConnexion','u.datepreviouslogin'=>'PreviousConnexion','u.fk_socpeople'=>"IdContact",'u.fk_societe'=>"IdCompany",'u.fk_member'=>"MemberId");
2013-02-23 17:40:28 +01:00
$this->export_TypeFields_array[$r]=array('u.login'=>"Text",'u.lastname'=>"Text",'u.firstname'=>"Text",'u.office_phone'=>'Text','u.office_fax'=>'Text','u.email'=>'Text','u.datec'=>"Date",'u.tms'=>"Date",'u.admin'=>"Boolean",'u.statut'=>'Status','u.note'=>"Text",'u.datelastlogin'=>'Date','u.datepreviouslogin'=>'Date','u.fk_societe'=>"List:societe:nom:rowid",'u.fk_member'=>"List:adherent:nom");
2013-02-23 17:40:28 +01:00
$this->export_entities_array[$r]=array('u.rowid'=>"user",'u.login'=>"user",'u.lastname'=>"user",'u.firstname'=>"user",'u.office_phone'=>'user','u.office_fax'=>'user','u.email'=>'user','u.datec'=>"user",'u.tms'=>"user",'u.admin'=>"user",'u.statut'=>'user','u.note'=>"user",'u.datelastlogin'=>'user','u.datepreviouslogin'=>'user','u.fk_socpeople'=>"contact",'u.fk_societe'=>"company",'u.fk_member'=>"member");
if (empty($conf->adherent->enabled))
{
unset($this->export_fields_array[$r]['u.fk_member']);
unset($this->export_entities_array[$r]['u.fk_member']);
}
2008-10-01 21:10:17 +02:00
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'user as u';
2009-04-28 12:16:31 +02:00
$this->export_sql_end[$r] .=' WHERE u.entity IN (0,'.$conf->entity.')';
2008-10-01 21:10:17 +02:00
}
2011-02-14 19:29:06 +01:00
/**
2012-01-04 21:23:50 +01:00
* Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories
*
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
2011-02-14 19:29:06 +01:00
*/
2012-01-04 21:23:50 +01:00
function init($options='')
2008-10-01 21:10:17 +02:00
{
global $conf;
// Permissions
$this->remove($options);
2008-10-01 21:10:17 +02:00
$sql = array();
2012-01-04 21:23:50 +01:00
return $this->_init($sql,$options);
2008-10-01 21:10:17 +02:00
}
2011-02-14 19:29:06 +01:00
/**
* Function called when module is disabled.
* Remove from database constants, boxes and permissions from Dolibarr database.
* Data directories are not deleted
*
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
2011-02-14 19:29:06 +01:00
*/
function remove($options='')
{
2008-10-01 21:10:17 +02:00
$sql = array();
return $this->_remove($sql,$options);
}
2005-08-23 13:13:03 +02:00
}
?>