2017-08-04 16:28:16 +02:00
|
|
|
<?php
|
2020-09-07 15:04:06 +02:00
|
|
|
/*
|
|
|
|
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
|
|
|
* Copyright (C) DevCode s.n.c.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
include_once __DIR__.'/../../core.php';
|
|
|
|
|
2018-03-02 19:01:30 +01:00
|
|
|
function menuSelection($element, $group_id, $depth, $perms_values, $perms_names)
|
2017-08-04 16:28:16 +02:00
|
|
|
{
|
2018-09-20 12:05:22 +02:00
|
|
|
$dbo = database();
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
++$depth;
|
|
|
|
$name = $element['title'];
|
|
|
|
|
2018-08-10 17:14:09 +02:00
|
|
|
$submenus = $element['all_children'];
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2018-07-02 09:55:16 +02:00
|
|
|
if (!empty($submenus)) {
|
2017-08-04 16:28:16 +02:00
|
|
|
$temp = '';
|
|
|
|
foreach ($submenus as $submenu) {
|
2018-03-02 19:01:30 +01:00
|
|
|
$temp .= menuSelection($submenu, $group_id, $depth, $perms_values, $perms_names);
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
|
|
|
}
|
2018-03-02 19:01:30 +01:00
|
|
|
|
2017-08-04 16:28:16 +02:00
|
|
|
$result .= '
|
|
|
|
<tr>
|
|
|
|
<td>'.str_repeat(' ', $depth).$name.'</td>
|
|
|
|
<td>
|
|
|
|
<select name="permesso" class="form-control superselect" onchange="update_permissions('.$element['id'].', $(this).find(\'option:selected\').val())">';
|
|
|
|
// Permessi
|
2018-03-02 19:01:30 +01:00
|
|
|
$rsp = $dbo->fetchArray('SELECT permessi FROM zz_permissions WHERE idgruppo='.prepare($group_id).' AND idmodule='.prepare($element['id']));
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
if (count($rsp) == 0) {
|
|
|
|
$permessi = '-';
|
|
|
|
} else {
|
|
|
|
$permessi = $rsp[0]['permessi'];
|
|
|
|
}
|
|
|
|
|
|
|
|
for ($i = 0; $i < count($perms_values); ++$i) {
|
|
|
|
$attr = ($perms_values[$i] == $permessi) ? ' selected="selected"' : '';
|
|
|
|
$result .= '
|
|
|
|
<option value="'.$perms_values[$i].'" '.$attr.'>'.$perms_names[$i].'</option>';
|
|
|
|
}
|
|
|
|
$result .= '
|
|
|
|
</select>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
'.$temp;
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|