From e6f075c62f9a012ef817058cc48b929098e4a803 Mon Sep 17 00:00:00 2001 From: Thomas Zilio Date: Mon, 2 Jul 2018 09:55:16 +0200 Subject: [PATCH] Bugfix --- locale/catalog.pot | 2 +- modules/utenti/actions.php | 11 ++++- modules/utenti/edit.php | 44 ++++++++++++++----- modules/utenti/modutil.php | 4 +- .../pdfgen.interventi_ordiniservizio.php | 8 ++-- update/2_4.sql | 2 +- 6 files changed, 50 insertions(+), 21 deletions(-) diff --git a/locale/catalog.pot b/locale/catalog.pot index 10ab6029f..a7768c230 100644 --- a/locale/catalog.pot +++ b/locale/catalog.pot @@ -5692,7 +5692,7 @@ msgstr "" #: modules/utenti/edit.php:56 modules/utenti/edit.php:59 #: modules/utenti/edit.php:74 -msgid "Sì" +msgid "Sì" msgstr "" #: modules/utenti/edit.php:59 diff --git a/modules/utenti/actions.php b/modules/utenti/actions.php index 0647a6cfa..ec71ef0d5 100644 --- a/modules/utenti/actions.php +++ b/modules/utenti/actions.php @@ -120,12 +120,21 @@ switch (filter('op')) { break; // Elimina utente - case 'delete': + case 'delete': if ($dbo->query('DELETE FROM zz_users WHERE id='.prepare($id_utente))) { $_SESSION['infos'][] = tr('Utente eliminato!'); } break; + // Disabilita API utente + case 'token': + $token = $dbo->fetchOne('SELECT `enabled` FROM `zz_tokens` WHERE `id_utente` = '.prepare($id_record)); + + if ($dbo->query('UPDATE zz_tokens SET enabled = '.(empty($token['enabled']) ? 1 : 0).' WHERE id_utente = '.prepare($id_utente))) { + $_SESSION['infos'][] = tr('Utente eliminato!'); + } + break; + // Elimina gruppo case 'deletegroup': // Verifico se questo gruppo si può eliminare diff --git a/modules/utenti/edit.php b/modules/utenti/edit.php index 3ea0c1749..6afc9c6e8 100644 --- a/modules/utenti/edit.php +++ b/modules/utenti/edit.php @@ -4,8 +4,6 @@ include_once __DIR__.'/../../core.php'; $record = $records[0]; -$moduli = $dbo->fetchArray('SELECT * FROM zz_modules WHERE parent IS NULL ORDER BY `order` ASC'); - $utenti = $dbo->fetchArray('SELECT *, (SELECT ragione_sociale FROM an_anagrafiche INNER JOIN an_tipianagrafiche_anagrafiche ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica WHERE an_anagrafiche.idanagrafica=zz_users.idanagrafica AND an_tipianagrafiche_anagrafiche.idtipoanagrafica=zz_users.idtipoanagrafica) AS ragione_sociale, (SELECT descrizione FROM an_tipianagrafiche INNER JOIN an_tipianagrafiche_anagrafiche ON an_tipianagrafiche.idtipoanagrafica=an_tipianagrafiche_anagrafiche.idtipoanagrafica WHERE idanagrafica=zz_users.idanagrafica AND an_tipianagrafiche.idtipoanagrafica=zz_users.idtipoanagrafica) AS tipo FROM zz_users WHERE idgruppo='.prepare($record['id'])); echo ' @@ -53,10 +51,10 @@ if (!empty($utenti)) { if ($utente['id'] != '1') { if ($utente['enabled'] == 1) { echo ' - '; + '; } else { echo ' - '; + '; } } else { echo ' @@ -65,15 +63,31 @@ if (!empty($utenti)) { // Cambio password e nome utente echo ' - '; + '; + + // Disabilitazione token API, se diverso da id_utente #1 (admin) + if ($utente['id'] != '1') { + $token = $dbo->fetchOne('SELECT `enabled` FROM `zz_tokens` WHERE `id_utente` = '.prepare($utente['id'])); + + if (!empty($token['enabled'])) { + echo ' + '; + } else { + echo ' + '; + } + } else { + echo ' + '; + } // Eliminazione utente, se diverso da id_utente #1 (admin) if ($utente['id'] != '1') { echo ' - '; + '; } else { echo ' - '; + '; } echo ' @@ -111,12 +125,18 @@ if ($record['nome'] != 'Amministratori') { '.tr('Modulo').' '.tr('Permessi').' - '; - for ($m = 0; $m < count($moduli); ++$m) { - $perms_values = ['-', 'r', 'rw']; - $perms_names = [tr('Nessun permesso'), tr('Sola lettura'), tr('Lettura e scrittura')]; + '; - echo menuSelection($moduli[$m], $id_record, -1, $perms_values, $perms_names); + $moduli = Modules::getHierarchy(); + + $permissions = [ + '-' => tr('Nessun permesso'), + 'r' => tr('Sola lettura'), + 'rw' => tr('Lettura e scrittura'), + ]; + + for ($m = 0; $m < count($moduli); ++$m) { + echo menuSelection($moduli[$m], $id_record, -1, array_keys($permissions), array_values($permissions)); } echo ' diff --git a/modules/utenti/modutil.php b/modules/utenti/modutil.php index c7ae4fef7..671d5744d 100644 --- a/modules/utenti/modutil.php +++ b/modules/utenti/modutil.php @@ -9,9 +9,9 @@ function menuSelection($element, $group_id, $depth, $perms_values, $perms_names) ++$depth; $name = $element['title']; - $submenus = $dbo->fetchArray("SELECT * FROM zz_modules WHERE enabled='1' AND parent=".prepare($element['id']).' ORDER BY `order` ASC'); + $submenus = $element['children']; - if ($submenus != null && count($submenus) != 0) { + if (!empty($submenus)) { $temp = ''; foreach ($submenus as $submenu) { $temp .= menuSelection($submenu, $group_id, $depth, $perms_values, $perms_names); diff --git a/templates/interventi_ordiniservizio/pdfgen.interventi_ordiniservizio.php b/templates/interventi_ordiniservizio/pdfgen.interventi_ordiniservizio.php index 4ab8d28db..70f80bde0 100644 --- a/templates/interventi_ordiniservizio/pdfgen.interventi_ordiniservizio.php +++ b/templates/interventi_ordiniservizio/pdfgen.interventi_ordiniservizio.php @@ -156,7 +156,7 @@ $body .= "