Files
fusionpbx/core/contacts/contacts_vcard.php
FusionPBX 7f9064fadb Update boolean toggle and the database boolean type (#7522)
* Change the data type to boolean

* Use boolean values in SQL and Conditional Statements

* Schema Data Types: Drop views so that alter tables statements complete

* Update settings.php

* Add extension for call_screen_enabled

* Gateway handle boolean
Add the boolean toggle
- distinct_to
- caller_id_in_from
- supress_cng
- extension_in_contact
- contact_in_ping

* Update gateways.php

* Update voicemail_edit.php

* Replace the ${caller_id_name} with the extensions caller id name

* Phrase - Edit: Update slide toggle with new select beneath.

* Update the input toggle style

* Set the input_toggle_style_switch as boolean

* Update the input toggle style

* Theme: Adjust CSS to wrap description text on form fields.

* Add domain_uuid and domain_name to the SQL SELECT

* Unset the parameters to fix the next query

* Gateway: Integrate new slide toggle switch.

* Dashboard: Update the input toggle style (#7499)

* Dashboard: Update the input toggle style

* Update dashboard_widget_edit.php

* Update dashboard_edit.php

* Inbound Route - Add: Integrate new slide toggle switch and boolean.

* User Settings: Integrate new slide toggle switch.

* Call Block Edit: Update the input toggle style (#7500)

* Bridge Edit: Update the input toggle style (#7501)

* Update phrases.php

* Update domain_edit.php

* Domain Settings Edit: Update the input toggle style

* User Edit: Update the input toggle style

* Update install.php

* Remove fields marked as deprecated

* Use boolean in the select statement

* Streams: New slide toggle and boolean.

* Streams: Remove unnecessary default.

* Queues (FIFO): New slide toggle.

* Call Detail Records: Update the input toggle style (#7503)

* Call Detail Records: Update the input toggle style

* Update xml_cdr_extension_summary.php

* Update xml_cdr_extension_summary.php

* Update xml_cdr_extension_summary.php

* Call Centers: Update the input toggle style (#7502)

* Call Centers: Update the input toggle style

* Update call_center_agent_edit.php

* Conference Centers: Update the input toggle style (#7506)

* Conference Centers: Update the input toggle style

* Update app_config.php

* Update conference_center_edit.php

* Use boolean data type (#7505)

* Call Flow Edit: Update the input toggle style (#7504)

* Devices: Update the input toggle style

* IVR Menus: New slide toggle.

* IVR Menu: Remove deprected file.

* SIP Profile - Edit: New slide toggle.

* Device Profiles: Update the input toggle style

* Ring Groups - List: Fix syntax.

* Theme: Fire onchange event when switching slide toggle control.

* Device Vendors: Update the input toggle style

* Update enabled boolean

* Update device_edit.php

* Ring Groups: New slide toggle.

* Update domain_edit.php

* Email Templates: Update the input toggle style

* Header: Correct default value on input toggle style.

* Default/Domain/User Settings: Adjust Select option label for better clarity.

* Use true boolean types for switch theme toggle or drop-down box (#7507)

* Groups: Update the input toggle style

* Conference Controls: Update the input toggle style (#7509)

* Conference Controls: Update the input toggle style

* Update conference_control_edit.php

* Update conference_control_details.php

* Update conference_control_detail_edit.php

* Conferences: Update the input toggle style (#7511)

* Use true boolean types for switch theme toggle or drop-down box (#7513)

* Dialplans: Update the input toggle style
Also updated outbound route add

* Ring Group: Only adjust ring group forward destination top margin when slide toggle enabled.

* Default/Domain/User Settings - List: Adjust for new 'Select Box' label on input_toggle_style value.

* Use true boolean types for switch theme toggle or drop-down box (#7514)

* Call Forward / Follow Me: Minor javascript adjustments to mirror previous behavior.

* Ring Groups [Dashboard]: New slide toggle.

* Get the contacts details with a seperate SQL Query

* Remove debug info

* Destinations: Update the input toggle style

* Conference Profiles: Update the input toggle style (#7515)

* Conference Profiles: Update the input toggle style

* Update conference_profiles.php

* Update conference_profile_params.php

* Update conference_profile_param_edit.php

* Update conference_profile_edit.php

* Extensions: Update the input toggle style

* Contacts: Update the input toggle style (#7517)

* Contacts: Update the input toggle style

* Update contact_address_edit.php

* Update contact_attachment_edit.php

* Update contact_edit.php

* Update contact_email_edit.php

* Update contact_phone_edit.php

* Update contact_relation_edit.php

* Update contact_setting_edit.php

* Update contact_url_edit.php

* Update contacts.php

* Voicemails: New slide toggle.

* Voicemail Greeting: New slide toggle.

* Modules: New slide toggle.

* Recordings: New slide toggle

* Variables: New slide toggle.

* Time Conditions: New slide toggle.

* Extensions - List: Remove invalid column name.

* Extension Settings: New slide toggle.

* Number Translations: New slide toggle and boolean.

* Sofia global settings: Update the input toggle style

* Update alter table convert to boolean

* Fix contact relation search (#7518)

* Sip Profile Edit: Fix setting enabled labels (#7519)

* Sip Profile Edit: Fix setting enabled labels

* Update sip_profile_edit.php

* Update dialplan_edit.php (#7520)

* Update SQL queries to use true/false for contact primary settings (#7521)

* Update SQL queries to use true/false for contact primary settings

* Update contacts_vcard.php

* Update email.php

* Update totp.php

* Update contact_url_edit.php

* Update contact_email_edit.php

* Update contact_address_edit.php

* Update contact_attachment_edit.php

* Update contact_phone_edit.php

* Add a database views method

* Add database view groups

* Add database users view

* Add database call_recordings view

* Update users.php

* Add  database view call block

* Update schema to use the database views method

* Update conference.conf.lua boolean

* Update directory.lua boolean

* Update callcenter.conf.lua agent_status boolean

* Update sofia.conf.lua boolean

* Update number translations lua boolean

* Update directory.lua boolean

* Update group_call.lua fix the cache

* Update reverse-auth-lookup.lua boolean

* Update directory.lua boolean

* Use concat instead of ||

* Update index.lua

---------

Co-authored-by: fusionate <nate@fusionpbx.com>
Co-authored-by: Alex <alex@fusionpbx.com>
Co-authored-by: frytimo <tim@fusionpbx.com>
2025-09-20 18:42:05 -06:00

258 lines
7.8 KiB
PHP

<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2019
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
if (permission_exists('contact_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
if (!empty($_GET)) {
//add multi-lingual support
$language = new text;
$text = $language->get();
//create the vcard object
$vcard = new vcard();
//get the contact id
$contact_uuid = $_GET["id"] ?? '';
//get the contact's information
$sql = "select * from v_contacts ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and contact_uuid = :contact_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['contact_uuid'] = $contact_uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (!empty($row)) {
$contact_type = $row["contact_type"];
$contact_organization = $row["contact_organization"];
$contact_name_given = $row["contact_name_given"];
$contact_name_family = $row["contact_name_family"];
$contact_nickname = $row["contact_nickname"];
$contact_title = $row["contact_title"];
$contact_role = $row["contact_role"];
$contact_time_zone = $row["contact_time_zone"];
$contact_note = $row["contact_note"];
}
unset($sql, $parameters, $row);
$vcard->data['company'] = $contact_organization ?? '';
$vcard->data['first_name'] = $contact_name_given ?? '';
$vcard->data['last_name'] = $contact_name_family ?? '';
//get the contact's primary (and a secondary, if available) email
$sql = "select email_address from v_contact_emails ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and contact_uuid = :contact_uuid ";
$sql .= "order by email_primary desc ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['contact_uuid'] = $contact_uuid;
$database = new database;
$result = $database->select($sql, $parameters, 'all');
if (!empty($result)) {
$e = 1;
foreach ($result as $row) {
$vcard->data['email'.$e] = $row["email_address"];
if ($e++ == 2) { break; } //limit to 2 rows
}
}
unset($sql, $parameters, $result, $row);
//get the contact's primary url
$sql = "select url_address from v_contact_urls ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and contact_uuid = :contact_uuid ";
$sql .= "and url_primary = true ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['contact_uuid'] = $contact_uuid;
$database = new database;
$url_address = $database->select($sql, $parameters, 'column');
$vcard->data['url'] = $url_address;
unset($sql, $parameters, $row);
if ($_GET['type'] == "image" || $_GET['type'] == "html") {
//don't add this to the QR code at this time
}
else {
$vcard->data['display_name'] = implode(' ', array_filter([$contact_name_given, $contact_name_family]));
$vcard->data['contact_nickname'] = $contact_nickname ?? null;
$vcard->data['contact_title'] = $contact_title ?? null;
$vcard->data['contact_role'] = $contact_role ?? null;
$vcard->data['timezone'] = $contact_time_zone ?? null;
$vcard->data['contact_note'] = $contact_note ?? null;
}
//get the contact's telephone numbers
$sql = "select * from v_contact_phones ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and contact_uuid = :contact_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['contact_uuid'] = $contact_uuid;
$database = new database;
$result = $database->select($sql, $parameters, 'all');
if (!empty($result)) {
foreach ($result as $row) {
$phone_label = $row["phone_label"];
$phone_number = $row["phone_number"];
if ($phone_label == $text['option-work']) { $vcard_phone_type = 'work'; }
else if ($phone_label == $text['option-home']) { $vcard_phone_type = 'home'; }
else if ($phone_label == $text['option-mobile']) { $vcard_phone_type = 'cell'; }
else if ($phone_label == $text['option-fax']) { $vcard_phone_type = 'fax'; }
else if ($phone_label == $text['option-pager']) { $vcard_phone_type = 'pager'; }
else { $vcard_phone_type = 'voice'; }
if ($vcard_phone_type != '') {
$vcard->data[$vcard_phone_type.'_tel'] = $phone_number;
}
}
}
unset($sql, $parameters, $result, $row);
//get the contact's addresses
if ($_GET['type'] == "image" || $_GET['type'] == "html") {
//don't add this to the QR code at this time
}
else {
$sql = "select * from v_contact_addresses ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and contact_uuid = :contact_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['contact_uuid'] = $contact_uuid;
$database = new database;
$result = $database->select($sql, $parameters, 'all');
if (!empty($result)) {
foreach ($result as $row) {
$address_type = $row["address_type"];
$address_street = $row["address_street"];
$address_extended = $row["address_extended"];
$address_locality = $row["address_locality"];
$address_region = $row["address_region"];
$address_postal_code = $row["address_postal_code"];
$address_country = $row["address_country"];
$address_latitude = $row["address_latitude"];
$address_longitude = $row["address_longitude"];
$address_type = strtolower(trim($address_type));
$vcard->data[$address_type.'_address'] = $address_street;
$vcard->data[$address_type.'_extended_address'] = $address_extended;
$vcard->data[$address_type.'_city'] = $address_locality;
$vcard->data[$address_type.'_state'] = $address_region;
$vcard->data[$address_type.'_postal_code'] = $address_postal_code;
$vcard->data[$address_type.'_country'] = $address_country;
}
}
unset($sql, $parameters, $result, $row);
}
//download the vcard
if ($_GET['type'] == "download") {
$vcard->download();
}
//show the vcard in a text qr code
if ($_GET['type'] == "text") {
$vcard->build();
$content = $vcard->card;
if ($qr_vcard) {
$qr_vcard = $content;
}
else {
echo $content;
}
}
//show the vcard in an image qr code
if ($_GET['type'] == "image" || $_GET['type'] == "html") {
$vcard->build();
$content = $vcard->card;
if (isset($_GET['debug'])) {
echo "<pre>";
print_r($vcard->data);
echo "</pre>";
exit;
}
//include
require_once $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/resources/qr/qrcode.php";
//error correction level
//QR_ERROR_CORRECT_LEVEL_L : $e = 0;
//QR_ERROR_CORRECT_LEVEL_M : $e = 1;
//QR_ERROR_CORRECT_LEVEL_Q : $e = 2;
//QR_ERROR_CORRECT_LEVEL_H : $e = 3;
//get the qr object
$qr = QRCode::getMinimumQRCode($content, QR_ERROR_CORRECT_LEVEL_L);
}
//show the vcard as an png image
if ($_GET['type'] == "image") {
header("Content-type: image/png");
$im = $qr->createImage(5, 10);
imagepng($im);
imagedestroy($im);
}
//show the vcard in an html qr code
if ($_GET['type'] == "html") {
$qr->make();
$qr->printHTML();
}
}
/*
//additional un accounted fields
additional_name
name_prefix
name_suffix
department
work_po_box
home_po_box
home_extended_address
home_address
home_city
home_state
home_postal_code
home_country
pager_tel
contact_email2
photo
birthday
sort_string
*/
?>