diff --git a/htdocs/includes/modules/modUser.class.php b/htdocs/includes/modules/modUser.class.php index b7ef01d6e41..c097f522edf 100644 --- a/htdocs/includes/modules/modUser.class.php +++ b/htdocs/includes/modules/modUser.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2005-2009 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2010 Regis Houssin * * 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 @@ -39,8 +39,8 @@ class modUser extends DolibarrModules { /** - * \brief Constructeur. Definit les noms, constantes et boites - * \param DB handler d'acces base + * Constructeur. Definit les noms, constantes et boites + * @param DB handler d'acces base */ function modUser($DB) { @@ -87,38 +87,46 @@ class modUser extends DolibarrModules $r++; $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][3] = 0; $this->rights[$r][4] = 'user'; $this->rights[$r][5] = 'lire'; - + $r++; $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][3] = 0; $this->rights[$r][4] = 'user'; $this->rights[$r][5] = 'creer'; - + $r++; - $this->rights[$r][0] = 253; - $this->rights[$r][1] = 'Modifier mot de passe des autres utilisateurs'; + $this->rights[$r][0] = 254; + $this->rights[$r][1] = 'Modifier le mot de passe des autres utilisateurs'; $this->rights[$r][2] = 'w'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'user'; $this->rights[$r][5] = 'password'; $r++; - $this->rights[$r][0] = 254; + $this->rights[$r][0] = 255; $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'; - + $r++; - $this->rights[$r][0] = 255; + $this->rights[$r][0] = 256; $this->rights[$r][1] = 'Creer/modifier ses propres infos utilisateur'; $this->rights[$r][2] = 'w'; $this->rights[$r][3] = 1; @@ -126,15 +134,55 @@ class modUser extends DolibarrModules $this->rights[$r][5] = 'creer'; $r++; - $this->rights[$r][0] = 256; + $this->rights[$r][0] = 257; $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'; - + $r++; $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][2] = 'r'; $this->rights[$r][3] = 0; diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index d6b943cf79b..02329537905 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -3239,7 +3239,15 @@ function migrate_reload_modules($db,$langs,$conf) //$mod->remove('noboxes'); $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 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Deplacement"); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index fcc5588612e..a61102a2f49 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -512,13 +512,14 @@ Permission241=Read categories Permission242=Create/modify categories Permission243=Delete categories Permission244=See the contents of the hidden categories -Permission251=Read other users and groups -Permission252=Create/modify other users, groups and permisssions -Permission253=Modify other users password -Permission254=Delete or disable other users -Permission255=Create/modify his own user information -Permission256=Modify his own password -Permission258=Export users +Permission251=Read other users +Permission252=Read permissions of other users +Permission253=Create/modify other users and permissions +Permission254=Modify other users password +Permission255=Delete or disable other users +Permission256=Create/modify his own user information +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). Permission271=Read CA Permission272=Read invoices @@ -538,6 +539,11 @@ Permission312=Assign service to contract Permission331=Read bookmarks Permission332=Create/modify 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 Permission402=Create/modify discounts Permission403=Validate discounts diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 91e8fa2a614..248acfcfdce 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -514,13 +514,14 @@ Permission241= Lire les catégories Permission242= Créer/modifier les catégories Permission243= Supprimer les catégories Permission244= Voir le contenu des catégories cachées -Permission251= Consulter les autres utilisateurs, leurs groupes et permissions -Permission252= Créer/modifier les autres utilisateurs, les groupes et leurs permissions -Permission253= Modifier mot de passe des autres utilisateurs -Permission254= Supprimer ou désactiver les autres utilisateurs -Permission255= Créer/modifier ses propres infos utilisateur -Permission256= Modifier son propre mot de passe -Permission258= Exporter les utilisateurs +Permission251= Consulter les autres utilisateurs +Permission252= Consulter les permissions des autres utilisateurs +Permission253= Créer/modifier les autres utilisateurs et leurs permissions +Permission254= Modifier le mot de passe des autres utilisateurs +Permission255= Supprimer ou désactiver les autres utilisateurs +Permission256= Créer/modifier ses propres infos utilisateur +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). Permission271= Consulter le CA Permission272= Consulter les factures @@ -540,6 +541,11 @@ Permission312= Affecter des services à un contrat Permission331= Lire les bookmarks Permission332= Créer/modifier 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 Permission402= Créer/modifier les avoirs Permission403= Valider les avoirs diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 6634fcf8b00..09568a5d9c7 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -229,8 +229,8 @@ class UserGroup extends CommonObject // Where pour la liste des droits a ajouter $whereforadd="id=".$rid; // Ajout des droits induits - if ($subperms) $whereforadd.=" OR (module='$module' AND perms='$perms' AND subperms='lire')"; - if ($perms) $whereforadd.=" OR (module='$module' AND perms='lire' AND subperms IS NULL)"; + if ($subperms) $whereforadd.=" OR (module='$module' AND perms='$perms' AND (subperms='lire' OR subperms='read'))"; + 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 // 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 $wherefordel="id=".$rid; // Suppression des droits induits - if ($subperms=='lire') $wherefordel.=" OR (module='$module' AND perms='$perms' AND subperms IS NOT NULL)"; - if ($perms=='lire') $wherefordel.=" OR (module='$module')"; + if ($subperms=='lire' || $subperms=='read') $wherefordel.=" OR (module='$module' AND perms='$perms' AND subperms IS NOT NULL)"; + if ($perms=='lire' || $perms=='read') $wherefordel.=" OR (module='$module')"; // Pour compatibilite, si lowid = 0, on est en mode suppression de tout // TODO A virer quand sera gere par l'appelant diff --git a/htdocs/user/group/perms.php b/htdocs/user/group/perms.php index dbe72944921..c37e90be53f 100644 --- a/htdocs/user/group/perms.php +++ b/htdocs/user/group/perms.php @@ -36,7 +36,7 @@ $module=isset($_GET["module"])?$_GET["module"]:$_POST["module"]; // Defini si peux modifier utilisateurs et permisssions $caneditperms=($user->admin || $user->rights->user->user->creer); - +$caneditselfperms=($user->admin || $user->rights->user->self->perms); /** * Actions @@ -213,7 +213,7 @@ if ($_GET["id"]) $oldmod = $obj->module; $var = !$var; - // Rupture d�tect�e, on r�cup�re objMod + // Rupture detectee, on recupere objMod $objMod = $modules[$obj->module]; $picto=($objMod->picto?$objMod->picto:'generic'); diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index 07f4dd8e081..705ae572295 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -36,12 +36,15 @@ $module=isset($_GET["module"])?$_GET["module"]:$_POST["module"]; 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); -// 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); +// Defini si peux modifier ses propres permissions +$caneditselfperms=($user->admin || $user->rights->user->self->perms); + // Security check $socid=0; if ($user->societe_id > 0) $socid = $user->societe_id;