1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-29 09:11:11 +01:00
openstamanager/modules/utenti/modutil.php

48 lines
1.5 KiB
PHP
Raw Normal View History

<?php
include_once __DIR__.'/../../core.php';
2018-03-02 19:01:30 +01:00
function menuSelection($element, $group_id, $depth, $perms_values, $perms_names)
{
$dbo = Database::getConnection();
++$depth;
$name = $element['title'];
2018-02-18 19:53:23 +01:00
$submenus = $dbo->fetchArray("SELECT * FROM zz_modules WHERE enabled='1' AND parent=".prepare($element['id']).' ORDER BY `order` ASC');
if ($submenus != null && count($submenus) != 0) {
$temp = '';
foreach ($submenus as $submenu) {
2018-03-02 19:01:30 +01:00
$temp .= menuSelection($submenu, $group_id, $depth, $perms_values, $perms_names);
}
}
2018-03-02 19:01:30 +01:00
$result .= '
<tr>
<td>'.str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', $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']));
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;
}