Skip to content

Commit d91b69a

Browse files
committed
fix: associazione permessi a gruppi utente
1 parent e2d8f3d commit d91b69a

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/Models/Group.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,17 @@ public function syncModulePermissions($id_module, $permessi)
110110
}
111111
}
112112

113-
// Se non ci sono viste predefinite, aggiungi il gruppo ad almeno una vista (la prima disponibile)
113+
// Se non ci sono viste predefinite, aggiungi il gruppo a tutte le viste del modulo
114114
if (empty($default_views)) {
115-
$first_view = $database->fetchArray('SELECT `id` FROM `zz_views` WHERE `id_module`='.prepare($id_module).' ORDER BY `order` ASC LIMIT 1');
115+
$all_views = $database->fetchArray('SELECT `id` FROM `zz_views` WHERE `id_module`='.prepare($id_module).' ORDER BY `order` ASC');
116116

117-
if (!empty($first_view)) {
118-
$has_view_access = $database->fetchArray('SELECT COUNT(*) as cont FROM `zz_group_view` WHERE `id_gruppo` = '.prepare($this->id).' AND `id_vista` = '.prepare($first_view[0]['id']))['cont'];
117+
foreach ($all_views as $view) {
118+
$has_view_access = $database->fetchArray('SELECT COUNT(*) as cont FROM `zz_group_view` WHERE `id_gruppo` = '.prepare($this->id).' AND `id_vista` = '.prepare($view['id']))['cont'];
119119

120120
if ($has_view_access == 0) {
121121
$database->insert('zz_group_view', [
122122
'id_gruppo' => $this->id,
123-
'id_vista' => $first_view[0]['id'],
123+
'id_vista' => $view['id'],
124124
]);
125125
}
126126
}

0 commit comments

Comments
 (0)