mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-08 23:58:42 +01:00
Correzioni minori su permessi
This commit is contained in:
parent
b7316eb837
commit
16be9980a7
@ -92,7 +92,7 @@ if (!empty($utenti)) {
|
|||||||
|
|
||||||
// Disabilitazione token API, se diverso da id_utente #1 (admin)
|
// Disabilitazione token API, se diverso da id_utente #1 (admin)
|
||||||
$token = $dbo->fetchOne('SELECT `enabled` FROM `zz_tokens` WHERE `id_utente` = '.prepare($utente['id']).'')['enabled'];
|
$token = $dbo->fetchOne('SELECT `enabled` FROM `zz_tokens` WHERE `id_utente` = '.prepare($utente['id']).'')['enabled'];
|
||||||
|
|
||||||
if ($utente['id'] == '1') {
|
if ($utente['id'] == '1') {
|
||||||
echo '
|
echo '
|
||||||
<div data-toggle="tooltip" class="tip" title="'.tr("Non è possibile gestire l'accesso API per l'utente admin").'" ><span class="btn btn-xs btn-default disabled">
|
<div data-toggle="tooltip" class="tip" title="'.tr("Non è possibile gestire l'accesso API per l'utente admin").'" ><span class="btn btn-xs btn-default disabled">
|
||||||
@ -170,14 +170,14 @@ if ($record['nome'] != 'Amministratori') {
|
|||||||
|
|
||||||
$moduli = Modules::getHierarchy();
|
$moduli = Modules::getHierarchy();
|
||||||
|
|
||||||
$permissions = [
|
$permessi_disponibili = [
|
||||||
'-' => tr('Nessun permesso'),
|
'-' => tr('Nessun permesso'),
|
||||||
'r' => tr('Sola lettura'),
|
'r' => tr('Sola lettura'),
|
||||||
'rw' => tr('Lettura e scrittura'),
|
'rw' => tr('Lettura e scrittura'),
|
||||||
];
|
];
|
||||||
|
|
||||||
for ($m = 0; $m < count($moduli); ++$m) {
|
for ($m = 0; $m < count($moduli); ++$m) {
|
||||||
echo menuSelection($moduli[$m], $id_record, -1, array_keys($permissions), array_values($permissions));
|
echo menuSelection($moduli[$m], $id_record, -1, $permessi_disponibili);
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
|
@ -19,46 +19,38 @@
|
|||||||
|
|
||||||
include_once __DIR__.'/../../core.php';
|
include_once __DIR__.'/../../core.php';
|
||||||
|
|
||||||
function menuSelection($element, $group_id, $depth, $perms_values, $perms_names)
|
function menuSelection($element, $group_id, $depth, $permessi_disponibili)
|
||||||
{
|
{
|
||||||
$dbo = database();
|
$dbo = database();
|
||||||
|
|
||||||
++$depth;
|
++$depth;
|
||||||
$name = $element['title'];
|
|
||||||
|
|
||||||
$submenus = $element['all_children'];
|
$result = '
|
||||||
|
|
||||||
if (!empty($submenus)) {
|
|
||||||
$temp = '';
|
|
||||||
foreach ($submenus as $submenu) {
|
|
||||||
$temp .= menuSelection($submenu, $group_id, $depth, $perms_values, $perms_names);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$result .= '
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>'.str_repeat(' ', $depth).$name.'</td>
|
<td>'.str_repeat(' ', $depth).$element['title'].'</td>
|
||||||
<td>
|
<td>
|
||||||
<select name="permesso_'.$element['id'].'" id="permesso_'.$element['id'].'" class="form-control superselect openstamanager-input select-input" onchange="update_permissions('.$element['id'].', $(this).find(\'option:selected\').val())">';
|
<select name="permesso_'.$element['id'].'" id="permesso_'.$element['id'].'" class="form-control superselect openstamanager-input select-input" onchange="update_permissions('.$element['id'].', $(this).find(\'option:selected\').val())">';
|
||||||
// Permessi
|
|
||||||
$rsp = $dbo->fetchArray('SELECT permessi FROM zz_permissions WHERE idgruppo='.prepare($group_id).' AND idmodule='.prepare($element['id']));
|
|
||||||
|
|
||||||
if (count($rsp) == 0) {
|
// Permessi impostati per il gruppo
|
||||||
$permessi = '-';
|
$permesso_salvato = $dbo->fetchOne('SELECT permessi FROM zz_permissions WHERE idgruppo = '.prepare($group_id).' AND idmodule = '.prepare($element['id']));
|
||||||
} else {
|
$permessi = $permesso_salvato ? $permesso_salvato['permessi'] : '-';
|
||||||
$permessi = $rsp[0]['permessi'];
|
foreach ($permessi_disponibili as $id => $nome){
|
||||||
}
|
$attr = ($id == $permessi) ? ' selected="selected"' : '';
|
||||||
|
|
||||||
for ($i = 0; $i < count($perms_values); ++$i) {
|
|
||||||
$attr = ($perms_values[$i] == $permessi) ? ' selected="selected"' : '';
|
|
||||||
$result .= '
|
$result .= '
|
||||||
<option value="'.$perms_values[$i].'" '.$attr.'>'.$perms_names[$i].'</option>';
|
<option value="'.$id.'" '.$attr.'>'.$nome.'</option>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$result .= '
|
$result .= '
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>';
|
||||||
'.$temp;
|
|
||||||
|
$submenus = $element['all_children'];
|
||||||
|
if (!empty($submenus)) {
|
||||||
|
foreach ($submenus as $submenu) {
|
||||||
|
$result .= menuSelection($submenu, $group_id, $depth, $permessi_disponibili, $perms_names);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user