From 079d9ca3d5ccf3f11378a6b2a45771bde5f3b9fa Mon Sep 17 00:00:00 2001 From: fusionate Date: Fri, 2 Jun 2023 23:54:00 +0000 Subject: [PATCH] Contacts: Updates for PHP 8.1 --- app/contacts/contact_address_edit.php | 8 +- app/contacts/contact_attachment_edit.php | 6 +- app/contacts/contact_edit.php | 230 +++++++++++--------- app/contacts/contact_email_edit.php | 6 +- app/contacts/contact_phone_edit.php | 10 +- app/contacts/contact_phones_view.php | 6 +- app/contacts/contact_relation_edit.php | 4 +- app/contacts/contact_view.php | 2 +- app/contacts/contacts.php | 8 +- app/contacts/contacts_vcard.php | 12 +- app/contacts/resources/classes/contacts.php | 8 +- 11 files changed, 160 insertions(+), 140 deletions(-) diff --git a/app/contacts/contact_address_edit.php b/app/contacts/contact_address_edit.php index 89789d8fca..4740cc804b 100644 --- a/app/contacts/contact_address_edit.php +++ b/app/contacts/contact_address_edit.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2018 + Portions created by the Initial Developer are Copyright (C) 2008-2023 the Initial Developer. All Rights Reserved. Contributor(s): @@ -336,7 +336,7 @@ 'pref' => $text['option-pref'] ); foreach ($vcard_address_types as $vcard_address_type_value => $vcard_address_type_label) { - echo " \n"; + echo " \n"; } echo " \n"; echo "
\n"; @@ -440,7 +440,7 @@ echo "\n"; echo " \n"; echo "
\n"; echo $text['description-address_primary']."\n"; @@ -472,4 +472,4 @@ //include the footer require_once "resources/footer.php"; -?> +?> \ No newline at end of file diff --git a/app/contacts/contact_attachment_edit.php b/app/contacts/contact_attachment_edit.php index 159f228437..5c22fb2df3 100644 --- a/app/contacts/contact_attachment_edit.php +++ b/app/contacts/contact_attachment_edit.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2018 + Portions created by the Initial Developer are Copyright (C) 2008-2023 the Initial Developer. All Rights Reserved. Contributor(s): @@ -216,7 +216,7 @@ echo "\n"; echo " \n"; echo "\n"; echo "\n"; @@ -244,4 +244,4 @@ //include the footer require_once "resources/footer.php"; -?> +?> \ No newline at end of file diff --git a/app/contacts/contact_edit.php b/app/contacts/contact_edit.php index 8e96c739fd..80c9ac7101 100644 --- a/app/contacts/contact_edit.php +++ b/app/contacts/contact_edit.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2018 - 2022 + Portions created by the Initial Developer are Copyright (C) 2018 - 2023 the Initial Developer. All Rights Reserved. */ @@ -88,13 +88,13 @@ $contact_time_zone = $_POST["contact_time_zone"]; $contact_note = $_POST["contact_note"]; - $last_mod_date = $_POST["last_mod_date"]; - $last_mod_user = $_POST["last_mod_user"]; + $last_mod_date = $_POST["last_mod_date"] ?? null; + $last_mod_user = $_POST["last_mod_user"] ?? null; //$contact_users = $_POST["contact_users"]; //$contact_groups = $_POST["contact_groups"]; - $contact_user_uuid = $_POST["contact_user_uuid"]; - $contact_group_uuid = $_POST["contact_group_uuid"]; + $contact_user_uuid = $_POST["contact_user_uuid"] ?? null; + $contact_group_uuid = $_POST["contact_group_uuid"] ?? null; $contact_phones = $_POST["contact_phones"]; $contact_addresses = $_POST["contact_addresses"]; @@ -102,9 +102,9 @@ $contact_urls = $_POST["contact_urls"]; $contact_relations = $_POST["contact_relations"]; $contact_settings = $_POST["contact_settings"]; - $contact_attachments = $_POST["contact_attachments"]; - $contact_times = $_POST["contact_times"]; - $contact_notes = $_POST["contact_notes"]; + $contact_attachments = $_POST["contact_attachments"] ?? null; + $contact_times = $_POST["contact_times"] ?? null; + $contact_notes = $_POST["contact_notes"] ?? null; } //process the user data and save it to the database @@ -126,124 +126,148 @@ //prepare the array(s) $x = 0; - foreach ($_POST['contact_users'] as $row) { - if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && $row['checked'] === 'true') { - $array['contacts'][$x]['checked'] = $row['checked']; - $array['contacts'][$x]['contact_users'][]['contact_user_uuid'] = $row['contact_user_uuid']; - $x++; + if (!empty($_POST['contact_users']) && is_array($_POST['contact_users']) && @sizeof($_POST['contact_users']) != 0) { + foreach ($_POST['contact_users'] as $row) { + if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && !empty($row['checked']) && $row['checked'] === 'true') { + $array['contacts'][$x]['checked'] = $row['checked']; + $array['contacts'][$x]['contact_users'][]['contact_user_uuid'] = $row['contact_user_uuid']; + $x++; + } } } $x = 0; - foreach ($_POST['contact_groups'] as $row) { - if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && $row['checked'] === 'true') { - $array['contacts'][$x]['checked'] = $row['checked']; - $array['contacts'][$x]['contact_groups'][]['contact_group_uuid'] = $row['contact_group_uuid']; - $x++; + if (!empty($_POST['contact_groups']) && is_array($_POST['contact_groups']) && @sizeof($_POST['contact_groups']) != 0) { + foreach ($_POST['contact_groups'] as $row) { + if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && !empty($row['checked']) && $row['checked'] === 'true') { + $array['contacts'][$x]['checked'] = $row['checked']; + $array['contacts'][$x]['contact_groups'][]['contact_group_uuid'] = $row['contact_group_uuid']; + $x++; + } } } $x = 0; - foreach ($_POST['contact_phones'] as $row) { - if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && $row['checked'] === 'true') { - $array['contacts'][$x]['checked'] = $row['checked']; - $array['contacts'][$x]['contact_phones'][]['contact_phone_uuid'] = $row['contact_phone_uuid']; - $x++; + if (!empty($_POST['contact_phones']) && is_array($_POST['contact_phones']) && @sizeof($_POST['contact_phones']) != 0) { + foreach ($_POST['contact_phones'] as $row) { + if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && !empty($row['checked']) && $row['checked'] === 'true') { + $array['contacts'][$x]['checked'] = $row['checked']; + $array['contacts'][$x]['contact_phones'][]['contact_phone_uuid'] = $row['contact_phone_uuid']; + $x++; + } } } $x = 0; - foreach ($_POST['contact_addresses'] as $row) { - if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && $row['checked'] === 'true') { - $array['contacts'][$x]['checked'] = $row['checked']; - $array['contacts'][$x]['contact_addresses'][]['contact_address_uuid'] = $row['contact_address_uuid']; - $x++; + if (!empty($_POST['contact_addresses']) && is_array($_POST['contact_addresses']) && @sizeof($_POST['contact_addresses']) != 0) { + foreach ($_POST['contact_addresses'] as $row) { + if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && !empty($row['checked']) && $row['checked'] === 'true') { + $array['contacts'][$x]['checked'] = $row['checked']; + $array['contacts'][$x]['contact_addresses'][]['contact_address_uuid'] = $row['contact_address_uuid']; + $x++; + } } } $x = 0; - foreach ($_POST['contact_emails'] as $row) { - if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && $row['checked'] === 'true') { - $array['contacts'][$x]['checked'] = $row['checked']; - $array['contacts'][$x]['contact_emails'][]['contact_email_uuid'] = $row['contact_email_uuid']; - $x++; + if (!empty($_POST['contact_emails']) && is_array($_POST['contact_emails']) && @sizeof($_POST['contact_emails']) != 0) { + foreach ($_POST['contact_emails'] as $row) { + if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && !empty($row['checked']) && $row['checked'] === 'true') { + $array['contacts'][$x]['checked'] = $row['checked']; + $array['contacts'][$x]['contact_emails'][]['contact_email_uuid'] = $row['contact_email_uuid']; + $x++; + } } } $x = 0; - foreach ($_POST['contact_urls'] as $row) { - if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && $row['checked'] === 'true') { - $array['contacts'][$x]['checked'] = $row['checked']; - $array['contacts'][$x]['contact_urls'][]['contact_url_uuid'] = $row['contact_url_uuid']; - $x++; + if (!empty($_POST['contact_urls']) && is_array($_POST['contact_urls']) && @sizeof($_POST['contact_urls']) != 0) { + foreach ($_POST['contact_urls'] as $row) { + if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && !empty($row['checked']) && $row['checked'] === 'true') { + $array['contacts'][$x]['checked'] = $row['checked']; + $array['contacts'][$x]['contact_urls'][]['contact_url_uuid'] = $row['contact_url_uuid']; + $x++; + } } } $x = 0; - foreach ($_POST['contact_relations'] as $row) { - if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && $row['checked'] === 'true') { - $array['contacts'][$x]['checked'] = $row['checked']; - $array['contacts'][$x]['contact_relations'][]['contact_relation_uuid'] = $row['contact_relation_uuid']; - $x++; + if (!empty($_POST['contact_relations']) && is_array($_POST['contact_relations']) && @sizeof($_POST['contact_relations']) != 0) { + foreach ($_POST['contact_relations'] as $row) { + if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && !empty($row['checked']) && $row['checked'] === 'true') { + $array['contacts'][$x]['checked'] = $row['checked']; + $array['contacts'][$x]['contact_relations'][]['contact_relation_uuid'] = $row['contact_relation_uuid']; + $x++; + } } } $x = 0; - foreach ($_POST['contact_settings'] as $row) { - if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && $row['checked'] === 'true') { - $array['contacts'][$x]['checked'] = $row['checked']; - $array['contacts'][$x]['contact_settings'][]['contact_setting_uuid'] = $row['contact_setting_uuid']; - $x++; + if (!empty($_POST['contact_settings']) && is_array($_POST['contact_settings']) && @sizeof($_POST['contact_settings']) != 0) { + foreach ($_POST['contact_settings'] as $row) { + if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && !empty($row['checked']) && $row['checked'] === 'true') { + $array['contacts'][$x]['checked'] = $row['checked']; + $array['contacts'][$x]['contact_settings'][]['contact_setting_uuid'] = $row['contact_setting_uuid']; + $x++; + } } } $x = 0; - foreach ($_POST['contact_attachments'] as $row) { - if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && $row['checked'] === 'true') { - $array['contacts'][$x]['checked'] = $row['checked']; - $array['contacts'][$x]['contact_attachments'][]['contact_attachment_uuid'] = $row['contact_attachment_uuid']; - $x++; + if (!empty($_POST['contact_attachments']) && is_array($_POST['contact_attachments']) && @sizeof($_POST['contact_attachments']) != 0) { + foreach ($_POST['contact_attachments'] as $row) { + if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && !empty($row['checked']) && $row['checked'] === 'true') { + $array['contacts'][$x]['checked'] = $row['checked']; + $array['contacts'][$x]['contact_attachments'][]['contact_attachment_uuid'] = $row['contact_attachment_uuid']; + $x++; + } } } $x = 0; - foreach ($_POST['contact_times'] as $row) { - if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && $row['checked'] === 'true') { - $array['contacts'][$x]['checked'] = $row['checked']; - $array['contacts'][$x]['contact_times'][]['contact_time_uuid'] = $row['contact_time_uuid']; - $x++; + if (!empty($_POST['contact_times']) && is_array($_POST['contact_times']) && @sizeof($_POST['contact_times']) != 0) { + foreach ($_POST['contact_times'] as $row) { + if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && !empty($row['checked']) && $row['checked'] === 'true') { + $array['contacts'][$x]['checked'] = $row['checked']; + $array['contacts'][$x]['contact_times'][]['contact_time_uuid'] = $row['contact_time_uuid']; + $x++; + } } } $x = 0; - foreach ($_POST['contact_notes'] as $row) { - if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && $row['checked'] === 'true') { - $array['contacts'][$x]['checked'] = $row['checked']; - $array['contacts'][$x]['contact_notes'][]['contact_note_uuid'] = $row['contact_note_uuid']; - $x++; + if (!empty($_POST['contact_notes']) && is_array($_POST['contact_notes']) && @sizeof($_POST['contact_notes']) != 0) { + foreach ($_POST['contact_notes'] as $row) { + if (!empty($row['contact_uuid']) && is_uuid($row['contact_uuid']) && !empty($row['checked']) && $row['checked'] === 'true') { + $array['contacts'][$x]['checked'] = $row['checked']; + $array['contacts'][$x]['contact_notes'][]['contact_note_uuid'] = $row['contact_note_uuid']; + $x++; + } } } //send the array to the database class - switch ($_POST['action']) { - case 'copy': - if (permission_exists('contact_add')) { - $obj = new database; - $obj->copy($array); - } - break; - case 'delete': - if (permission_exists('contact_delete')) { - $obj = new database; - $obj->delete($array); - } - break; - case 'toggle': - if (permission_exists('contact_update')) { - $obj = new database; - $obj->toggle($array); - } - break; + if (!empty($array)) { + switch ($_POST['action']) { + case 'copy': + if (permission_exists('contact_add')) { + $obj = new database; + $obj->copy($array); + } + break; + case 'delete': + if (permission_exists('contact_delete')) { + $obj = new database; + $obj->delete($array); + } + break; + case 'toggle': + if (permission_exists('contact_update')) { + $obj = new database; + $obj->toggle($array); + } + break; + } } //redirect the user @@ -1317,17 +1341,17 @@ if (!empty($_SESSION["contact"]["type"])) { else { echo " \n"; } echo " \n"; @@ -1419,12 +1443,7 @@ foreach ($time_zone_identifiers as $key => $val) { $time_zone_offset_hours = "-".number_pad($time_zone_offset_hours, 2); } } - if ($val == $contact_time_zone) { - echo " \n"; - } - else { - echo " \n"; - } + echo " \n"; $previous_category = $category; $x++; } @@ -1609,7 +1628,7 @@ if (permission_exists('contact_phone_view')) { echo " \n"; } echo "