29require
'../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
34$langs->loadLangs(array(
'admin',
'users',
'other'));
36$action =
GETPOST(
'action',
'aZ09');
38$entity = $conf->entity;
49if ($action ==
'add') {
50 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"rights_def SET bydefault=1";
51 $sql .=
" WHERE id = ".GETPOSTINT(
"pid");
52 $sql .=
" AND entity = ".$conf->entity;
56if ($action ==
'remove') {
57 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"rights_def SET bydefault=0";
58 $sql .=
" WHERE id = ".GETPOSTINT(
'pid');
59 $sql .=
" AND entity = ".$conf->entity;
70$wikihelp =
'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
72llxHeader(
'', $langs->trans(
"DefaultRights"), $wikihelp,
'', 0, 0,
'',
'',
'',
'mod-admin page-perms');
76print
'<span class="opacitymedium">'.$langs->trans(
"DefaultRightsDesc").
" ".$langs->trans(
"OnlyActiveElementsAreShown").
"</span><br><br>\n";
84foreach ($modulesdir as $dir) {
86 if (is_resource($handle)) {
87 while (($file = readdir($handle)) !==
false) {
88 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
89 $modName = substr($file, 0,
dol_strlen($file) - 10);
91 include_once $dir.$file;
92 $objMod =
new $modName($db);
95 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
96 foreach ($objMod->langfiles as $domain) {
97 $langs->load($domain);
101 if ($objMod->rights_class) {
102 $ret = $objMod->insert_permissions(0, $entity);
103 $modules[$objMod->rights_class] = $objMod;
113'@phan-var-force DolibarrModules[] $modules';
124print
'<div class="div-table-responsive-no-min">';
125print
'<table class="noborder centpercent">';
127print
'<tr class="liste_titre">';
128print
'<td>'.$langs->trans(
"Module").
'</td>';
129print
'<td class="center">'.$langs->trans(
"Default").
'</td>';
130print
'<td class="center" width="24"> </td>';
131print
'<td>'.$langs->trans(
"Permissions").
'</td>';
133 print
'<td class="right"></td>';
138$sql =
"SELECT r.id, r.libelle as label, r.module, r.perms, r.subperms, r.module_position, r.bydefault";
139$sql .=
" FROM ".MAIN_DB_PREFIX.
"rights_def as r";
140$sql .=
" WHERE r.libelle NOT LIKE 'tou%'";
141$sql .=
" AND r.entity = ".((int) $entity);
143 $sql .=
" AND r.perms NOT LIKE '%_advance'";
145$sql .=
" ORDER BY r.family_position, r.module_position, r.module, r.id";
147$result = $db->query($sql);
149 $num = $db->num_rows($result);
154 $obj = $db->fetch_object($result);
157 if (empty($modules[$obj->module])) {
162 $objMod = $modules[$obj->module];
165 if (empty($obj->module_position) || (is_object($objMod) && $objMod->isCoreOrExternalModule() ==
'external' && $obj->module_position < 100000)) {
166 if (is_object($modules[$obj->module]) && ($modules[$obj->module]->module_position > 0)) {
171 $newmoduleposition = $modules[$obj->module]->module_position;
174 $objMod = $modules[$obj->module];
175 if (is_object($objMod) && $objMod->isCoreOrExternalModule() ==
'external' && $newmoduleposition < 100000) {
176 $newmoduleposition += 100000;
179 $sqlupdate =
'UPDATE '.MAIN_DB_PREFIX.
"rights_def SET module_position = ".((int) $newmoduleposition).
",";
180 $sqlupdate .=
" family_position = ".((int) $familyposition);
181 $sqlupdate .=
" WHERE module_position = ".((int) $obj->module_position).
" AND module = '".$db->escape($obj->module).
"'";
182 $db->query($sqlupdate);
188 foreach ($modules[$obj->module]->rights as $key => $val) {
189 if ($val[4] == $obj->perms && (empty($val[5]) || $val[5] == $obj->subperms)) {
200 if (isset($obj->module) && ($oldmod != $obj->module)) {
201 $oldmod = $obj->module;
204 $objMod = $modules[$obj->module];
205 $picto = ($objMod->picto ? $objMod->picto :
'generic');
208 print
'<tr class="oddeven trforbreak">';
209 print
'<td class="maxwidthonsmartphone tdoverflowmax200" title="'.dol_escape_htmltag($objMod->getName()).
'">';
210 print
img_object(
'', $picto,
'class="pictoobjectwidth paddingright"').
' '.$objMod->getName();
211 print
'<a name="'.$objMod->getName().
'"></a>';
213 print
'<td> </td>';
214 print
'<td> </td>';
215 print
'<td> </td>';
218 print
'<td class="right"></td>';
223 print
'<!-- '.$obj->module.
'->'.$obj->perms.($obj->subperms ?
'->'.$obj->subperms :
'').
' -->'.
"\n";
224 print
'<tr class="oddeven">';
227 print
'<td class="maxwidthonsmartphone tdoverflowmax200">';
232 if ($obj->bydefault == 1) {
233 print
'<td class="center">';
234 print
'<a class="reposition" href="perms.php?pid='.$obj->id.
'&action=remove&token='.
newToken().
'">';
239 print
'<td class="center">';
243 print
'<td class="center">';
244 print
'<a class="reposition" href="perms.php?pid='.$obj->id.
'&action=add&token='.
newToken().
'">';
249 print
'<td class="center">';
255 $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)));
258 if ($langs->trans(
"Permission".$obj->id.
'b') !=
"Permission".$obj->id.
'b') {
259 print
'<br><span class="opacitymedium">'.$langs->trans(
"Permission".$obj->id.
'b').
'</span>';
261 if ($langs->trans(
"Permission".$obj->id.
'c') !=
"Permission".$obj->id.
'c') {
262 print
'<br><span class="opacitymedium">'.$langs->trans(
"Permission".$obj->id.
'c').
'</span>';
265 if (preg_match(
'/_advance$/', $obj->perms)) {
266 print
' <span class="opacitymedium">('.$langs->trans(
"AdvancedModeOnly").
')</span>';
273 print
'<td class="right">';
274 $htmltext = $langs->trans(
"ID").
': '.$obj->id;
275 $htmltext .=
'<br>'.$langs->trans(
"Permission").
': user->hasRight(\''.
dol_escape_htmltag($obj->module).
'\', \
''.dol_escape_htmltag($obj->perms).
'\''.($obj->subperms ?
', \''.dol_escape_htmltag($obj->subperms).
'\'' :
'').
')';
276 print $form->textwithpicto(
'', $htmltext);
291$parameters = array();
292$reshook = $hookmanager->executeHooks(
'insertExtraFooter', $parameters,
$object, $action);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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 directories that contain modules.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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_get_fiche_end($notab=0)
Return tab footer of a card.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.