Look and feel v12

Fix error report
This commit is contained in:
Laurent Destailleur 2020-04-18 16:48:49 +02:00
parent ae80b09327
commit 19815850c0
2 changed files with 51 additions and 32 deletions

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2020 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com>
*
@ -28,6 +28,7 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
// Load translation files required by page
$langs->loadLangs(array('users', 'admin'));
@ -39,9 +40,9 @@ $module = GETPOST('module', 'alpha');
$rights = GETPOST('rights', 'int');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'groupperms'; // To manage different context of search
// Defini si peux lire les permissions
// Define if user can read permissions
$canreadperms = ($user->admin || $user->rights->user->user->lire);
// Defini si peux modifier les permissions
// Define if user can modify group permissions
$caneditperms = ($user->admin || $user->rights->user->user->creer);
// Advanced permissions
$advancedpermsactive = false;
@ -76,7 +77,12 @@ if (empty($reshook)) {
$editgroup = new Usergroup($db);
$result = $editgroup->fetch($id);
if ($result > 0) {
$editgroup->addrights($rights, $module, '', $entity);
$result= $editgroup->addrights($rights, $module, '', $entity);
if ($result < 0) {
setEventMessages($editgroup->error, $editgroup->errors, 'errors');
}
} else {
dol_print_error($db);
}
}
@ -84,7 +90,12 @@ if (empty($reshook)) {
$editgroup = new Usergroup($db);
$result = $editgroup->fetch($id);
if ($result > 0) {
$editgroup->delrights($rights, $module, '', $entity);
$result = $editgroup->delrights($rights, $module, '', $entity);
if ($result < 0) {
setEventMessages($editgroup->error, $editgroup->errors, 'errors');
}
} else {
dol_print_error($db);
}
}
}
@ -117,8 +128,6 @@ if ($object->id > 0)
foreach ($modulesdir as $dir)
{
// Load modules attributes in arrays (name, numero, orders) from dir directory
//print $dir."\n<br>";
$handle = @opendir(dol_osencode($dir));
if (is_resource($handle))
{
@ -130,7 +139,7 @@ if ($object->id > 0)
if ($modName)
{
include_once $dir."/".$file;
include_once $dir.$file;
$objMod = new $modName($db);
// Load all lang files of module
if (isset($objMod->langfiles) && is_array($objMod->langfiles))
@ -154,7 +163,7 @@ if ($object->id > 0)
$db->commit();
// Lecture des droits groupes
// Read permissions of group
$permsgroupbyentity = array();
$sql = "SELECT DISTINCT r.id, r.libelle, r.module, gr.entity";
@ -225,20 +234,22 @@ if ($object->id > 0)
$reshook = $hookmanager->executeHooks('insertExtraHeader', $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 "\n";
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Module").'</td>';
if ($caneditperms)
{
print '<td class="center nowrap">';
print '<a class="reposition" title="'.dol_escape_htmltag($langs->trans("All")).'" alt="'.dol_escape_htmltag($langs->trans("All")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;module=allmodules">'.$langs->trans("All")."</a>";
print '<a class="reposition commonlink" title="'.dol_escape_htmltag($langs->trans("All")).'" alt="'.dol_escape_htmltag($langs->trans("All")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;module=allmodules">'.$langs->trans("All")."</a>";
print '/';
print '<a class="reposition" title="'.dol_escape_htmltag($langs->trans("None")).'" alt="'.dol_escape_htmltag($langs->trans("None")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delrights&amp;entity='.$entity.'&amp;module=allmodules">'.$langs->trans("None")."</a>";
print '<a class="reposition commonlink" title="'.dol_escape_htmltag($langs->trans("None")).'" alt="'.dol_escape_htmltag($langs->trans("None")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delrights&amp;entity='.$entity.'&amp;module=allmodules">'.$langs->trans("None")."</a>";
print '</td>';
}
print '<td class="center" width="24">&nbsp;</td>';
print '<td>'.$langs->trans("Permissions").'</td>';
print '</tr>';
print '</tr>'."\n";
$sql = "SELECT r.id, r.libelle as label, r.module";
$sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r";
@ -250,16 +261,15 @@ if ($object->id > 0)
$result = $db->query($sql);
if ($result)
{
$i = 0;
$num = $db->num_rows($result);
$i = 0;
$oldmod = '';
$num = $db->num_rows($result);
while ($i < $num)
{
$obj = $db->fetch_object($result);
// Si la ligne correspond a un module qui n'existe plus (absent de includes/module), on l'ignore
// If line is for a module that doe snot existe anymore (absent of includes/module), we ignore it
if (empty($modules[$obj->module]))
{
$i++;
@ -270,29 +280,37 @@ if ($object->id > 0)
{
$oldmod = $obj->module;
// Rupture detectee, on recupere objMod
// Break detected, we get objMod
$objMod = $modules[$obj->module];
$picto = ($objMod->picto ? $objMod->picto : 'generic');
// Show break line
print '<tr class="oddeven trforbreak">';
print '<td class="nowrap">'.img_object('', $picto, 'class="inline-block pictoobjectwidth"').' '.$objMod->getName();
print '<a name="'.$objMod->getName().'">&nbsp;</a></td>';
print '<td class="center nowrap">';
print '<td class="maxwidthonsmartphone tdoverflowonsmartphone">';
print img_object('', $picto, 'class="pictoobjectwidth paddingright"').' '.$objMod->getName();
print '<a name="'.$objMod->getName().'"></a>';
print '</td>';
if ($caneditperms)
{
print '<td class="center nowrap">';
print '<a title='.$langs->trans("All").' alt='.$langs->trans("All").' href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;module='.$obj->module.'#'.$objMod->getName().'">'.$langs->trans("All")."</a>";
print '/';
print '<a title='.$langs->trans("None").' alt='.$langs->trans("None").' href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delrights&amp;entity='.$entity.'&amp;module='.$obj->module.'#'.$objMod->getName().'">'.$langs->trans("None")."</a>";
print '</td>';
} else {
print '<td>&nbsp;</td>';
}
print '</td>';
print '<td colspan="2">&nbsp;</td>';
print '</tr>';
}
print '<!-- '.$obj->module.'->'.$obj->perms.($obj->subperms ? '->'.$obj->subperms : '').' -->'."\n";
print '<tr class="oddeven">';
// Module
print '<td class="nowrap">'.img_object('', $picto, 'class="inline-block pictoobjectwidth"').' '.$objMod->getName().'</td>';
// Picto and label of module
print '<td class="maxwidthonsmartphone tdoverflowonsmartphone">';
//print img_object('', $picto, 'class="inline-block pictoobjectwidth"').' '.$objMod->getName();
print '</td>';
if (is_array($permsgroupbyentity[$entity]))
{
@ -303,7 +321,7 @@ if ($object->id > 0)
{
print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delrights&amp;entity='.$entity.'&amp;rights='.$obj->id.'">'.img_edit_remove($langs->trans("Remove")).'</a></td>';
}
print '<td class="center">';
print '<td class="center nowrap">';
print img_picto($langs->trans("Active"), 'tick');
print '</td>';
}
@ -327,15 +345,16 @@ if ($object->id > 0)
print '<td>&nbsp</td>';
}
$perm_libelle = ($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 '<td>'.$perm_libelle.'</td>';
$permlabel = ($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 '<td class="maxwidthonsmartphone">'.$permlabel.'</td>';
print '</tr>';
print '</tr>'."\n";
$i++;
}
}
print '</table>';
print '</div>';
print '</div>';

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2020 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
@ -42,9 +42,9 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'use
if (!isset($id) || empty($id)) accessforbidden();
// Defini si peux lire les permissions
// Define if user can read permissions
$canreaduser = ($user->admin || $user->rights->user->user->lire);
// Defini si peux modifier les autres utilisateurs et leurs permisssions
// Define if user can modify other users and permissions
$caneditperms = ($user->admin || $user->rights->user->user->creer);
// Advanced permissions
if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS))
@ -132,10 +132,10 @@ if (empty($reshook)) {
* View
*/
llxHeader('', $langs->trans("Permissions"));
$form = new Form($db);
llxHeader('', $langs->trans("Permissions"));
$head = user_prepare_head($object);
$title = $langs->trans("User");