This commit is contained in:
Regis Houssin 2010-10-28 19:31:11 +00:00
parent 149e2dd18a
commit 40cdb5dba1
7 changed files with 108 additions and 37 deletions

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -39,8 +39,8 @@ class modUser extends DolibarrModules
{ {
/** /**
* \brief Constructeur. Definit les noms, constantes et boites * Constructeur. Definit les noms, constantes et boites
* \param DB handler d'acces base * @param DB handler d'acces base
*/ */
function modUser($DB) function modUser($DB)
{ {
@ -87,7 +87,7 @@ class modUser extends DolibarrModules
$r++; $r++;
$this->rights[$r][0] = 251; $this->rights[$r][0] = 251;
$this->rights[$r][1] = 'Consulter les autres utilisateurs, leurs groupes et permissions'; $this->rights[$r][1] = 'Consulter les autres utilisateurs';
$this->rights[$r][2] = 'r'; $this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'user'; $this->rights[$r][4] = 'user';
@ -95,22 +95,30 @@ class modUser extends DolibarrModules
$r++; $r++;
$this->rights[$r][0] = 252; $this->rights[$r][0] = 252;
$this->rights[$r][1] = 'Creer/modifier les autres utilisateurs, les groupes et leurs permissions'; $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';
$this->rights[$r][5] = 'readperms';
$r++;
$this->rights[$r][0] = 253;
$this->rights[$r][1] = 'Creer/modifier les autres utilisateurs et leurs permissions';
$this->rights[$r][2] = 'w'; $this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'user'; $this->rights[$r][4] = 'user';
$this->rights[$r][5] = 'creer'; $this->rights[$r][5] = 'creer';
$r++; $r++;
$this->rights[$r][0] = 253; $this->rights[$r][0] = 254;
$this->rights[$r][1] = 'Modifier mot de passe des autres utilisateurs'; $this->rights[$r][1] = 'Modifier le mot de passe des autres utilisateurs';
$this->rights[$r][2] = 'w'; $this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'user'; $this->rights[$r][4] = 'user';
$this->rights[$r][5] = 'password'; $this->rights[$r][5] = 'password';
$r++; $r++;
$this->rights[$r][0] = 254; $this->rights[$r][0] = 255;
$this->rights[$r][1] = 'Supprimer ou desactiver les autres utilisateurs'; $this->rights[$r][1] = 'Supprimer ou desactiver les autres utilisateurs';
$this->rights[$r][2] = 'd'; $this->rights[$r][2] = 'd';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
@ -118,7 +126,7 @@ class modUser extends DolibarrModules
$this->rights[$r][5] = 'supprimer'; $this->rights[$r][5] = 'supprimer';
$r++; $r++;
$this->rights[$r][0] = 255; $this->rights[$r][0] = 256;
$this->rights[$r][1] = 'Creer/modifier ses propres infos utilisateur'; $this->rights[$r][1] = 'Creer/modifier ses propres infos utilisateur';
$this->rights[$r][2] = 'w'; $this->rights[$r][2] = 'w';
$this->rights[$r][3] = 1; $this->rights[$r][3] = 1;
@ -126,7 +134,7 @@ class modUser extends DolibarrModules
$this->rights[$r][5] = 'creer'; $this->rights[$r][5] = 'creer';
$r++; $r++;
$this->rights[$r][0] = 256; $this->rights[$r][0] = 257;
$this->rights[$r][1] = 'Modifier son propre mot de passe'; $this->rights[$r][1] = 'Modifier son propre mot de passe';
$this->rights[$r][2] = 'w'; $this->rights[$r][2] = 'w';
$this->rights[$r][3] = 1; $this->rights[$r][3] = 1;
@ -135,6 +143,46 @@ class modUser extends DolibarrModules
$r++; $r++;
$this->rights[$r][0] = 258; $this->rights[$r][0] = 258;
$this->rights[$r][1] = 'Modifier ses propres permissions';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 1;
$this->rights[$r][4] = 'self';
$this->rights[$r][5] = 'writeperms';
$r++;
$this->rights[$r][0] = 351;
$this->rights[$r][1] = 'Consulter les groupes';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'group';
$this->rights[$r][5] = 'read';
$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;
$this->rights[$r][4] = 'group';
$this->rights[$r][5] = 'readperms';
$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;
$this->rights[$r][4] = 'group';
$this->rights[$r][5] = 'write';
$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;
$this->rights[$r][4] = 'group';
$this->rights[$r][5] = 'delete';
$r++;
$this->rights[$r][0] = 358;
$this->rights[$r][1] = 'Exporter les utilisateurs'; $this->rights[$r][1] = 'Exporter les utilisateurs';
$this->rights[$r][2] = 'r'; $this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;

View File

@ -3240,6 +3240,14 @@ function migrate_reload_modules($db,$langs,$conf)
$mod->init(); $mod->init();
} }
if (! empty($conf->global->MAIN_MODULE_USER)) // Permission has changed into 3.0
{
dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module User");
require_once(DOL_DOCUMENT_ROOT.'/includes/modules/modUser.class.php');
$mod=new modUser($db);
//$mod->remove('noboxes'); // We need to remove because id of module has changed
$mod->init();
}
if (! empty($conf->global->MAIN_MODULE_DEPLACEMENT)) // Permission has changed into 3.0 if (! empty($conf->global->MAIN_MODULE_DEPLACEMENT)) // Permission has changed into 3.0
{ {
dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Deplacement"); dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Deplacement");

View File

@ -512,13 +512,14 @@ Permission241=Read categories
Permission242=Create/modify categories Permission242=Create/modify categories
Permission243=Delete categories Permission243=Delete categories
Permission244=See the contents of the hidden categories Permission244=See the contents of the hidden categories
Permission251=Read other users and groups Permission251=Read other users
Permission252=Create/modify other users, groups and permisssions Permission252=Read permissions of other users
Permission253=Modify other users password Permission253=Create/modify other users and permissions
Permission254=Delete or disable other users Permission254=Modify other users password
Permission255=Create/modify his own user information Permission255=Delete or disable other users
Permission256=Modify his own password Permission256=Create/modify his own user information
Permission258=Export users Permission257=Modify his own password
Permission258=Modify its own permissions
Permission262=Extend access to all third parties (not only those linked to user). Not effective for external users (always limited to themselves). Permission262=Extend access to all third parties (not only those linked to user). Not effective for external users (always limited to themselves).
Permission271=Read CA Permission271=Read CA
Permission272=Read invoices Permission272=Read invoices
@ -538,6 +539,11 @@ Permission312=Assign service to contract
Permission331=Read bookmarks Permission331=Read bookmarks
Permission332=Create/modify bookmarks Permission332=Create/modify bookmarks
Permission333=Delete bookmarks Permission333=Delete bookmarks
Permission351=Read groups
Permission352=Read groups permissions
Permission353=Create/modify groups
Permission354=Delete or disable groups
Permission358=Export users
Permission401=Read discounts Permission401=Read discounts
Permission402=Create/modify discounts Permission402=Create/modify discounts
Permission403=Validate discounts Permission403=Validate discounts

View File

@ -514,13 +514,14 @@ Permission241= Lire les catégories
Permission242= Créer/modifier les catégories Permission242= Créer/modifier les catégories
Permission243= Supprimer les catégories Permission243= Supprimer les catégories
Permission244= Voir le contenu des catégories cachées Permission244= Voir le contenu des catégories cachées
Permission251= Consulter les autres utilisateurs, leurs groupes et permissions Permission251= Consulter les autres utilisateurs
Permission252= Créer/modifier les autres utilisateurs, les groupes et leurs permissions Permission252= Consulter les permissions des autres utilisateurs
Permission253= Modifier mot de passe des autres utilisateurs Permission253= Créer/modifier les autres utilisateurs et leurs permissions
Permission254= Supprimer ou désactiver les autres utilisateurs Permission254= Modifier le mot de passe des autres utilisateurs
Permission255= Créer/modifier ses propres infos utilisateur Permission255= Supprimer ou désactiver les autres utilisateurs
Permission256= Modifier son propre mot de passe Permission256= Créer/modifier ses propres infos utilisateur
Permission258= Exporter les utilisateurs Permission257= Modifier son propre mot de passe
Permission258= Modifier ses propres permissions
Permission262= Étendre l'accès à tous les tiers (Pas seulement ceux liés à l'utilisateur). Non effectif pour utilisateurs externes (toujours limité à eux-même). Permission262= Étendre l'accès à tous les tiers (Pas seulement ceux liés à l'utilisateur). Non effectif pour utilisateurs externes (toujours limité à eux-même).
Permission271= Consulter le CA Permission271= Consulter le CA
Permission272= Consulter les factures Permission272= Consulter les factures
@ -540,6 +541,11 @@ Permission312= Affecter des services à un contrat
Permission331= Lire les bookmarks Permission331= Lire les bookmarks
Permission332= Créer/modifier les bookmarks Permission332= Créer/modifier les bookmarks
Permission333= Supprimer les bookmarks Permission333= Supprimer les bookmarks
Permission351= Consulter les groupes
Permission352= Consulter les permissions des groupes
Permission353= Créer/modifier les groupes et leurs permissions
Permission354= Supprimer ou désactiver les groupes
Permission358= Exporter les utilisateurs
Permission401= Consulter les avoirs Permission401= Consulter les avoirs
Permission402= Créer/modifier les avoirs Permission402= Créer/modifier les avoirs
Permission403= Valider les avoirs Permission403= Valider les avoirs

View File

@ -229,8 +229,8 @@ class UserGroup extends CommonObject
// Where pour la liste des droits a ajouter // Where pour la liste des droits a ajouter
$whereforadd="id=".$rid; $whereforadd="id=".$rid;
// Ajout des droits induits // Ajout des droits induits
if ($subperms) $whereforadd.=" OR (module='$module' AND perms='$perms' AND subperms='lire')"; if ($subperms) $whereforadd.=" OR (module='$module' AND perms='$perms' AND (subperms='lire' OR subperms='read'))";
if ($perms) $whereforadd.=" OR (module='$module' AND perms='lire' AND subperms IS NULL)"; if ($perms) $whereforadd.=" OR (module='$module' AND (perms='lire' OR perms='read') AND subperms IS NULL)";
// Pour compatibilite, si lowid = 0, on est en mode ajout de tout // Pour compatibilite, si lowid = 0, on est en mode ajout de tout
// TODO A virer quand sera gere par l'appelant // TODO A virer quand sera gere par l'appelant
@ -328,8 +328,8 @@ class UserGroup extends CommonObject
// Where pour la liste des droits a supprimer // Where pour la liste des droits a supprimer
$wherefordel="id=".$rid; $wherefordel="id=".$rid;
// Suppression des droits induits // Suppression des droits induits
if ($subperms=='lire') $wherefordel.=" OR (module='$module' AND perms='$perms' AND subperms IS NOT NULL)"; if ($subperms=='lire' || $subperms=='read') $wherefordel.=" OR (module='$module' AND perms='$perms' AND subperms IS NOT NULL)";
if ($perms=='lire') $wherefordel.=" OR (module='$module')"; if ($perms=='lire' || $perms=='read') $wherefordel.=" OR (module='$module')";
// Pour compatibilite, si lowid = 0, on est en mode suppression de tout // Pour compatibilite, si lowid = 0, on est en mode suppression de tout
// TODO A virer quand sera gere par l'appelant // TODO A virer quand sera gere par l'appelant

View File

@ -36,7 +36,7 @@ $module=isset($_GET["module"])?$_GET["module"]:$_POST["module"];
// Defini si peux modifier utilisateurs et permisssions // Defini si peux modifier utilisateurs et permisssions
$caneditperms=($user->admin || $user->rights->user->user->creer); $caneditperms=($user->admin || $user->rights->user->user->creer);
$caneditselfperms=($user->admin || $user->rights->user->self->perms);
/** /**
* Actions * Actions
@ -213,7 +213,7 @@ if ($_GET["id"])
$oldmod = $obj->module; $oldmod = $obj->module;
$var = !$var; $var = !$var;
// Rupture d<EFBFBD>tect<EFBFBD>e, on r<>cup<75>re objMod // Rupture detectee, on recupere objMod
$objMod = $modules[$obj->module]; $objMod = $modules[$obj->module];
$picto=($objMod->picto?$objMod->picto:'generic'); $picto=($objMod->picto?$objMod->picto:'generic');

View File

@ -36,12 +36,15 @@ $module=isset($_GET["module"])?$_GET["module"]:$_POST["module"];
if (! isset($_GET["id"]) || empty($_GET["id"])) accessforbidden(); if (! isset($_GET["id"]) || empty($_GET["id"])) accessforbidden();
// Defini si peux lire/modifier permisssions // Defini si peux lire les permissions
$canreaduser=($user->admin || $user->rights->user->user->lire); $canreaduser=($user->admin || $user->rights->user->user->lire);
// Defini si peux modifier utilisateurs et permisssions // Defini si peux modifier les autres utilisateurs et leurs permisssions
$caneditperms=($user->admin || $user->rights->user->user->creer); $caneditperms=($user->admin || $user->rights->user->user->creer);
// Defini si peux modifier ses propres permissions
$caneditselfperms=($user->admin || $user->rights->user->self->perms);
// Security check // Security check
$socid=0; $socid=0;
if ($user->societe_id > 0) $socid = $user->societe_id; if ($user->societe_id > 0) $socid = $user->societe_id;