27 require
'../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
32 $langs->loadLangs(array(
'admin',
'users',
'other'));
34 $action =
GETPOST(
'action',
'aZ09');
38 $entity = $conf->entity;
47 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"rights_def SET bydefault=1";
48 $sql .=
" WHERE id = ".GETPOST(
"pid",
'int');
49 $sql .=
" AND entity = ".$conf->entity;
53 if ($action ==
'remove')
55 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"rights_def SET bydefault=0";
56 $sql .=
" WHERE id = ".GETPOST(
'pid',
'int');
57 $sql .=
" AND entity = ".$conf->entity;
66 $wikihelp =
'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
71 print '<span class="opacitymedium">'.$langs->trans(
"DefaultRightsDesc").
" ".$langs->trans(
"OnlyActiveElementsAreShown").
"</span><br><br>\n";
79 foreach ($modulesdir as $dir)
82 if (is_resource($handle))
84 while (($file = readdir($handle)) !==
false)
86 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php')
88 $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))
97 foreach ($objMod->langfiles as $domain)
99 $langs->load($domain);
103 if ($objMod->rights_class)
105 $ret = $objMod->insert_permissions(0, $entity);
106 $modules[$objMod->rights_class] = $objMod;
126 print '<div class="div-table-responsive-no-min">';
127 print '<table class="noborder centpercent">';
129 print '<tr class="liste_titre">';
130 print '<td>'.$langs->trans(
"Module").
'</td>';
131 print '<td class="center">'.$langs->trans(
"Default").
'</td>';
132 print '<td class="center"> </td>';
133 print '<td>'.$langs->trans(
"Permissions").
'</td>';
134 if ($user->admin)
print '<td class="right">'.$langs->trans(
"ID").
'</td>';
138 $sql =
"SELECT r.id, r.libelle as label, r.module, r.module_position, r.perms, r.subperms, 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 = ".$entity;
142 if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql .=
" AND r.perms NOT LIKE '%_advance'";
143 $sql .=
" ORDER BY r.family_position, r.module_position, r.module, r.id";
145 $result = $db->query($sql);
148 $num = $db->num_rows($result);
154 $obj = $db->fetch_object($result);
157 if (empty($modules[$obj->module]))
164 if (empty($obj->module_position))
166 if (is_object($modules[$obj->module]) && ($modules[$obj->module]->module_position > 0))
169 $family = $modules[$obj->module]->family_position;
171 $sqlupdate =
'UPDATE '.MAIN_DB_PREFIX.
"rights_def SET module_position = ".$modules[$obj->module]->module_position.
",";
172 $sqlupdate .=
" family_position = ".$familyposition;
173 $sqlupdate .=
" WHERE module_position = 0 AND module = '".$db->escape($obj->module).
"'";
174 $db->query($sqlupdate);
180 foreach ($modules[$obj->module]->rights as $key => $val)
182 if ($val[4] == $obj->perms && (empty($val[5]) || $val[5] == $obj->subperms))
195 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>';
213 if ($user->admin)
print '<td class="right"></td>';
217 $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) : $obj->label));
219 print '<tr class="oddeven">';
222 print '<td class="maxwidthonsmartphone tdoverflowonsmartphone">';
226 if ($obj->bydefault == 1)
228 print '<td class="center">';
229 print '<a class="reposition" href="perms.php?pid='.$obj->id.
'&action=remove">';
234 print '<td class="center">';
238 print '<td class="center">';
239 print '<a class="reposition" href="perms.php?pid='.$obj->id.
'&action=add">';
244 print '<td class="center">';
250 print '<td>'.$perm_libelle.
'</td>';
253 if ($user->admin)
print '<td class="right"><span class="opacitymedium">'.$obj->id.
'</span></td>';
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dolGetModulesDirs($subdir= '')
Return list of modules directories.
showModulesExludedForExternal($modules)
Show array with constants to edit.
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save"&&empty($cancel)) $wikihelp
View.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
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)
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
security_prepare_head()
Prepare array with list of tabs.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.