28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
33$langs->loadLangs(array(
'admin',
'users',
'other'));
35$action =
GETPOST(
'action',
'aZ09');
41$entity = $conf->entity;
48if ($action ==
'add') {
49 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"rights_def SET bydefault=1";
50 $sql .=
" WHERE id = ".GETPOST(
"pid",
'int');
51 $sql .=
" AND entity = ".$conf->entity;
55if ($action ==
'remove') {
56 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"rights_def SET bydefault=0";
57 $sql .=
" WHERE id = ".GETPOST(
'pid',
'int');
58 $sql .=
" AND entity = ".$conf->entity;
67$wikihelp =
'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
69llxHeader(
'', $langs->trans(
"DefaultRights"), $wikihelp);
73print
'<span class="opacitymedium">'.$langs->trans(
"DefaultRightsDesc").
" ".$langs->trans(
"OnlyActiveElementsAreShown").
"</span><br><br>\n";
81foreach ($modulesdir as $dir) {
83 if (is_resource($handle)) {
84 while (($file = readdir($handle)) !==
false) {
85 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
86 $modName = substr($file, 0,
dol_strlen($file) - 10);
88 include_once $dir.$file;
89 $objMod =
new $modName($db);
92 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
93 foreach ($objMod->langfiles as $domain) {
94 $langs->load($domain);
98 if ($objMod->rights_class) {
99 $ret = $objMod->insert_permissions(0, $entity);
100 $modules[$objMod->rights_class] = $objMod;
120print
'<div class="div-table-responsive-no-min">';
121print
'<table class="noborder centpercent">';
123print
'<tr class="liste_titre">';
124print
'<td>'.$langs->trans(
"Module").
'</td>';
125print
'<td class="center">'.$langs->trans(
"Default").
'</td>';
126print
'<td class="center" width="24"> </td>';
127print
'<td>'.$langs->trans(
"Permissions").
'</td>';
129 print
'<td class="right"></td>';
134$sql =
"SELECT r.id, r.libelle as label, r.module, r.perms, r.subperms, r.module_position, r.bydefault";
135$sql .=
" FROM ".MAIN_DB_PREFIX.
"rights_def as r";
136$sql .=
" WHERE r.libelle NOT LIKE 'tou%'";
137$sql .=
" AND r.entity = ".((int) $entity);
139 $sql .=
" AND r.perms NOT LIKE '%_advance'";
141$sql .=
" ORDER BY r.family_position, r.module_position, r.module, r.id";
143$result = $db->query($sql);
145 $num = $db->num_rows($result);
150 $obj = $db->fetch_object($result);
153 if (empty($modules[$obj->module])) {
158 $objMod = $modules[$obj->module];
161 if (empty($obj->module_position) || (is_object($objMod) && $objMod->isCoreOrExternalModule() ==
'external' && $obj->module_position < 100000)) {
162 if (is_object($modules[$obj->module]) && ($modules[$obj->module]->module_position > 0)) {
167 $newmoduleposition = $modules[$obj->module]->module_position;
170 $objMod = $modules[$obj->module];
171 if (is_object($objMod) && $objMod->isCoreOrExternalModule() ==
'external' && $newmoduleposition < 100000) {
172 $newmoduleposition += 100000;
175 $sqlupdate =
'UPDATE '.MAIN_DB_PREFIX.
"rights_def SET module_position = ".((int) $newmoduleposition).
",";
176 $sqlupdate .=
" family_position = ".((int) $familyposition);
177 $sqlupdate .=
" WHERE module_position = ".((int) $obj->module_position).
" AND module = '".$db->escape($obj->module).
"'";
178 $db->query($sqlupdate);
184 foreach ($modules[$obj->module]->rights as $key => $val) {
185 if ($val[4] == $obj->perms && (empty($val[5]) || $val[5] == $obj->subperms)) {
196 if (isset($obj->module) && ($oldmod != $obj->module)) {
197 $oldmod = $obj->module;
200 $objMod = $modules[$obj->module];
201 $picto = ($objMod->picto ? $objMod->picto :
'generic');
204 print
'<tr class="oddeven trforbreak">';
205 print
'<td class="maxwidthonsmartphone tdoverflowonsmartphone">';
206 print
img_object(
'', $picto,
'class="pictoobjectwidth paddingright"').
' '.$objMod->getName();
207 print
'<a name="'.$objMod->getName().
'"></a>';
209 print
'<td> </td>';
210 print
'<td> </td>';
211 print
'<td> </td>';
214 print
'<td class="right"></td>';
219 print
'<!-- '.$obj->module.
'->'.$obj->perms.($obj->subperms ?
'->'.$obj->subperms :
'').
' -->'.
"\n";
220 print
'<tr class="oddeven">';
223 print
'<td class="maxwidthonsmartphone tdoverflowonsmartphone">';
228 if ($obj->bydefault == 1) {
229 print
'<td class="center">';
230 print
'<a class="reposition" href="perms.php?pid='.$obj->id.
'&action=remove&token='.newToken().
'">';
235 print
'<td class="center">';
239 print
'<td class="center">';
240 print
'<a class="reposition" href="perms.php?pid='.$obj->id.
'&action=add&token='.newToken().
'">';
245 print
'<td class="center">';
251 $permlabel = (
getDolGlobalString(
'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)));
255 if (preg_match(
'/_advance$/', $obj->perms)) {
256 print
' <span class="opacitymedium">('.$langs->trans(
"AdvancedModeOnly").
')</span>';
263 print
'<td class="right">';
264 $htmltext = $langs->trans(
"ID").
': '.$obj->id;
265 $htmltext .=
'<br>'.$langs->trans(
"Permission").
': user->rights->'.$obj->module.
'->'.$obj->perms.($obj->subperms ?
'->'.$obj->subperms :
'');
266 print $form->textwithpicto(
'', $htmltext);
281$parameters = array();
282$reshook = $hookmanager->executeHooks(
'insertExtraFooter', $parameters, $object, $action);
security_prepare_head()
Prepare array with list of tabs.
showModulesExludedForExternal($modules)
Show array with constants to edit.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
dolGetModulesDirs($subdir='')
Return list of modules directories.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.