From 92d3d3a967df00cbc6b9c054305661b66c9a21e0 Mon Sep 17 00:00:00 2001 From: Luca Date: Mon, 20 Feb 2023 19:01:24 +0100 Subject: [PATCH] Avviso utenti abilitati per la check --- actions.php | 26 +++++++++----------------- lib/util.php | 8 +++++--- modules/checklists/modutil.php | 6 ++++++ 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/actions.php b/actions.php index 178d5d1d6..2325cfd3f 100755 --- a/actions.php +++ b/actions.php @@ -258,15 +258,11 @@ elseif (filter('op') == 'rimuovi-nota') { elseif (filter('op') == 'copia-checklist') { $content = post('content'); $checklist_id = post('checklist'); - - if (!empty(post('assigned_users'))){ - $users = post('assigned_users'); - $users = array_clean($users); - } - - if (!empty(post('group_id'))){ - $group_id = post('group_id'); - } + + $users = post('assigned_users'); + $users = array_clean($users); + + $group_id = post('group_id'); $checklist = Checklist::find($checklist_id); $checklist->copia($user, $id_record, $users, $group_id); @@ -277,14 +273,10 @@ elseif (filter('op') == 'aggiungi-check') { $content = post('content'); $parent_id = post('parent') ?: null; - if (!empty(post('assigned_users'))){ - $users = post('assigned_users'); - $users = array_clean($users); - } - - if (!empty(post('group_id'))){ - $group_id = post('group_id'); - } + $users = post('assigned_users'); + $users = array_clean($users); + + $group_id = post('group_id'); $check = Check::build($user, $structure, $id_record, $content, $parent_id); $check->setAccess($users, $group_id); diff --git a/lib/util.php b/lib/util.php index 0ed471c86..72a290903 100755 --- a/lib/util.php +++ b/lib/util.php @@ -56,9 +56,11 @@ if (!function_exists('array_clean')) { */ function array_clean($array) { - return array_unique(array_values(array_filter($array, function ($value) { - return !empty($value); - }))); + if (!empty($array)){ + return array_unique(array_values(array_filter($array, function ($value) { + return !empty($value); + }))); + } } } diff --git a/modules/checklists/modutil.php b/modules/checklists/modutil.php index 2b8a028b5..deb748846 100755 --- a/modules/checklists/modutil.php +++ b/modules/checklists/modutil.php @@ -28,6 +28,12 @@ function renderChecklist($check, $level = 0) '.$check->content.''; + if (intval($check->assignedUsers->pluck('id')->toArray())>0){ + $result .= ''. implode(',', $check->assignedUsers->pluck('username')->toArray()).''; + }else{ + $result .= ''. tr('Nessun utente asseganto').''; + } + if (empty($check->user) || $check->user->id == $user->id) { $result .= '