diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php
index f08a1497181..8f4c0c6f763 100644
--- a/htdocs/admin/perms.php
+++ b/htdocs/admin/perms.php
@@ -21,7 +21,7 @@
/**
* \file htdocs/admin/perms.php
* \ingroup core
- * \brief Page d'administration/configuration des permissions par defaut
+ * \brief Page to setup default permissions of a new user
*/
require '../main.inc.php';
@@ -64,6 +64,7 @@ if ($action == 'remove') {
*/
$wikihelp = 'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
+
llxHeader('', $langs->trans("DefaultRights"), $wikihelp);
print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup');
@@ -121,15 +122,15 @@ print '
';
print '';
print '| '.$langs->trans("Module").' | ';
print ''.$langs->trans("Default").' | ';
-print ' | ';
+print ' | ';
print ''.$langs->trans("Permissions").' | ';
if ($user->admin) {
- print ''.$langs->trans("ID").' | ';
+ print ' | ';
}
print '
'."\n";
//print "xx".$conf->global->MAIN_USE_ADVANCED_PERMS;
-$sql = "SELECT r.id, r.libelle as label, r.module, r.module_position, r.perms, r.subperms, r.bydefault";
+$sql = "SELECT r.id, r.libelle as label, r.module, r.perms, r.subperms, r.module_position, r.bydefault";
$sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r";
$sql .= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous"
$sql .= " AND r.entity = ".((int) $entity);
@@ -147,21 +148,32 @@ if ($result) {
while ($i < $num) {
$obj = $db->fetch_object($result);
- // If line is for a module that doe snot existe anymore (absent of includes/module), we ignore it
+ // If line is for a module that does not exist anymore (absent of includes/module), we ignore it
if (empty($modules[$obj->module])) {
$i++;
continue;
}
- // Save field module_position in database if value is still zero
- if (empty($obj->module_position)) {
+ $objMod = $modules[$obj->module];
+
+ // Save field module_position in database if value is wrong
+ if (empty($obj->module_position) || (is_object($objMod) && $objMod->isCoreOrExternalModule() == 'external' && $obj->module_position < 100000)) {
if (is_object($modules[$obj->module]) && ($modules[$obj->module]->module_position > 0)) {
// TODO Define familyposition
- $family = (!empty($modules[$obj->module]->family_position) ? $modules[$obj->module]->family_position : '');
+ //$familyposition = $modules[$obj->module]->family_position;
$familyposition = 0;
- $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX."rights_def SET module_position = ".((int) $modules[$obj->module]->module_position).",";
+
+ $newmoduleposition = $modules[$obj->module]->module_position;
+
+ // Correct $newmoduleposition position for external modules
+ $objMod = $modules[$obj->module];
+ if (is_object($objMod) && $objMod->isCoreOrExternalModule() == 'external' && $newmoduleposition < 100000) {
+ $newmoduleposition += 100000;
+ }
+
+ $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX."rights_def SET module_position = ".((int) $newmoduleposition).",";
$sqlupdate .= " family_position = ".((int) $familyposition);
- $sqlupdate .= " WHERE module_position = 0 AND module = '".$db->escape($obj->module)."'";
+ $sqlupdate .= " WHERE module_position = ".((int) $obj->module_position)." AND module = '".$db->escape($obj->module)."'";
$db->query($sqlupdate);
}
}
@@ -203,12 +215,12 @@ if ($result) {
print ''."\n";
}
- $perm_libelle = (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ($langs->trans("PermissionAdvanced".$obj->id) != ("PermissionAdvanced".$obj->id)) ? $langs->trans("PermissionAdvanced".$obj->id) : (($langs->trans("Permission".$obj->id) != ("Permission".$obj->id)) ? $langs->trans("Permission".$obj->id) : $obj->label));
-
+ print ''."\n";
print '';
// Picto and label of module
print '| ';
+ //print img_object('', $picto, 'class="pictoobjectwidth"').' '.$objMod->getName();
print ' | ';
// Tick
@@ -235,11 +247,24 @@ if ($result) {
}
// Permission and tick
- print ''.$perm_libelle.' | ';
+ $permlabel = (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ($langs->trans("PermissionAdvanced".$obj->id) != ("PermissionAdvanced".$obj->id)) ? $langs->trans("PermissionAdvanced".$obj->id) : (($langs->trans("Permission".$obj->id) != ("Permission".$obj->id)) ? $langs->trans("Permission".$obj->id) : $langs->trans($obj->label)));
+ print '';
+ print $permlabel;
+ if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
+ if (preg_match('/_advance$/', $obj->perms)) {
+ print ' ('.$langs->trans("AdvancedModeOnly").')';
+ }
+ }
+ print ' | ';
// Permission id
if ($user->admin) {
- print ''.$obj->id.' | ';
+ print '';
+ $htmltext = $langs->trans("ID").': '.$obj->id;
+ $htmltext .= ' '.$langs->trans("Permission").': user->rights->'.$obj->module.'->'.$obj->perms.($obj->subperms ? '->'.$obj->subperms : '');
+ print $form->textwithpicto('', $htmltext);
+ //print ''.$obj->id.'';
+ print ' | ';
}
print '
'."\n";
@@ -252,6 +277,12 @@ if ($result) {
print '
';
print '';
+$parameters = array();
+$reshook = $hookmanager->executeHooks('insertExtraFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) {
+ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+}
+
print dol_get_fiche_end();
// End of page
diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql
index c58b9ee3efe..d7aa335a4b2 100644
--- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql
+++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql
@@ -546,4 +546,4 @@ create table llx_c_partnership_type
active tinyint DEFAULT 1 NOT NULL
)ENGINE=innodb;
-
+DELETE FROM llx_rights_def WHERE module = 'hrm' AND perms = 'employee';
diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql
index 6e9ea4601f8..59f04fdb2ca 100644
--- a/htdocs/install/mysql/migration/repair.sql
+++ b/htdocs/install/mysql/migration/repair.sql
@@ -533,3 +533,5 @@ UPDATE llx_facturedet SET situation_percent = 100 WHERE situation_percent IS NUL
--ALTER TABLE llx_tablename ROW_FORMAT=DYNAMIC;
+DELETE FROM llx_rights_def WHERE module = 'hrm' AND perms = 'employee';
+
diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php
index cb0a093867d..2136d0f07c5 100644
--- a/htdocs/user/perms.php
+++ b/htdocs/user/perms.php
@@ -293,10 +293,10 @@ if ($user->admin) {
print ''."\n";
//print "xx".$conf->global->MAIN_USE_ADVANCED_PERMS;
-$sql = "SELECT r.id, r.libelle as label, r.module, r.perms, r.subperms, r.module_position";
+$sql = "SELECT r.id, r.libelle as label, r.module, r.perms, r.subperms, r.module_position, r.bydefault";
$sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r";
$sql .= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous"
-$sql .= " AND r.entity = ".$entity;
+$sql .= " AND r.entity = ".((int) $entity);
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
$sql .= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is not enabled
}
@@ -342,10 +342,12 @@ if ($result) {
}
}
+ // Break found, it's a new module to catch
if (isset($obj->module) && ($oldmod <> $obj->module)) {
$oldmod = $obj->module;
// Break detected, we get objMod
+ $objMod = $modules[$obj->module];
$picto = ($objMod->picto ? $objMod->picto : 'generic');
// Show break line
@@ -436,9 +438,9 @@ if ($result) {
print ' | ';
}
- // Descrption of permission
+ // Description of permission
$permlabel = (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ($langs->trans("PermissionAdvanced".$obj->id) != ("PermissionAdvanced".$obj->id)) ? $langs->trans("PermissionAdvanced".$obj->id) : (($langs->trans("Permission".$obj->id) != ("Permission".$obj->id)) ? $langs->trans("Permission".$obj->id) : $langs->trans($obj->label)));
- print '';
+ print ' | ';
print $permlabel;
if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
if (preg_match('/_advance$/', $obj->perms)) {
|