Move contacts from the app to core directory

This commit is contained in:
markjcrane
2024-11-16 21:06:29 -07:00
parent cbcc47d47b
commit 9b843bbff0
50 changed files with 0 additions and 0 deletions
File diff suppressed because it is too large Load Diff
+7
View File
@@ -0,0 +1,7 @@
<?php
if ($domains_processed == 1) {
}
?>
File diff suppressed because it is too large Load Diff
+38
View File
@@ -0,0 +1,38 @@
<?php
$y=0;
$apps[$x]['menu'][$y]['title']['en-us'] = "Contacts";
$apps[$x]['menu'][$y]['title']['en-gb'] = "Contacts";
$apps[$x]['menu'][$y]['title']['ar-eg'] = "الاتصالات";
$apps[$x]['menu'][$y]['title']['de-at'] = "Kontakte";
$apps[$x]['menu'][$y]['title']['de-ch'] = "Ansprechpartner";
$apps[$x]['menu'][$y]['title']['de-de'] = "Kontakte";
$apps[$x]['menu'][$y]['title']['es-cl'] = "Contactos";
$apps[$x]['menu'][$y]['title']['es-mx'] = "Contactos";
$apps[$x]['menu'][$y]['title']['fr-ca'] = "Contacts";
$apps[$x]['menu'][$y]['title']['fr-fr'] = "Contacts";
$apps[$x]['menu'][$y]['title']['he-il'] = "אנשי קשר";
$apps[$x]['menu'][$y]['title']['it-it'] = "Contatti";
$apps[$x]['menu'][$y]['title']['ka-ge'] = "კონტაქტები";
$apps[$x]['menu'][$y]['title']['nl-nl'] = "Contacten";
$apps[$x]['menu'][$y]['title']['pl-pl'] = "Kontakty";
$apps[$x]['menu'][$y]['title']['pt-br'] = "Contatos";
$apps[$x]['menu'][$y]['title']['pt-pt'] = "Contactos";
$apps[$x]['menu'][$y]['title']['ro-ro'] = "Contacte";
$apps[$x]['menu'][$y]['title']['ru-ru'] = "Контакты";
$apps[$x]['menu'][$y]['title']['sv-se'] = "Kontakter";
$apps[$x]['menu'][$y]['title']['uk-ua'] = "Контакти";
$apps[$x]['menu'][$y]['title']['zh-cn'] = "联系人";
$apps[$x]['menu'][$y]['title']['ja-jp'] = "コンタクト";
$apps[$x]['menu'][$y]['title']['ko-kr'] = "콘택트 렌즈";
$apps[$x]['menu'][$y]['uuid'] = "f14e6ab6-6565-d4e6-cbad-a51d2e3e8ec6";
$apps[$x]['menu'][$y]['parent_uuid'] = "fd29e39c-c936-f5fc-8e2b-611681b266b5";
$apps[$x]['menu'][$y]['category'] = "internal";
$apps[$x]['menu'][$y]['icon'] = "";
$apps[$x]['menu'][$y]['path'] = "/app/contacts/contacts.php";
$apps[$x]['menu'][$y]['order'] = "";
$apps[$x]['menu'][$y]['groups'][] = "admin";
$apps[$x]['menu'][$y]['groups'][] = "superadmin";
$y++;
?>
+473
View File
@@ -0,0 +1,473 @@
<?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-2024
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('contact_address_edit') || permission_exists('contact_address_add')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//set the defaults
$address_label = '';
$address_label_custom = '';
$address_street = '';
$address_extended = '';
$address_community = '';
$address_locality = '';
$address_region = '';
$address_postal_code = '';
$address_country = '';
$address_latitude = '';
$address_longitude = '';
$address_description = '';
//action add or update
if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
$action = "update";
$contact_address_uuid = $_REQUEST["id"];
}
else {
$action = "add";
}
//get the contact uuid
if (!empty($_GET["contact_uuid"]) && is_uuid($_GET["contact_uuid"])) {
$contact_uuid = $_GET["contact_uuid"];
}
//get http post variables and set them to php variables
if (!empty($_POST)) {
$address_type = $_POST["address_type"];
$address_label = $_POST["address_label"];
$address_label_custom = $_POST["address_label_custom"];
$address_street = $_POST["address_street"];
$address_extended = $_POST["address_extended"];
$address_community = $_POST["address_community"];
$address_locality = $_POST["address_locality"];
$address_region = $_POST["address_region"];
$address_postal_code = $_POST["address_postal_code"];
$address_country = $_POST["address_country"];
$address_latitude = $_POST["address_latitude"];
$address_longitude = $_POST["address_longitude"];
$address_primary = $_POST["address_primary"];
$address_description = $_POST["address_description"];
//use custom label if set
$address_label = !empty($address_label_custom) ? $address_label_custom : $address_label;
}
//process the form data
if (!empty($_POST) && empty($_POST["persistformvar"])) {
//set the uuid
if ($action == "update") {
$contact_address_uuid = $_POST["contact_address_uuid"];
}
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: contacts.php');
exit;
}
//check for all required data
$msg = '';
if (!empty($msg) && empty($_POST["persistformvar"])) {
require_once "resources/header.php";
require_once "resources/persist_form_var.php";
echo "<div align='center'>\n";
echo "<table><tr><td>\n";
echo $msg."<br />";
echo "</td></tr></table>\n";
persistformvar($_POST);
echo "</div>\n";
require_once "resources/footer.php";
return;
}
//add or update the database
if (empty($_POST["persistformvar"])) {
//update last modified
$array['contacts'][0]['contact_uuid'] = $contact_uuid;
$array['contacts'][0]['domain_uuid'] = $domain_uuid;
$array['contacts'][0]['last_mod_date'] = 'now()';
$array['contacts'][0]['last_mod_user'] = $_SESSION['username'];
$p = new permissions;
$p->add('contact_edit', 'temp');
$database = new database;
$database->app_name = 'contacts';
$database->app_uuid = '04481e0e-a478-c559-adad-52bd4174574c';
$database->save($array);
unset($array);
$p->delete('contact_edit', 'temp');
//if primary, unmark other primary addresses
if ($email_primary) {
$sql = "update v_contact_addresses set address_primary = 0 ";
$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;
$database->execute($sql, $parameters);
unset($sql, $parameters);
}
if ($action == "add" && permission_exists('contact_address_add')) {
$contact_address_uuid = uuid();
$array['contact_addresses'][0]['contact_address_uuid'] = $contact_address_uuid;
message::add($text['message-add']);
}
if ($action == "update" && permission_exists('contact_address_edit')) {
$array['contact_addresses'][0]['contact_address_uuid'] = $contact_address_uuid;
message::add($text['message-update']);
}
if (!empty($array)) {
$array['contact_addresses'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
$array['contact_addresses'][0]['contact_uuid'] = $contact_uuid;
$array['contact_addresses'][0]['address_type'] = $address_type;
$array['contact_addresses'][0]['address_label'] = $address_label;
$array['contact_addresses'][0]['address_street'] = $address_street;
$array['contact_addresses'][0]['address_extended'] = $address_extended;
$array['contact_addresses'][0]['address_community'] = $address_community;
$array['contact_addresses'][0]['address_locality'] = $address_locality;
$array['contact_addresses'][0]['address_region'] = $address_region;
$array['contact_addresses'][0]['address_postal_code'] = $address_postal_code;
$array['contact_addresses'][0]['address_country'] = $address_country;
$array['contact_addresses'][0]['address_latitude'] = $address_latitude;
$array['contact_addresses'][0]['address_longitude'] = $address_longitude;
$array['contact_addresses'][0]['address_primary'] = $address_primary ? 1 : 0;
$array['contact_addresses'][0]['address_description'] = $address_description;
$database = new database;
$database->app_name = 'contacts';
$database->app_uuid = '04481e0e-a478-c559-adad-52bd4174574c';
$database->save($array);
unset($array);
}
header("Location: contact_edit.php?id=".$contact_uuid);
exit;
}
}
//pre-populate the form
if (!empty($_GET) && empty($_POST["persistformvar"])) {
$contact_address_uuid = $_GET["id"] ?? '';
$sql = "select * from v_contact_addresses ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and contact_address_uuid = :contact_address_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['contact_address_uuid'] = $contact_address_uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (!empty($row)) {
$address_type = $row["address_type"];
$address_label = $row["address_label"];
$address_street = $row["address_street"];
$address_extended = $row["address_extended"];
$address_community = $row["address_community"];
$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_primary = $row["address_primary"];
$address_description = $row["address_description"];
}
unset($sql, $parameters, $row);
}
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//show the header
if ($action == "update") {
$document['title'] = $text['title-contact_addresses-edit'];
}
else if ($action == "add") {
$document['title'] = $text['title-contact_addresses-add'];
}
require_once "resources/header.php";
//javascript to toggle input/select boxes
echo "<script type='text/javascript'>";
echo " function toggle_custom(field) {";
echo " $('#'+field).toggle();";
echo " document.getElementById(field).selectedIndex = 0;";
echo " document.getElementById(field+'_custom').value = '';";
echo " $('#'+field+'_custom').toggle();";
echo " if ($('#'+field+'_custom').is(':visible')) { $('#'+field+'_custom').trigger('focus'); } else { $('#'+field).trigger('focus'); }";
echo " }";
echo "</script>";
//show the content
echo "<form method='post' name='frm' id='frm'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'>";
if ($action == "update") {
echo "<b>".$text['header-contact_addresses-edit']."</b>";
}
else if ($action == "add") {
echo "<b>".$text['header-contact_addresses-add']."</b>";
}
echo " </div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'contact_edit.php?id='.urlencode($contact_uuid)]);
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
if ($action == "update") {
echo $text['description-contact_addresses-edit'];
}
else if ($action == "add") {
echo $text['description-contact_addresses-add'];
}
echo "<br /><br />\n";
echo "<div class='card'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-address_label']."\n";
echo "</td>\n";
echo "<td width='70%' class='vtable' align='left'>\n";
if (!empty($_SESSION["contact"]["address_label"])) {
sort($_SESSION["contact"]["address_label"]);
foreach($_SESSION["contact"]["address_label"] as $row) {
$address_label_options[] = "<option value='".$row."' ".(($row == $address_label) ? "selected='selected'" : null).">".$row."</option>";
}
$address_label_found = (in_array($address_label, $_SESSION["contact"]["address_label"])) ? true : false;
}
else {
$selected[$address_label] = "selected";
$default_labels[] = $text['option-work'];
$default_labels[] = $text['option-home'];
$default_labels[] = $text['option-mailing'];
$default_labels[] = $text['option-physical'];
$default_labels[] = $text['option-shipping'];
$default_labels[] = $text['option-billing'];
$default_labels[] = $text['option-other'];
foreach ($default_labels as $default_label) {
$address_label_options[] = "<option value='".$default_label."' ".!empty($selected[$default_label]).">".$default_label."</option>";
}
$address_label_found = (in_array($address_label, $default_labels)) ? true : false;
}
echo " <select class='formfld' ".((!empty($address_label) && !$address_label_found) ? "style='display: none;'" : null)." name='address_label' id='address_label' onchange=\"getElementById('address_label_custom').value='';\">\n";
echo " <option value=''></option>\n";
echo (!empty($address_label_options)) ? implode("\n", $address_label_options) : null;
echo " </select>\n";
echo " <input type='text' class='formfld' ".((empty($address_label) || $address_label_found) ? "style='display: none;'" : null)." name='address_label_custom' id='address_label_custom' value=\"".((!$address_label_found) ? htmlentities($address_label) : null)."\">\n";
echo " <input type='button' id='btn_toggle_label' class='btn' alt='".$text['button-back']."' value='&#9665;' onclick=\"toggle_custom('address_label');\">\n";
echo "<br />\n";
echo $text['description-address_label']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-address_type']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='address_type' id='address_type'>\n";
echo " <option value=''></option>\n";
$vcard_address_types = array(
'work' => $text['option-work'],
'home' => $text['option-home'],
'dom' => $text['option-dom'],
'intl' => $text['option-intl'],
'postal' => $text['option-postal'],
'parcel' => $text['option-parcel'],
'pref' => $text['option-pref']
);
foreach ($vcard_address_types as $vcard_address_type_value => $vcard_address_type_label) {
echo " <option value='".$vcard_address_type_value."' ".(!empty($address_type) && $address_type == $vcard_address_type_value ? "selected" : null).">".$vcard_address_type_label."</option>\n";
}
echo " </select>\n";
echo "<br />\n";
echo $text['description-address_type']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-address_address']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <textarea class='formfld' name='address_street' style='margin-bottom: 3px;'>".$address_street."</textarea><br>\n";
echo " <input class='formfld' type='text' name='address_extended' maxlength='255' value=\"".escape($address_extended)."\">\n";
echo "<br />\n";
echo $text['description-address_address']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-address_community']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='address_community' maxlength='255' value=\"".escape($address_community)."\">\n";
echo "<br />\n";
echo $text['description-address_community']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-address_locality']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='address_locality' maxlength='255' value=\"".escape($address_locality)."\">\n";
echo "<br />\n";
echo $text['description-address_locality']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-address_region']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='address_region' maxlength='255' value=\"".escape($address_region)."\">\n";
echo "<br />\n";
echo $text['description-address_region']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-address_postal_code']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='address_postal_code' maxlength='255' value=\"".escape($address_postal_code)."\">\n";
echo "<br />\n";
echo $text['description-address_postal_code']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-address_country']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='address_country' maxlength='255' value=\"".escape($address_country)."\">\n";
echo "<br />\n";
echo $text['description-address_country']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-address_latitude']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='number' name='address_latitude' maxlength='255' min='-90' max='90' step='0.0000001' value=\"".escape($address_latitude)."\">\n";
echo "<br />\n";
echo $text['description-address_latitude']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-address_longitude']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='number' name='address_longitude' maxlength='255' min='-180' max='180' step='0.0000001' value=\"".escape($address_longitude)."\">\n";
echo "<br />\n";
echo $text['description-address_longitude']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-primary']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='address_primary' id='address_primary'>\n";
echo " <option value='0'>".$text['option-false']."</option>\n";
echo " <option value='1' ".(!empty($address_primary) && $address_primary ? "selected" : null).">".$text['option-true']."</option>\n";
echo " </select>\n";
echo "<br />\n";
echo $text['description-address_primary']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-address_description']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='address_description' maxlength='255' value=\"".escape($address_description)."\">\n";
echo "<br />\n";
echo $text['description-address_description']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>";
echo "</div>\n";
echo "<br><br>";
echo "<input type='hidden' name='contact_uuid' value='".escape($contact_uuid)."'>\n";
if ($action == "update") {
echo "<input type='hidden' name='contact_address_uuid' value='".escape($contact_address_uuid)."'>\n";
}
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>";
//include the footer
require_once "resources/footer.php";
?>
+125
View File
@@ -0,0 +1,125 @@
<?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-2024
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";
//check permissions
if (permission_exists('contact_address_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//set from session variables
$list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false';
//set the uuid
if (!empty($_GET['id']) && is_uuid($_GET['id'])) {
$contact_uuid = $_GET['id'];
}
//get the address list
$sql = "select * from v_contact_addresses ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and contact_uuid = :contact_uuid ";
$sql .= "order by address_primary desc, address_label asc ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['contact_uuid'] = $contact_uuid ?? '';
$database = new database;
$contact_addresses = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//show if exists
if (!empty($contact_addresses)) {
//show the content
echo "<div class='action_bar sub shrink'>\n";
echo " <div class='heading'><b>".!empty($text['label-addresses'])."</b></div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo "<div class='card'>\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
if (permission_exists('contact_address_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all_addresses' name='checkbox_all' onclick=\"edit_all_toggle('addresses');\" ".(!empty($contact_addresses) ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
}
echo "<th class='pct-15'>".!empty($text['label-address_label'])."</th>\n";
echo "<th>".!empty($text['label-address_address'])."</th>\n";
echo "<th>".!empty($text['label-address_locality']).", ".!empty($text['label-address_region'])."</th>\n";
echo "<th class='center'>".!empty($text['label-address_country'])."</th>\n";
echo "<th class='shrink'>&nbsp;</th>\n";
echo "<th class='hide-md-dn'>".!empty($text['label-address_description'])."</th>\n";
if (permission_exists('contact_address_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
if (!empty($contact_addresses)) {
$x = 0;
foreach ($contact_addresses as $row) {
$map_query = $row['address_street']." ".$row['address_extended'].", ".$row['address_locality'].", ".$row['address_region'].", ".$row['address_region'].", ".$row['address_postal_code'];
if (permission_exists('contact_address_edit')) {
$list_row_url = "contact_address_edit.php?contact_uuid=".urlencode($row['contact_uuid'])."&id=".urlencode($row['contact_address_uuid']);
}
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('contact_address_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='contact_addresses[$x][checked]' id='checkbox_".$x."' class='chk_delete checkbox_addresses' value='true' onclick=\"edit_delete_action('addresses');\">\n";
echo " <input type='hidden' name='contact_addresses[$x][uuid]' value='".escape($row['contact_address_uuid'])."' />\n";
echo " </td>\n";
}
echo " <td>".escape($row['address_label'])." ".($row['address_primary'] ? "&nbsp;<i class='fas fa-star fa-xs' style='float: right; margin-top: 0.5em; margin-right: -0.5em;' title=\"".$text['label-primary']."\"></i>" : null)."</td>\n";
$address = escape($row['address_street']).(!empty($row['address_extended']) ? " ".escape($row['address_extended']) : null);
echo " <td class='pct-25 overflow no-wrap'><a href='".$list_row_url."'>".$address."</a>&nbsp;</td>\n";
echo " <td class='no-wrap'>".escape($row['address_locality']).((!empty($row['address_locality']) && !empty($row['address_region'])) ? ", " : null).escape($row['address_region'])."&nbsp;</td>\n";
echo " <td class='center'>".escape($row['address_country'])."&nbsp;</td>\n";
echo " <td class='button no-link'><a href=\"http://maps.google.com/maps?q=".urlencode($map_query)."&hl=en\" target=\"_blank\"><img src='resources/images/icon_gmaps.png' style='width: 21px; height: 21px; alt='".!empty($text['label-google_map'])."' title='".!empty($text['label-google_map'])."'></a></td>\n";
echo " <td class='description overflow hide-md-dn'>".escape($row['address_description'])."&nbsp;</td>\n";
if (permission_exists('contact_address_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n";
}
echo "</tr>\n";
$x++;
}
unset($contact_addresses);
}
echo "</table>\n";
echo "</div>\n";
echo "<br />\n";
}
?>
+98
View File
@@ -0,0 +1,98 @@
<?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-2020
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";
//check permissions
if (permission_exists('contact_address_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//get the address list
$sql = "select * from v_contact_addresses ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and contact_uuid = :contact_uuid ";
$sql .= "order by address_primary desc, address_label asc ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['contact_uuid'] = $contact_uuid ?? '';
$database = new database;
$contact_addresses = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//show if exists
if (!empty($contact_addresses)) {
//show the content
echo "<div class='grid' style='grid-template-columns: 70px auto 30px;'>\n";
$x = 0;
foreach ($contact_addresses as $row) {
$map_query = $row['address_street']." ".$row['address_extended'].", ".$row['address_locality'].", ".$row['address_region'].", ".$row['address_region'].", ".$row['address_postal_code'];
echo "<div class='box contact-details-label'>".escape($row['address_label'])."</div>\n";
// ($row['address_primary'] ? "&nbsp;<i class='fas fa-star fa-xs' style='float: right; margin-top: 0.5em; margin-right: -0.5em;' title=\"".$text['label-primary']."\"></i>" : null)."</td>\n";
echo "<div class='box'>";
echo "<a href='http://maps.google.com/maps?q=".urlencode($map_query)."&hl=en' target='_blank' alt='".$text['label-google_map']."' title='".$text['label-google_map']."'>";
$previous_data = false;
if ($row['address_street']) {
echo escape($row['address_street']);
$previous_data = true;
}
if ($row['address_extended']) {
echo $previous_data ? ', ' : null;
echo escape($row['address_extended']);
$previous_data = true;
}
if ($row['address_locality']) {
echo $previous_data ? ', ' : null;
echo escape($row['address_locality']);
$previous_data = true;
}
if ($row['address_region']) {
echo $previous_data ? ', ' : null;
echo escape($row['address_region']);
$previous_data = true;
}
if ($row['address_country']) {
echo $previous_data ? ', ' : null;
echo escape($row['address_country']);
$previous_data = true;
}
echo "</a>";
echo "</div>\n";
echo "<div class='box' style='text-align: right;'><i class='fas fa-map-marked-alt fa-fw'></i></div>\n";
$x++;
}
echo "</div>\n";
unset($contact_addresses);
}
?>
+86
View File
@@ -0,0 +1,86 @@
<?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) 2016-2024
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
//add multi-lingual support
$language = new text;
$text = $language->get();
//get attachment uuid
$contact_attachment_uuid = $_GET['id'] ?? '';
$action = $_GET['action'] ?? '';
$session_id = $_GET['sid'] ?? '';
//get media
if (!empty($contact_attachment_uuid) && is_uuid($contact_attachment_uuid)) {
$sql = "select attachment_filename, attachment_content from v_contact_attachments ";
$sql .= "where contact_attachment_uuid = :contact_attachment_uuid ";
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['contact_attachment_uuid'] = $contact_attachment_uuid;
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$attachment = $database->select($sql, $parameters ?? null, 'row');
unset($sql, $parameters);
$attachment_type = strtolower(pathinfo($attachment['attachment_filename'] ?? '', PATHINFO_EXTENSION));
//determine mime type
$content_type = 'application/octet-stream'; //set default
$allowed_attachment_types = json_decode($_SESSION['contact']['allowed_attachment_types']['text'] ?? '', true);
if (!empty($allowed_attachment_types)) {
if ($allowed_attachment_types[$attachment_type] != '') {
$content_type = $allowed_attachment_types[$attachment_type];
}
}
switch ($action) {
case 'download':
header("Content-type: ".$content_type."; charset=utf-8");
header("Content-Disposition: attachment; filename=\"".$attachment['attachment_filename']."\"");
header("Content-Length: ".strlen(base64_decode($attachment['attachment_content'])));
if (!empty($session_id)) {
header("Cache-Control: max-age=86400"); // 24h
header("Expires: ". gmdate('D, d M Y H:i:s \G\M\T', time() + 86400)); // 24h
}
echo base64_decode($attachment['attachment_content']);
break;
case 'display':
echo " <table cellpadding='0' cellspacing='0' border='0' width='100%' height='100%'>\n";
echo " <tr>\n";
echo " <td align='center' valign='middle'>\n";
echo " <img src=\"data:".$content_type.";base64,".$attachment['attachment_content']."\" style='width: auto; max-width: 95%; height: auto; max-height: 800px; box-shadow: 0px 1px 20px #888; background-color: #fff; cursor: pointer;' onclick=\"$('#contact_attachment_layer').fadeOut(200);\" oncontextmenu=\"window.open('contact_attachment.php?id=".$contact_attachment_uuid."&action=download'); return false;\" title=\"\">\n";
echo " </td>\n";
echo " </tr>\n";
echo " </table>\n";
break;
}
}
?>
+283
View File
@@ -0,0 +1,283 @@
<?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-2024
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (!permission_exists('contact_attachment_edit') && !permission_exists('contact_attachment_add')) {
echo "access denied"; exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//action add or update
$contact_attachment_uuid = $_REQUEST['id'] ?? '';
$contact_uuid = $_REQUEST['contact_uuid'] ?? '';
if (!empty($contact_attachment_uuid) && !empty($contact_uuid) && is_uuid($contact_attachment_uuid) && is_uuid($contact_uuid)) {
$action = 'update';
}
else if (!empty($contact_uuid) && is_uuid($contact_uuid)) {
$action = 'add';
}
else {
exit;
}
//get http post variables and set them to php variables
if (!empty($_POST)) {
//set the variables
$attachment = $_FILES['attachment'];
$attachment_primary = $_POST['attachment_primary'];
$attachment_description = $_POST['attachment_description'];
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: contacts.php');
exit;
}
//get the attachment type
if (empty($attachment) || sizeof($attachment) == 0) {
$attachment_type = strtolower(pathinfo($_POST['attachment_filename'], PATHINFO_EXTENSION));
}
else {
$attachment_type = strtolower(pathinfo($attachment['name'], PATHINFO_EXTENSION));
}
//unflag others as primary
$allowed_primary_attachment = false;
if ($attachment_primary && ($attachment_type == 'jpg' || $attachment_type == 'jpeg' || $attachment_type == 'gif' || $attachment_type == 'png')) {
$sql = "update v_contact_attachments set attachment_primary = 0 ";
$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;
$database->execute($sql, $parameters ?? null);
unset($sql, $parameters);
$allowed_primary_attachment = true;
}
//get the allowed extensions
$allowed_extensions = array_keys(json_decode($_SESSION['contact']['allowed_attachment_types']['text'], true));
//get the attachment extension
$attachment_extension = strtolower(pathinfo($attachment['name'], PATHINFO_EXTENSION));
//check the allowed extensions
if ($attachment['error'] == '0' && in_array($attachment_extension, $allowed_extensions)) {
//get the attachment content
$attachment_content = file_get_contents($attachment['tmp_name']);
//list of image extensions
$image_extensions = array('png','jpg','jpeg','gif','bmp', 'webp');
//read the image from the string then output the image without meta data
if (in_array($attachment_extension, $image_extensions)) {
//create the image object from the content string
$image = imagecreatefromstring($attachment_content);
imagealphablending($image, FALSE);
imagesavealpha($image, TRUE);
//start output buffering to capture the image data
ob_start();
//output the image without the EXIF data
imagepng($image);
//get the image from the buffer
$attachment_content = ob_get_contents();
//end the buffering
ob_end_clean();
//free up the memory
imagedestroy($image);
}
}
//prepare the array
$array['contact_attachments'][0]['contact_attachment_uuid'] = $action == 'update' ? $contact_attachment_uuid : uuid();
$array['contact_attachments'][0]['domain_uuid'] = $_SESSION['domain_uuid'] ?? '';
$array['contact_attachments'][0]['contact_uuid'] = $contact_uuid;
$array['contact_attachments'][0]['attachment_primary'] = $allowed_primary_attachment ? 1 : 0;
if ($attachment['error'] == '0' && in_array(strtolower(pathinfo($attachment['name'], PATHINFO_EXTENSION)), $allowed_extensions)) {
$array['contact_attachments'][0]['attachment_filename'] = $attachment['name'];
$array['contact_attachments'][0]['attachment_content'] = base64_encode($attachment_content);
}
$array['contact_attachments'][0]['attachment_description'] = $attachment_description;
if ($action == 'add') {
$array['contact_attachments'][0]['attachment_uploaded_date'] = 'now()';
$array['contact_attachments'][0]['attachment_uploaded_user_uuid'] = $_SESSION['user_uuid'];
}
//save data
$database = new database;
$database->app_name = 'contacts';
$database->app_uuid = '04481e0e-a478-c559-adad-52bd4174574c';
$database->save($array);
unset($array);
//redirect
message::add($text['message-'.($action == 'update' ? 'update' : 'uploaded')]);
header('Location: contact_edit.php?id='.$contact_uuid);
exit;
}
//get form data
if (!empty($_GET)) {
$sql = "select * from v_contact_attachments ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and contact_attachment_uuid = :contact_attachment_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['contact_attachment_uuid'] = $contact_attachment_uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (!empty($row)) {
$attachment_primary = $row["attachment_primary"];
$attachment_filename = $row["attachment_filename"];
$attachment_content = $row["attachment_content"];
$attachment_description = $row["attachment_description"];
}
unset($sql, $parameters, $row);
}
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//show the header
if ($action == "update") {
$document['title'] = $text['title-contact_attachment-edit'];
}
else if ($action == "add") {
$document['title'] = $text['title-contact_attachment-add'];
}
require_once "resources/header.php";
//show the content
echo "<form method='post' name='frm' id='frm' enctype='multipart/form-data'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'>";
if ($action == "update") {
echo "<b>".$text['header-contact_attachment-edit']."</b>";
}
else if ($action == "add") {
echo "<b>".$text['header-contact_attachment-add']."</b>";
}
echo " </div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'contact_edit.php?id='.urlencode($contact_uuid)]);
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo "<div class='card'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-attachment']."\n";
echo "</td>\n";
echo "<td width='70%' class='vtable' align='left'>\n";
$attachment_type = strtolower(pathinfo($attachment_filename ?? '', PATHINFO_EXTENSION));
if ($action == 'update') {
echo "<input type='hidden' name='attachment_filename' value=\"".escape($attachment_filename)."\">\n";
if ($attachment_type == 'jpg' || $attachment_type == 'jpeg' || $attachment_type == 'gif' || $attachment_type == 'png') {
echo "<img src='data:image/".$attachment_type.";base64,".$attachment_content."' style='border: none; width: auto; max-height: 400px;' oncontextmenu=\"window.open('contact_attachment.php?id=".$contact_attachment_uuid."&action=download'); return false;\">";
}
else {
echo "<a href='contact_attachment.php?id=".$contact_attachment_uuid."&action=download' style='font-size: 120%;'>".$attachment_filename."</a>";
}
}
else {
$allowed_attachment_types = json_decode($_SESSION['contact']['allowed_attachment_types']['text'], true);
echo " <input type='file' class='formfld' name='attachment' id='attachment' accept='.".implode(',.',array_keys($allowed_attachment_types))."'>\n";
echo " <span style='display: inline-block; margin-top: 5px; font-size: 80%;'>".strtoupper(implode(', ', array_keys($allowed_attachment_types)))."</span>";
}
echo "</td>\n";
echo "</tr>\n";
if ($action == 'update' && ($attachment_type == 'jpg' || $attachment_type == 'jpeg' || $attachment_type == 'gif' || $attachment_type == 'png')) {
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-attachment_filename']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <a href='contact_attachment.php?id=".$contact_attachment_uuid."&action=download' style='font-size: 120%;'>".$attachment_filename."</a>";
echo "</td>\n";
echo "</tr>\n";
}
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-primary']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='attachment_primary' id='attachment_primary'>\n";
echo " <option value='0'>".$text['option-false']."</option>\n";
echo " <option value='1' ".(!empty($attachment_primary) && $attachment_primary ? "selected" : null).">".$text['option-true']."</option>\n";
echo " </select>\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-attachment_description']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='attachment_description' maxlength='255' value=\"".escape($attachment_description ?? '')."\">\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>";
echo "</div>\n";
echo "<br><br>";
echo "<input type='hidden' name='contact_uuid' value='".escape($contact_uuid)."'>\n";
if ($action == "update") {
echo "<input type='hidden' name='contact_attachment_uuid' value='".escape($contact_attachment_uuid)."'>\n";
}
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>";
//include the footer
require_once "resources/footer.php";
?>
+149
View File
@@ -0,0 +1,149 @@
<?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-2024
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";
//check permissions
if (permission_exists('contact_attachment_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//set from session variables
$list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false';
//get the contact attachment list
$sql = "select *, length(decode(attachment_content,'base64')) as attachment_size from v_contact_attachments ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and contact_uuid = :contact_uuid ";
$sql .= "order by attachment_primary desc, attachment_filename asc ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['contact_uuid'] = $contact_uuid ?? '';
$database = new database;
$contact_attachments = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//show if exists
if (!empty($contact_attachments)) {
//styles and attachment layer
echo "<style>\n";
echo " #contact_attachment_layer {\n";
echo " z-index: 999999;\n";
echo " position: absolute;\n";
echo " left: 0px;\n";
echo " top: 0px;\n";
echo " right: 0px;\n";
echo " bottom: 0px;\n";
echo " text-align: center;\n";
echo " vertical-align: middle;\n";
echo " }\n";
echo "</style>\n";
echo "<div id='contact_attachment_layer' style='display: none;'></div>\n";
//script
echo "<script>\n";
echo " function display_attachment(id) {\n";
echo " $('#contact_attachment_layer').load('contact_attachment.php?id=' + id + '&action=display', function(){\n";
echo " $('#contact_attachment_layer').fadeIn(200);\n";
echo " });\n";
echo " }\n";
echo "</script>\n";
//show the content
echo "<div class='action_bar sub shrink'>\n";
echo " <div class='heading'><b>".$text['label-attachments']."</b></div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo "<div class='card'>\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
if (permission_exists('contact_attachment_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all_attachments' name='checkbox_all' onclick=\"edit_all_toggle('attachments');\" ".(!empty($contact_attachments) ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
}
echo "<th class='pct-15'>".$text['label-type']."</th>\n";
echo "<th>".$text['label-attachment_filename']."</th>\n";
echo "<th>".$text['label-attachment_size']."</th>\n";
echo "<th>".$text['label-tools']."</th>\n";
echo "<th class='hide-md-dn'>".$text['label-attachment_description']."</th>\n";
if (permission_exists('contact_attachment_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
if (!empty($contact_attachments)) {
$x = 0;
foreach ($contact_attachments as $row) {
$attachment_type = strtolower(pathinfo($row['attachment_filename'], PATHINFO_EXTENSION));
$attachment_type_label = $attachment_type == 'jpg' || $attachment_type == 'jpeg' || $attachment_type == 'gif' || $attachment_type == 'png' ? $text['label-image'] : $text['label-file'];
if (permission_exists('contact_attachment_edit')) {
$list_row_url = "contact_attachment_edit.php?contact_uuid=".urlencode($row['contact_uuid'])."&id=".urlencode($row['contact_attachment_uuid']);
}
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('contact_attachment_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='contact_attachments[$x][checked]' id='checkbox_".$x."' class='chk_delete checkbox_attachments' value='true' onclick=\"edit_delete_action('attachments');\">\n";
echo " <input type='hidden' name='contact_attachments[$x][uuid]' value='".escape($row['contact_attachment_uuid'])."' />\n";
echo " </td>\n";
}
echo " <td>".$attachment_type_label." ".($row['attachment_primary'] ? "&nbsp;<i class='fas fa-star fa-xs' style='float: right; margin-top: 0.5em; margin-right: -0.5em;' title=\"".$text['label-primary']."\"></i>" : null)."</td>\n";
echo " <td><a href='".$list_row_url."'>".escape($row['attachment_filename'])."</a></td>\n";
echo " <td>".strtoupper(byte_convert($row['attachment_size']))."</td>\n";
echo " <td class='no-link' style='cursor: pointer;'>";
if ($attachment_type == 'jpg' || $attachment_type == 'jpeg' || $attachment_type == 'gif' || $attachment_type == 'png') {
echo button::create(['type'=>'button','class'=>'link','label'=>$text['button-view'],'onclick'=>"display_attachment('".escape($row['contact_attachment_uuid'])."');"]);
}
else {
echo button::create(['type'=>'button','class'=>'link','label'=>$text['label-download'],'onclick'=>"window.location='contact_attachment.php?id=".urlencode($row['contact_attachment_uuid'])."&action=download';"]);
}
echo " </td>\n";
echo " <td class='description overflow hide-md-dn'>".escape($row['attachment_description'])."</td>\n";
if (permission_exists('contact_attachment_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n";
}
echo "</tr>\n";
$x++;
}
}
unset($contact_attachments);
echo "</table>";
echo "</div>\n";
echo "<br />\n";
}
?>
+102
View File
@@ -0,0 +1,102 @@
<?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-2020
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";
//check permissions
if (permission_exists('contact_attachment_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//get the contact attachment list
$sql = "select *, length(decode(attachment_content,'base64')) as attachment_size from v_contact_attachments ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and contact_uuid = :contact_uuid ";
$sql .= "order by attachment_primary desc, attachment_filename asc ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['contact_uuid'] = $contact_uuid ?? '';
$database = new database;
$contact_attachments = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//show if exists
if (!empty($contact_attachments)) {
//styles and attachment layer
echo "<style>\n";
echo " #contact_attachment_layer {\n";
echo " z-index: 999999;\n";
echo " position: fixed;\n";
echo " left: 0px;\n";
echo " top: 0px;\n";
echo " right: 0px;\n";
echo " bottom: 0px;\n";
echo " text-align: center;\n";
echo " vertical-align: middle;\n";
echo " }\n";
echo "</style>\n";
echo "<div id='contact_attachment_layer' style='display: none;'></div>\n";
//display script
echo "<script>\n";
echo " function display_attachment(id) {\n";
echo " $('#contact_attachment_layer').load('contact_attachment.php?id=' + id + '&action=display', function(){\n";
echo " $('#contact_attachment_layer').fadeIn(200);\n";
echo " });\n";
echo " }\n";
echo "</script>\n";
//show the content
echo "<div class='grid' style='grid-template-columns: 70px auto 75px;'>\n";
$x = 0;
foreach ($contact_attachments as $row) {
$attachment_type = strtolower(pathinfo($row['attachment_filename'], PATHINFO_EXTENSION));
$attachment_type_label = $attachment_type == 'jpg' || $attachment_type == 'jpeg' || $attachment_type == 'gif' || $attachment_type == 'png' ? $text['label-image'] : $text['label-file'];
echo "<div class='box contact-details-label'>".$attachment_type_label."</div>\n";
// ($row['attachment_primary'] ? "&nbsp;<i class='fas fa-star fa-xs' style='float: right; margin-top: 0.5em; margin-right: -0.5em;' title=\"".$text['label-primary']."\"></i>" : null)."</td>\n";
echo "<div class='box'>";
if ($attachment_type == 'jpg' || $attachment_type == 'jpeg' || $attachment_type == 'gif' || $attachment_type == 'png') {
echo button::create(['type'=>'button','class'=>'link','label'=>escape($row['attachment_filename']),'onclick'=>"display_attachment('".escape($row['contact_attachment_uuid'])."');"]);
}
else {
echo button::create(['type'=>'button','class'=>'link','label'=>escape($row['attachment_filename']),'onclick'=>"window.location='contact_attachment.php?id=".urlencode($row['contact_attachment_uuid'])."&action=download';"]);
}
echo "</div>\n";
echo "<div class='box' style='text-align: right; font-size: 90%;'>".strtoupper(byte_convert($row['attachment_size']))."</div>\n";
$x++;
}
echo "</div>\n";
unset($contact_attachments);
}
?>
+120
View File
@@ -0,0 +1,120 @@
<?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-2013
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_add')) {
//access granted
}
else {
echo "access denied";
exit;
}
/*
echo "bang!";
exit;
*/
//add multi-lingual support
$language = new text;
$text = $language->get();
$_SESSION['contact_auth']['source'] = ($_SESSION['contact_auth']['source'] == '') ? $_REQUEST['source'] : $_SESSION['contact_auth']['source'];
$_SESSION['contact_auth']['target'] = ($_SESSION['contact_auth']['target'] == '') ? $_REQUEST['target'] : $_SESSION['contact_auth']['target'];
//google api authentication
if ($_SESSION['contact_auth']['source'] == 'google') {
if ($_REQUEST['error']) {
message::add(($text['message-'.$_REQUEST['error']] != '') ? $text['message-'.$_REQUEST['error']] : $_REQUEST['error'], 'negative');
header("Location: ".$_SESSION['contact_auth']['referer']);
unset($_SESSION['contact_auth']);
exit;
}
if (isset($_REQUEST['signout'])) {
unset($_SESSION['contact_auth']['token']);
message::add($text['message-google_signed_out']);
header("Location: https://www.google.com/accounts/Logout?continue=https://appengine.google.com/_ah/logout?continue=".(($_SERVER["HTTPS"] == "on") ? "https" : "http")."://".$_SERVER['HTTP_HOST'].PROJECT_PATH."/app/contacts/".$_SESSION['contact_auth']['referer']);
exit;
}
if ($_GET['code'] == '') {
header("Location: https://accounts.google.com/o/oauth2/auth?client_id=".$_SESSION['contact']['google_oauth_client_id']['text']."&redirect_uri=".(($_SERVER["HTTPS"] == "on") ? "https" : "http")."://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."&scope=https://www.google.com/m8/feeds/&response_type=code");
exit;
}
else {
$auth_code = $_GET["code"];
}
/*******************************************************************************************/
// request access token
$fields = array(
'code' => urlencode($auth_code),
'client_id' => urlencode($_SESSION['contact']['google_oauth_client_id']['text']),
'client_secret' => urlencode($_SESSION['contact']['google_oauth_client_secret']['text']),
'redirect_uri' => urlencode((($_SERVER["HTTPS"] == "on") ? "https" : "http")."://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']),
'grant_type' => urlencode('authorization_code')
);
foreach($fields as $key => $value) {
$post_fields[] = $key.'='.$value;
}
$post_fields = implode("&", $post_fields);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://accounts.google.com/o/oauth2/token');
curl_setopt($curl, CURLOPT_POST, 5);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
$result = curl_exec($curl);
curl_close($curl);
$response = json_decode($result);
$access_token = $response->access_token;
if ($access_token != '') {
// redirect to target script
$_SESSION['contact_auth']['token'] = $access_token;
header("Location: ".$_SESSION['contact_auth']['target']);
exit;
}
}
else {
message::add($text['message-access_denied'], 'negative');
header("Location: ".$_SESSION['contact_auth']['referer']);
unset($_SESSION['contact_auth']);
exit;
}
?>
File diff suppressed because it is too large Load Diff
+327
View File
@@ -0,0 +1,327 @@
<?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-2024
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('contact_email_edit') || permission_exists('contact_email_add')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//set the defaults
$email_label = '';
$email_address = '';
$email_description = '';
//action add or update
if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
$action = "update";
$contact_email_uuid = $_REQUEST["id"];
}
else {
$action = "add";
}
if (!empty($_GET["contact_uuid"]) && is_uuid($_GET["contact_uuid"])) {
$contact_uuid = $_GET["contact_uuid"];
}
//get http post variables and set them to php variables
if (!empty($_POST)) {
$email_label = $_POST["email_label"];
$email_label_custom = $_POST["email_label_custom"];
$email_address = $_POST["email_address"];
$email_primary = $_POST["email_primary"];
$email_description = $_POST["email_description"];
//use custom label if set
$email_label = !empty($email_label_custom) ? $email_label_custom : $email_label;
}
//process the form data
if (!empty($_POST) && empty($_POST["persistformvar"])) {
//set the uuid
if ($action == "update") {
$contact_email_uuid = $_POST["contact_email_uuid"];
}
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: contacts.php');
exit;
}
//check for all required data
$msg = '';
if (!empty($msg) && empty($_POST["persistformvar"])) {
require_once "resources/header.php";
require_once "resources/persist_form_var.php";
echo "<div align='center'>\n";
echo "<table><tr><td>\n";
echo $msg."<br />";
echo "</td></tr></table>\n";
persistformvar($_POST);
echo "</div>\n";
require_once "resources/footer.php";
return;
}
//add or update the database
if (empty($_POST["persistformvar"])) {
//update last modified
$array['contacts'][0]['contact_uuid'] = $contact_uuid;
$array['contacts'][0]['domain_uuid'] = $domain_uuid;
$array['contacts'][0]['last_mod_date'] = 'now()';
$array['contacts'][0]['last_mod_user'] = $_SESSION['username'];
$p = new permissions;
$p->add('contact_edit', 'temp');
$database = new database;
$database->app_name = 'contacts';
$database->app_uuid = '04481e0e-a478-c559-adad-52bd4174574c';
$database->save($array);
unset($array);
$p->delete('contact_edit', 'temp');
//if primary, unmark other primary emails
if ($email_primary) {
$sql = "update v_contact_emails set email_primary = 0 ";
$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;
$database->execute($sql, $parameters);
unset($sql, $parameters);
}
if ($action == "add" && permission_exists('contact_email_add')) {
$contact_email_uuid = uuid();
$array['contact_emails'][0]['contact_email_uuid'] = $contact_email_uuid;
message::add($text['message-add']);
}
if ($action == "update" && permission_exists('contact_email_edit')) {
$array['contact_emails'][0]['contact_email_uuid'] = $contact_email_uuid;
message::add($text['message-update']);
}
if (!empty($array)) {
$array['contact_emails'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
$array['contact_emails'][0]['contact_uuid'] = $contact_uuid;
$array['contact_emails'][0]['email_label'] = $email_label;
$array['contact_emails'][0]['email_address'] = $email_address;
$array['contact_emails'][0]['email_primary'] = $email_primary ? 1 : 0;
$array['contact_emails'][0]['email_description'] = $email_description;
$database = new database;
$database->app_name = 'contacts';
$database->app_uuid = '04481e0e-a478-c559-adad-52bd4174574c';
$database->save($array);
unset($array);
}
header("Location: contact_edit.php?id=".$contact_uuid);
exit;
}
}
//pre-populate the form
if (!empty($_GET) && empty($_POST["persistformvar"])) {
$contact_email_uuid = $_GET["id"] ?? '';
$sql = "select * from v_contact_emails ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and contact_email_uuid = :contact_email_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['contact_email_uuid'] = $contact_email_uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');;
if (!empty($row)) {
$email_label = $row["email_label"];
$email_address = $row["email_address"];
$email_primary = $row["email_primary"];
$email_description = $row["email_description"];
}
unset($sql, $parameters, $row);
}
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//show the header
if ($action == "update") {
$document['title'] = $text['title-contact_email-edit'];
}
else if ($action == "add") {
$document['title'] = $text['title-contact_email-add'];
}
require_once "resources/header.php";
//javascript to toggle input/select boxes
echo "<script type='text/javascript'>";
echo " function toggle_custom(field) {";
echo " $('#'+field).toggle();";
echo " document.getElementById(field).selectedIndex = 0;";
echo " document.getElementById(field+'_custom').value = '';";
echo " $('#'+field+'_custom').toggle();";
echo " if ($('#'+field+'_custom').is(':visible')) { $('#'+field+'_custom').trigger('focus'); } else { $('#'+field).trigger('focus'); }";
echo " }";
echo "</script>";
//show the content
echo "<form method='post' name='frm' id='frm'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'>";
if ($action == "update") {
echo "<b>".$text['header-contact_email-edit']."</b>";
}
else if ($action == "add") {
echo "<b>".$text['header-contact_email-add']."</b>";
}
echo " </div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'contact_edit.php?id='.urlencode($contact_uuid ?? '')]);
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
if ($action == "update") {
echo $text['description-contact_email-edit'];
}
else if ($action == "add") {
echo $text['description-contact_email-add'];
}
echo "<br /><br />\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-email_label']."\n";
echo "</td>\n";
echo "<td width='70%' class='vtable' align='left'>\n";
if (!empty($_SESSION["contact"]["email_label"])) {
sort($_SESSION["contact"]["email_label"]);
foreach($_SESSION["contact"]["email_label"] as $row) {
$email_label_options[] = "<option value='".$row."' ".(($row == $email_label) ? "selected='selected'" : null).">".$row."</option>";
}
$email_label_found = (in_array($email_label, $_SESSION["contact"]["email_label"])) ? true : false;
}
else {
$selected[$email_label] = "selected";
$default_labels[] = $text['option-work'];
$default_labels[] = $text['option-home'];
$default_labels[] = $text['option-other'];
foreach ($default_labels as $default_label) {
$email_label_options[] = "<option value='".$default_label."' ".!empty($selected[$default_label]).">".$default_label."</option>";
}
$email_label_found = (in_array($email_label, $default_labels)) ? true : false;
}
echo " <select class='formfld' ".((!empty($email_label) && !$email_label_found) ? "style='display: none;'" : null)." name='email_label' id='email_label' onchange=\"getElementById('email_label_custom').value='';\">\n";
echo " <option value=''></option>\n";
echo (!empty($email_label_options)) ? implode("\n", $email_label_options) : null;
echo " </select>\n";
echo " <input type='text' class='formfld' ".((empty($email_label) || $email_label_found) ? "style='display: none;'" : null)." name='email_label_custom' id='email_label_custom' value=\"".((!$email_label_found) ? htmlentities($email_label ?? '') : null)."\">\n";
echo " <input type='button' id='btn_toggle_label' class='btn' alt='".$text['button-back']."' value='&#9665;' onclick=\"toggle_custom('email_label');\">\n";
echo "<br />\n";
echo !empty($text['description-email_label'])."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-email_address']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='email_address' maxlength='255' value=\"".escape($email_address)."\">\n";
echo "<br />\n";
echo !empty($text['description-email_address'])."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-primary']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='email_primary' id='email_primary'>\n";
echo " <option value='0'>".$text['option-false']."</option>\n";
echo " <option value='1' ".(!empty($email_primary) && $email_primary ? "selected" : null).">".$text['option-true']."</option>\n";
echo " </select>\n";
echo "<br />\n";
echo $text['description-email_primary']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-email_description']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='email_description' maxlength='255' value=\"".escape($email_description)."\">\n";
echo "<br />\n";
echo !empty($text['description-email_description'])."\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>";
echo "<br><br>";
echo "<input type='hidden' name='contact_uuid' value='".escape($contact_uuid ?? '')."'>\n";
if ($action == "update") {
echo "<input type='hidden' name='contact_email_uuid' value='".escape($contact_email_uuid)."'>\n";
}
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>";
//include the footer
require_once "resources/footer.php";
?>
+112
View File
@@ -0,0 +1,112 @@
<?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-2024
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";
//check permissions
if (permission_exists('contact_email_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//set from session variables
$list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false';
//get the contact list
$sql = "select * from v_contact_emails ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and contact_uuid = :contact_uuid ";
$sql .= "order by email_primary desc, email_label asc ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['contact_uuid'] = $contact_uuid ?? '';
$database = new database;
$contact_emails = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//show if exists
if (!empty($contact_emails)) {
//show the content
echo "<div class='action_bar sub shrink'>\n";
echo " <div class='heading'><b>".$text['label-emails']."</b></div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo "<div class='card'>\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
if (permission_exists('contact_email_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all_emails' name='checkbox_all' onclick=\"edit_all_toggle('emails');\" ".(!empty($contact_emails) ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
}
echo "<th class='pct-15'>".$text['label-email_label']."</th>\n";
echo "<th>".$text['label-email_address']."</th>\n";
echo "<th class='hide-md-dn'>".$text['label-email_description']."</th>\n";
if (permission_exists('contact_email_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
if (!empty($contact_emails)) {
$x = 0;
foreach ($contact_emails as $row) {
if (permission_exists('contact_email_edit')) {
$list_row_url = "contact_email_edit.php?contact_uuid=".urlencode($row['contact_uuid'])."&id=".urlencode($row['contact_email_uuid']);
}
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('contact_email_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='contact_emails[$x][checked]' id='checkbox_".$x."' class='chk_delete checkbox_emails' value='true' onclick=\"edit_delete_action('emails');\">\n";
echo " <input type='hidden' name='contact_emails[$x][uuid]' value='".escape($row['contact_email_uuid'])."' />\n";
echo " </td>\n";
}
echo " <td>".escape($row['email_label'])." ".($row['email_primary'] ? "&nbsp;<i class='fas fa-star fa-xs' style='float: right; margin-top: 0.5em; margin-right: -0.5em;' title=\"".$text['label-primary']."\"></i>" : null)."</td>\n";
echo " <td class='no-link'><a href='mailto:".escape($row['email_address'])."'>".escape($row['email_address'])."</a>&nbsp;</td>\n";
echo " <td class='description overflow hide-md-dn'>".escape($row['email_description'])."&nbsp;</td>\n";
if (permission_exists('contact_email_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n";
}
echo "</tr>\n";
$x++;
}
}
unset($contact_emails);
echo "</table>";
echo "</div>\n";
echo "<br />\n";
}
?>
+68
View File
@@ -0,0 +1,68 @@
<?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-2020
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";
//check permissions
if (permission_exists('contact_email_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//get the contact list
$sql = "select * from v_contact_emails ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and contact_uuid = :contact_uuid ";
$sql .= "order by email_primary desc, email_label asc ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['contact_uuid'] = $contact_uuid ?? '';
$database = new database;
$contact_emails = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//show if exists
if (!empty($contact_emails)) {
//show the content
echo "<div class='grid' style='grid-template-columns: 70px auto;'>\n";
$x = 0;
foreach ($contact_emails as $row) {
echo "<div class='box contact-details-label'>".($row['email_label'] == strtolower($row['email_label'] ?? '') ? ucwords($row['email_label'] ?? '') : $row['email_label'])."</div>\n";
// ($row['email_primary'] ? "&nbsp;<i class='fas fa-star fa-xs' style='float: right; margin-top: 0.5em; margin-right: -0.5em;' title=\"".$text['label-primary']."\"></i>" : null)."</td>\n";
echo "<div class='box'><a href='mailto:".escape($row['email_address'])."'>".escape($row['email_address'])."</a></div>\n";
$x++;
}
echo "</div>\n";
unset($contact_emails);
}
?>
+111
View File
@@ -0,0 +1,111 @@
<?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-2024
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";
//check permissions
if (permission_exists('contact_extension_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//set from session variables
$list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false';
//get the extension list
$sql = "select e.extension_uuid, e.extension, e.enabled, e.description ";
$sql .= "from v_extensions e, v_extension_users eu, v_users u ";
$sql .= "where e.extension_uuid = eu.extension_uuid ";
$sql .= "and u.user_uuid = eu.user_uuid ";
$sql .= "and e.domain_uuid = :domain_uuid ";
$sql .= "and u.contact_uuid = :contact_uuid ";
$sql .= "order by e.extension asc ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['contact_uuid'] = $contact_uuid ?? '';
$database = new database;
$contact_extensions = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//show if exists
if (!empty($contact_extensions)) {
//show the content
echo "<div class='action_bar sub shrink'>\n";
echo " <div class='heading'><b>".$text['label-contact_extensions']."</b></div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo "<div class='card'>\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
echo "<th>".$text['label-extension']."</th>\n";
echo "<th class='center'>".$text['label-enabled']."</th>\n";
echo "<th class='hide-md-dn'>".$text['label-description']."</th>\n";
if (permission_exists('extension_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
if (!empty($contact_extensions)) {
$x = 0;
foreach ($contact_extensions as $row) {
if (permission_exists('extension_edit')) {
$list_row_url = PROJECT_PATH.'/app/extensions/extension_edit.php?id='.urlencode($row['extension_uuid']);
}
echo "<tr class='list-row' href='".$list_row_url."' ".($row['url_primary'] ? "style='font-weight: bold;'" : null).">\n";
echo " <td>";
if (permission_exists('extension_edit')) {
echo "<a href='".PROJECT_PATH."/app/extensions/extension_edit.php?id=".urlencode($row['extension_uuid'])."'>".escape($row['extension'])."</a>";
}
else {
echo $row['extension'];
}
echo " </td>\n";
echo " <td class='center'>".$text['label-'.escape($row['enabled'])]."&nbsp;</td>\n";
echo " <td class='description overflow hide-md-dn'>".$row['description']."&nbsp;</td>\n";
if (permission_exists('extension_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n";
}
echo "</tr>\n";
$x++;
}
}
unset($contact_extensions);
echo "</table>";
echo "</div>\n";
echo "<br />\n";
}
?>
+90
View File
@@ -0,0 +1,90 @@
<?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-2020
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";
//check permissions
if (permission_exists('contact_extension_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//get the extension list
$sql = "select e.extension_uuid, e.extension, e.enabled, e.description ";
$sql .= "from v_extensions e, v_extension_users eu, v_users u ";
$sql .= "where e.extension_uuid = eu.extension_uuid ";
$sql .= "and u.user_uuid = eu.user_uuid ";
$sql .= "and e.domain_uuid = :domain_uuid ";
$sql .= "and u.contact_uuid = :contact_uuid ";
$sql .= "order by e.extension asc ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['contact_uuid'] = $contact_uuid ?? '';
$database = new database;
$contact_extensions = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//show if exists
if (!empty($contact_extensions)) {
//javascript function: send_cmd
echo "<script type='text/javascript'>\n";
echo "function send_cmd(url) {\n";
echo " if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari\n";
echo " xmlhttp=new XMLHttpRequest();\n";
echo " }\n";
echo " else {// code for IE6, IE5\n";
echo " xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');\n";
echo " }\n";
echo " xmlhttp.open('GET',url,true);\n";
echo " xmlhttp.send(null);\n";
echo " document.getElementById('cmd_reponse').innerHTML=xmlhttp.responseText;\n";
echo "}\n";
echo "</script>\n";
//show the content
echo "<div class='grid' style='grid-template-columns: 70px 100px auto;'>\n";
$x = 0;
foreach ($contact_extensions as $row) {
if ($row['enabled'] != 'true') { continue; } //skip disabled extensions
echo "<div class='box contact-details-label'>".$text['label-extension']."</div>\n";
// ($row['url_primary'] ? "style='font-weight: bold;'" : null).">\n";
echo "<div class='box'>";
echo button::create(['type'=>'button','class'=>'link','label'=>escape($row['extension']),'title'=>$text['label-click_to_call'],'onclick'=>"send_cmd('".PROJECT_PATH."/app/click_to_call/click_to_call.php?src_cid_name=".urlencode($row['extension'])."&src_cid_number=".urlencode($row['extension'])."&dest_cid_name=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_name'])."&dest_cid_number=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_number'])."&src=".urlencode($_SESSION['user']['extension'][0]['user'])."&dest=".urlencode($row['extension'])."&rec=false&ringback=us-ring&auto_answer=true');"]);
echo "</div>\n";
echo "<div class='box'>".$row['description']."</div>\n";
$x++;
}
echo "</div>\n";
unset($contact_extensions);
}
?>
+535
View File
@@ -0,0 +1,535 @@
<?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-2024
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";
//check permissions
if (permission_exists('contact_add')) {
//access granted
}
else {
echo "access denied";
exit;
}
//connect to the database
$database = new database;
//add multi-lingual support
$language = new text;
$text = $language->get();
//built in str_getcsv requires PHP 5.3 or higher, this function can be used to reproduct the functionality but requirs PHP 5.1.0 or higher
if (!function_exists('str_getcsv')) {
function str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\") {
$fp = fopen("php://memory", 'r+');
fputs($fp, $input);
rewind($fp);
$data = fgetcsv($fp, null, $delimiter, $enclosure); // $escape only got added in 5.3.0
fclose($fp);
return $data;
}
}
//set the max php execution time
ini_set('max_execution_time', 7200);
//get the http get values and set them as php variables
$action = $_POST["action"] ?? '';
$from_row = $_POST["from_row"] ?? '';
$delimiter = $_POST["data_delimiter"] ?? '';
$enclosure = $_POST["data_enclosure"] ?? '';
//save the data to the csv file
if (isset($_POST['data'])) {
$file = $_SESSION['server']['temp']['dir']."/contacts-".$_SESSION['domain_name'].".csv";
file_put_contents($file, $_POST['data']);
$_SESSION['file'] = $file;
}
//copy the csv file
//$_POST['submit'] == "Upload" &&
if (!empty($_FILES['ulfile']['tmp_name']) && is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('contact_upload')) {
if ($_POST['type'] == 'csv') {
move_uploaded_file($_FILES['ulfile']['tmp_name'], $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name']);
$save_msg = "Uploaded file to ".$_SESSION['server']['temp']['dir']."/". htmlentities($_FILES['ulfile']['name']);
//system('chmod -R 744 '.$_SESSION['server']['temp']['dir'].'*');
$file = $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name'];
$_SESSION['file'] = $file;
}
}
//get the schema
if (!empty($delimiter)) {
//get the first line
$line = fgets(fopen($_SESSION['file'], 'r'));
$line_fields = explode($delimiter, $line);
//get the schema
$x = 0;
include "app/contacts/app_config.php";
$i = 0;
foreach ($apps[0]['db'] as $table) {
//get the table name and parent name
$table_name = $table["table"]['name'];
$parent_name = $table["table"]['parent'];
//remove the v_ table prefix
if (substr($table_name, 0, 2) == 'v_') {
$table_name = substr($table_name, 2);
}
if (substr($parent_name, 0, 2) == 'v_') {
$parent_name = substr($parent_name, 2);
}
//filter for specific tables and build the schema array
if ($table_name == "contacts" || $table_name == "contact_addresses" ||
$table_name == "contact_phones" || $table_name == "contact_emails" ||
$table_name == "contact_urls") {
$schema[$i]['table'] = $table_name;
$schema[$i]['parent'] = $parent_name;
foreach ($table['fields'] as $row) {
if (empty($row['deprecated']) || !empty($row['deprecated']) && $row['deprecated'] !== 'true') {
if (!empty($row['name']['text'])) {
$field_name = $row['name']['text'];
}
else {
$field_name = $row['name'];
}
$schema[$i]['fields'][] = $field_name;
}
}
$i++;
}
}
$schema[$i]['table'] = 'contact_groups';
$schema[$i]['parent'] = 'contacts';
$schema[$i]['fields'][] = 'group_name';
$i++;
$schema[$i]['table'] = 'contact_users';
$schema[$i]['parent'] = 'contacts';
$schema[$i]['fields'][] = 'username';
}
//match the column names to the field names
if (!empty($delimiter) && file_exists($_SESSION['file']) && $action != 'import') {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: contact_import.php');
exit;
}
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//include header
$document['title'] = $text['title-contacts_import'];
require_once "resources/header.php";
//form to match the fields to the column names
echo "<form name='frmUpload' method='post' enctype='multipart/form-data'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-contacts_import']."</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'contact_import.php']);
echo button::create(['type'=>'submit','label'=>$text['button-import'],'icon'=>$_SESSION['theme']['button_icon_import'],'id'=>'btn_save']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['description-contacts_import']."\n";
echo "<br /><br />\n";
echo "<div class='card'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
//define phone label options
if (!empty($_SESSION["contact"]["phone_label"])) {
sort($_SESSION["contact"]["phone_label"]);
foreach($_SESSION["contact"]["phone_label"] as $row) {
$label_options[] = "<option value='".$row.">".$row."</option>";
}
}
else {
$default_labels[] = $text['option-work'];
$default_labels[] = $text['option-home'];
$default_labels[] = $text['option-mobile'];
$default_labels[] = $text['option-main'];
$default_labels[] = $text['option-fax'];
$default_labels[] = $text['option-pager'];
$default_labels[] = $text['option-voicemail'];
$default_labels[] = $text['option-text'];
$default_labels[] = $text['option-other'];
foreach ($default_labels as $default_label) {
$label_options[] = "<option value='".$default_label."'>".$default_label."</option>";
}
}
//loop through user columns
$x = 0;
foreach ($line_fields as $line_field) {
$line_field = preg_replace('#[^a-zA-Z0-9_]#', '', $line_field);
echo "<tr>\n";
echo " <td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo $line_field;
echo " </td>\n";
echo " <td width='70%' class='vtable' align='left'>\n";
echo " <select class='formfld' style='' name='fields[$x]' onchange=\"document.getElementById('labels_$x').style.display = this.options[this.selectedIndex].value == 'contact_phones.phone_number' ? 'inline' : 'none';\">\n";
echo " <option value=''></option>\n";
foreach($schema as $row) {
echo " <optgroup label='".$row['table']."'>\n";
foreach($row['fields'] as $field) {
//if ($field == 'phone_label') { continue; }
//if ($field == 'contact_url') { continue; } // can remove this after field is removed from the table
$selected = '';
if ($field == $line_field) {
$selected = "selected='selected'";
}
if (substr($field, -5) != '_uuid') {
echo " <option value='".$row['table'].".".$field."' ".$selected.">".$field."</option>\n";
}
}
echo " </optgroup>\n";
}
echo " </select>\n";
//echo " <select class='formfld' style='display: none;' id='labels_$x' name='labels[$x]'>\n";
//echo is_array($label_options) ? implode("\n", $label_options) : null;
//echo " </select>\n";
echo " </td>\n";
echo "</tr>\n";
$x++;
}
echo "</table>\n";
echo "</div>\n";
echo "<br /><br />\n";
echo "<input name='action' type='hidden' value='import'>\n";
echo "<input name='from_row' type='hidden' value='$from_row'>\n";
echo "<input name='data_delimiter' type='hidden' value='$delimiter'>\n";
echo "<input name='data_enclosure' type='hidden' value='$enclosure'>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
require_once "resources/footer.php";
//normalize the column names
//$line = strtolower($line);
//$line = str_replace("-", "_", $line);
//$line = str_replace($delimiter."title".$delimiter, $delimiter."contact_title".$delimiter, $line);
//$line = str_replace("firstname", "name_given", $line);
//$line = str_replace("lastname", "name_family", $line);
//$line = str_replace("company", "organization", $line);
//$line = str_replace("company", "contact_email", $line);
//end the script
exit;
}
//get the parent table
function get_parent($schema,$table_name) {
foreach ($schema as $row) {
if ($row['table'] == $table_name) {
return $row['parent'];
}
}
}
//upload the csv
if (!empty($_SESSION['file']) && file_exists($_SESSION['file']) && $action == 'import') {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: contact_import.php');
exit;
}
//user selected fields, labels
$fields = $_POST['fields'] ?? [];
$labels = $_POST['labels'] ?? [];
//set the domain_uuid
$domain_uuid = $_SESSION['domain_uuid'];
//get the groups
$sql = "select * from v_groups where domain_uuid is null ";
$groups = $database->select($sql, null, 'all');
unset($sql);
//get the users
$sql = "select * from v_users where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
$users = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//get the contents of the csv file and convert them into an array
$handle = @fopen($_SESSION['file'], "r");
if ($handle) {
//set the starting identifiers
$row_id = 0;
$row_number = 1;
//loop through the array
while (($line = fgets($handle, 4096)) !== false) {
if ($from_row <= $row_number) {
//format the data
$y = 0;
foreach ($fields as $key => $value) {
//get the line
$result = str_getcsv($line, $delimiter, $enclosure);
//get the table and field name
$field_array = explode(".",$value);
$table_name = $field_array[0];
$field_name = $field_array[1];
//echo "value: $value<br />\n";
//echo "table_name: $table_name<br />\n";
//echo "field_name: $field_name<br />\n";
//get the parent table name
$parent = get_parent($schema, $table_name);
//count the field names
if (isset($field_count[$table_name][$field_name])) {
$field_count[$table_name][$field_name]++;
}
else {
$field_count[$table_name][$field_name] = 0;
}
//set the ordinal ID
$id = $field_count[$table_name][$field_name];
//remove formatting from the phone number
if ($field_name == "phone_number") {
$result[$key] = preg_replace('{(?!^\+)[\D]}', '', $result[$key]);
}
//build the data array
if (!empty($table_name)) {
if (empty($parent)) {
$array[$table_name][$row_id]['domain_uuid'] = $domain_uuid;
$array[$table_name][$row_id][$field_name] = $result[$key];
}
else {
if ($field_name != "username" && $field_name != "group_name") {
$array[$parent][$row_id][$table_name][$id]['domain_uuid'] = $domain_uuid;
$array[$parent][$row_id][$table_name][$id][$field_name] = $result[$key];
//if ($field_name == 'phone_number') {
// $array[$parent][$row_id][$table_name][$id]['phone_label'] = $labels[$key];
//}
}
}
if ($field_name == "group_name") {
foreach ($groups as $field) {
if ($field['group_name'] == $result[$key]) {
//$array[$parent][$row_id]['contact_group_uuid'] = uuid();
$array[$parent][$row_id]['contact_groups'][$id]['domain_uuid'] = $domain_uuid;
//$array['contact_groups'][$x]['contact_uuid'] = $row['contact_uuid'];
$array[$parent][$row_id]['contact_groups'][$id]['group_uuid'] = $field['group_uuid'];
}
}
}
if ($field_name == "username") {
foreach ($users as $field) {
if ($field['username'] == $result[$key]) {
//$array[$parent][$row_id]['contact_users'][$id]['contact_group_uuid'] = uuid();
$array[$parent][$row_id]['contact_users'][$id]['domain_uuid'] = $domain_uuid;
//$array['contact_groups'][$x]['contact_uuid'] = $row['contact_uuid'];
$array[$parent][$row_id]['contact_users'][$id]['user_uuid'] = $field['user_uuid'];
}
}
}
}
if (!empty($array[$parent][$row_id])) { $y++; }
}
//debug information
//view_array($field_count);
//process a chunk of the array
if ($row_id === 1000) {
//save to the data
$database->app_name = 'contacts';
$database->app_uuid = '04481e0e-a478-c559-adad-52bd4174574c';
$database->save($array);
//clear the array
unset($array);
//set the row id back to 0
$row_id = 0;
}
} //if ($from_row <= $row_number)
unset($field_count);
$row_number++;
$row_id++;
} //end while
fclose($handle);
//debug information
//view_array($array);
//save to the data
if (!empty($array)) {
$database->app_name = 'contacts';
$database->app_uuid = '04481e0e-a478-c559-adad-52bd4174574c';
$database->save($array);
unset($array);
}
//send the redirect header
header("Location: contacts.php");
exit;
}
}
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//include the header
$document['title'] = $text['title-contacts_import'];
require_once "resources/header.php";
//show content
echo "<form name='frmUpload' method='post' enctype='multipart/form-data'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-contacts_import']."</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'contacts.php']);
echo button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>$_SESSION['theme']['button_icon_upload'],'id'=>'btn_save']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['description-contacts_import']."\n";
echo "<br /><br />\n";
echo "<div class='card'>\n";
echo "<table border='0' cellpadding='0' cellspacing='0' width='100%'>\n";
echo "<tr>\n";
echo "<td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-import_data']."\n";
echo "</td>\n";
echo "<td width='70%' class='vtable' align='left'>\n";
echo " <textarea name='data' id='data' class='formfld' style='width: 100%; min-height: 150px;' wrap='off'></textarea>\n";
echo "<br />\n";
echo $text['description-import_data']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-from_row']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='from_row'>\n";
$i=2;
while($i<=99) {
$selected = ($i == $from_row) ? "selected" : null;
echo " <option value='$i' ".$selected.">$i</option>\n";
$i++;
}
echo " </select>\n";
echo "<br />\n";
echo $text['description-from_row']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-import_delimiter']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' style='width:40px;' name='data_delimiter'>\n";
echo " <option value=','>,</option>\n";
echo " <option value='|'>|</option>\n";
echo " </select>\n";
echo "<br />\n";
echo $text['description-import_delimiter']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-import_enclosure']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' style='width:40px;' name='data_enclosure'>\n";
echo " <option value='\"'>\"</option>\n";
echo " <option value=''></option>\n";
echo " </select>\n";
echo "<br />\n";
echo $text['description-import_enclosure']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-import_file_upload']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input name='ulfile' type='file' class='formfld fileinput' id='ulfile'>\n";
echo "<br />\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</div>\n";
echo "<br />\n";
if (function_exists('curl_version') && !empty($_SESSION['contact']['google_oauth_client_id']['text']) && !empty($_SESSION['contact']['google_oauth_client_secret']['text'])) {
echo "<a href='contact_import_google.php'><img src='resources/images/icon_gcontacts.png' style='width: 21px; height: 21px; border: none; text-decoration: none; margin-right: 5px;' align='absmiddle'>".$text['header-contacts_import_google']."</a>\n";
}
echo "<br />\n";
echo "<input name='type' type='hidden' value='csv'>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>";
//include the footer
require_once "resources/footer.php";
?>
+608
View File
@@ -0,0 +1,608 @@
<?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-2024
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";
require_once "resources/functions/google_get_groups.php";
require_once "resources/functions/google_get_contacts.php";
//check permissions
if (permission_exists('contact_add')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//handle import
if ($_POST['a'] == 'import') {
if (sizeof($_POST['group_id']) > 0) {
//get contact ids for those in the submitted groups
if (sizeof($_SESSION['contact_auth']['google']) > 0) {
foreach ($_SESSION['contact_auth']['google'] as $contact['id'] => $contact) {
foreach ($contact['groups'] as $contact_group['id'] => $meh) {
if (in_array($contact_group['id'], $_POST['group_id'])) {
$import_ids[] = $contact['id'];
}
}
}
}
}
if (sizeof($_POST['contact_id']) > 0) {
foreach ($_POST['contact_id'] as $contact_id) {
$import_ids[] = $contact_id;
}
}
//iterate selected contact ids, insert contact into database
$contacts_imported = 0;
$contacts_skipped = 0;
$contacts_replaced = 0;
if (sizeof($import_ids) > 0) {
$import_ids = array_unique($import_ids);
foreach ($import_ids as $index_1 => $contact_id) {
//check for duplicate contact (already exists, previously imported, etc)
$sql = "select contact_uuid from v_contact_settings ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and contact_setting_category = 'google' ";
$sql .= "and contact_setting_subcategory = 'id' ";
$sql .= "and contact_setting_value = :contact_setting_value ";
$sql .= "and contact_setting_enabled = 'true' ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['contact_setting_value'] = $contact_id;
$database = new database;
$result = $database->select($sql, $parameters, 'row');
if (is_uuid($result['contact_uuid'])) {
$duplicate_exists = true;
$duplicate_contact_uuid = $result['contact_uuid'];
}
else {
$duplicate_exists = false;
}
unset($sql, $parameters, $result);
//skip importing contact
if ($duplicate_exists && $_POST['import_duplicates'] == 'skip') {
$contacts_skipped++;
continue;
}
//replace contact (delete before inserts below)
else if ($duplicate_exists && $_POST['import_duplicates'] == 'replace') {
//build array
$array[0]['checked'] = 'true';
$array[0]['uuid'] = $duplicate_contact_uuid;
unset($duplicate_contact_uuid);
//grant temporary permissions
$p = new permissions;
$p->add('contact_delete', 'temp');
//delete duplicate contact
$obj = new contacts;
$obj->delete($array);
unset($array);
//revoke temporary permissions
$p->delete('contact_delete', 'temp');
//increase counter
$contacts_replaced++;
}
//extract contact record from array using contact id
$contact = $_SESSION['contact_auth']['google'][$contact_id];
//insert contact
$contact_uuid = uuid();
$array['contacts'][$index_1]['domain_uuid'] = $_SESSION['domain_uuid'];
$array['contacts'][$index_1]['contact_uuid'] = $contact_uuid;
$array['contacts'][$index_1]['contact_type'] = $_POST['import_type'];
$array['contacts'][$index_1]['contact_organization'] = $contact['organization'];
$array['contacts'][$index_1]['contact_name_prefix'] = $contact['name_prefix'];
$array['contacts'][$index_1]['contact_name_given'] = $contact['name_given'];
$array['contacts'][$index_1]['contact_name_middle'] = $contact['name_middle'];
$array['contacts'][$index_1]['contact_name_family'] = $contact['name_family'];
$array['contacts'][$index_1]['contact_name_suffix'] = $contact['name_suffix'];
$array['contacts'][$index_1]['contact_nickname'] = $contact['nickname'];
$array['contacts'][$index_1]['contact_title'] = $contact['title'];
$array['contacts'][$index_1]['contact_category'] = $_POST['import_category'];
$array['contacts'][$index_1]['contact_note'] = $contact['notes'];
//set sharing
if ($_POST['import_shared'] != 'true') {
$contact_group_uuid = uuid();
$array['contact_groups'][$index_1]['contact_group_uuid'] = $contact_group_uuid;
$array['contact_groups'][$index_1]['domain_uuid'] = $_SESSION['domain_uuid'];
$array['contact_groups'][$index_1]['contact_uuid'] = $contact_uuid;
$array['contact_groups'][$index_1]['group_uuid'] = $_SESSION["user_uuid"];
}
//insert emails
if (!empty($contact['emails']) && $_POST['import_fields']['email']) {
foreach ($contact['emails'] as $index_2 => $contact_email) {
$contact_email_uuid = uuid();
$array['contact_emails'][$index_2]['domain_uuid'] = $_SESSION['domain_uuid'];
$array['contact_emails'][$index_2]['contact_uuid'] = $contact_uuid;
$array['contact_emails'][$index_2]['contact_email_uuid'] = $contact_email_uuid;
$array['contact_emails'][$index_2]['email_label'] = $contact_email['label'];
$array['contact_emails'][$index_2]['email_address'] = $contact_email['address'];
$array['contact_emails'][$index_2]['email_primary'] = $contact_email['primary'] ? 1 : 0;
}
}
//insert numbers
if (!empty($contact['numbers']) && $_POST['import_fields']['number']) {
foreach ($contact['numbers'] as $index_3 => $contact_number) {
$contact_phone_uuid = uuid();
$array['contact_phones'][$index_3]['domain_uuid'] = $domain_uuid;
$array['contact_phones'][$index_3]['contact_uuid'] = $contact_uuid;
$array['contact_phones'][$index_3]['contact_phone_uuid'] = $contact_phone_uuid;
$array['contact_phones'][$index_3]['phone_type_voice'] = substr_count(strtoupper($contact_number['label']), strtoupper($text['label-fax'])) == 0 ? 1 : null;
$array['contact_phones'][$index_3]['phone_type_fax'] = substr_count(strtoupper($contact_number['label']), strtoupper($text['label-fax'])) != 0 ? 1 : null;
$array['contact_phones'][$index_3]['phone_label'] = $contact_number['label'];
$array['contact_phones'][$index_3]['phone_number'] = $contact_number['number'];
$array['contact_phones'][$index_3]['phone_primary'] = @sizeof($contact['numbers']) == 1 ? 1 : 0;
}
}
//insert urls
if (!empty($contact['urls']) && $_POST['import_fields']['url']) {
foreach ($contact['urls'] as $index_4 => $contact_url) {
$contact_url_uuid = uuid();
$array['contact_urls'][$index_4]['domain_uuid'] = $_SESSION['domain_uuid'];
$array['contact_urls'][$index_4]['contact_uuid'] = $contact_uuid;
$array['contact_urls'][$index_4]['contact_url_uuid'] = $contact_url_uuid;
$array['contact_urls'][$index_4]['url_label'] = $contact_url['label'];
$array['contact_urls'][$index_4]['url_address'] = $contact_url['url'];
$array['contact_urls'][$index_4]['url_primary'] = @sizeof($contact['urls']) == 1 ? 1 : 0;
}
}
//insert addresses
if (!empty($contact['addresses']) && $_POST['import_fields']['address']) {
foreach ($contact['addresses'] as $index_5 => $contact_address) {
$contact_address_uuid = uuid();
$array['contact_addresses'][$index_5]['domain_uuid'] = $_SESSION['domain_uuid'];
$array['contact_addresses'][$index_5]['contact_uuid'] = $contact_uuid;
$array['contact_addresses'][$index_5]['contact_address_uuid'] = $contact_address_uuid;
if (substr_count(strtoupper($contact_address['label']), strtoupper($text['option-home'])) != 0) {
$array['contact_addresses'][$index_5]['address_type'] = 'home';
}
else if (substr_count(strtoupper($contact_address['label']), strtoupper($text['option-work'])) != 0) {
$array['contact_addresses'][$index_5]['address_type'] = 'work';
}
else {
$array['contact_addresses'][$index_5]['address_type'] = null;
}
$array['contact_addresses'][$index_5]['address_label'] = $contact_address['label'];
$array['contact_addresses'][$index_5]['address_street'] = $contact_address['street'];
$array['contact_addresses'][$index_5]['address_extended'] = $contact_address['extended'];
$array['contact_addresses'][$index_5]['address_community'] = $contact_address['community'];
$array['contact_addresses'][$index_5]['address_locality'] = $contact_address['locality'];
$array['contact_addresses'][$index_5]['address_region'] = $contact_address['region'];
$array['contact_addresses'][$index_5]['address_postal_code'] = $contact_address['postal_code'];
$array['contact_addresses'][$index_5]['address_country'] = $contact_address['country'];
$array['contact_addresses'][$index_5]['address_primary'] = @sizeof($contact['addresses']) == 1 ? 1 : 0;
}
}
//add google contact id, etag and updated date to contact settings
$contact['updated'] = str_replace('T', ' ', $contact['updated']);
$contact['updated'] = str_replace('Z', '', $contact['updated']);
$contact_setting_columns = array('contact_setting_category', 'contact_setting_subcategory', 'contact_setting_name', 'contact_setting_value', 'contact_setting_order', 'contact_setting_enabled');
$contact_setting_array[] = array('sync', 'source', 'array', 'google', 0, 'true');
$contact_setting_array[] = array('google', 'id', 'text', $contact_id, 0, 'true');
$contact_setting_array[] = array('google', 'updated', 'date', $contact['updated'], 0, 'true');
$contact_setting_array[] = array('google', 'etag', 'text', $contact['etag'], 0, 'true');
foreach ($contact_setting_array as $index_6 => $values) {
$contact_setting_uuid = uuid();
$array['contact_settings'][$index_6]['contact_setting_uuid'] = $contact_setting_uuid;
$array['contact_settings'][$index_6]['contact_uuid'] = $contact_uuid;
$array['contact_settings'][$index_6]['domain_uuid'] = $_SESSION['domain_uuid'];
foreach ($values as $index_7 => $value) {
foreach ($contact_setting_columns as $column) {
$array['contact_settings'][$index_6][$contact_setting_columns[$index_7]] = $value;
}
}
}
unset($contact_setting_columns, $contact_setting_array);
//insert records
$database = new database;
$database->app_name = 'contacts';
$database->app_uuid = '04481e0e-a478-c559-adad-52bd4174574c';
$database->save($array);
unset($array);
//increment counter
$contacts_imported++;
}
$message = $text['message-contacts_imported']." ".$contacts_imported;
if ($contacts_replaced > 0) { $message .= " (".$text['message_contacts_imported_replaced']." ".$contacts_replaced.")"; }
if ($contacts_skipped > 0) { $message .= ", ".$text['message_contacts_imported_skipped']." ".$contacts_skipped; }
message::add($message);
header("Location: contacts.php");
exit;
}
else {
// no contacts imported
message::add($text['message-contacts_imported']." ".$contacts_imported, 'negative');
}
}
//*******************************************************************************************
//check if authenticated
if (empty($_SESSION['contact_auth']['token'])) {
$_SESSION['contact_auth']['referer'] = substr($_SERVER["HTTP_REFERER"], strrpos($_SERVER["HTTP_REFERER"],'/')+1);
header("Location: contact_auth.php?source=google&target=".substr($_SERVER["PHP_SELF"], strrpos($_SERVER["PHP_SELF"],'/')+1));
exit;
}
unset($_SESSION['contact_auth']['source'], $_SESSION['contact_auth']['target']);
//get groups & contacts
$groups = google_get_groups($_SESSION['contact_auth']['token']);
$contacts = google_get_contacts($_SESSION['contact_auth']['token'], 1000);
//store in session variable for use on import
$_SESSION['contact_auth']['google'] = $contacts;
//include the header
$document['title'] = $text['title-contacts_import_google'];
require_once "resources/header.php";
echo "<table cellpadding='0' cellspacing='0' border='0' align='right'>";
echo " <tr>";
echo " <td style='text-align: right;'>";
echo " <input type='button' class='btn' id='btn_back' onclick=\"document.location.href='contact_import.php';\" value=\"".$text['button-back']."\">";
echo " <input type='button' class='btn' id='btn_refresh' onclick='document.location.reload();' value=\"".$text['button-reload']."\">";
echo " <input type='button' class='btn' id='btn_signout' onclick=\"document.location.href='contact_auth.php?source=google&signout'\" value=\"".$text['button-sign_out']."\">";
echo " </td>";
echo " </tr>";
echo " <tr>";
echo " <td style='text-align: right; white-space: nowrap; padding-top: 8px;'><span style='font-weight: bold; color: #000;'>".$_SESSION['contact_auth']['name']."</a> (<a href='https://www.google.com/contacts/#contacts' target='_blank'>".$_SESSION['contact_auth']['email']."</a>)"."</td>";
echo " </tr>";
echo "</table>";
echo "<b>".$text['header-contacts_import_google']."</b>";
echo "<br><br>";
echo $text['description-contacts_import_google'];
echo "<br><br><br>";
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
echo "<form name='frm_import' id='frm_import' method='post'>\n";
echo "<input type='hidden' name='a' value='import'>\n";
echo "<div class='card'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-import_fields']."\n";
echo "</td>\n";
echo "<td width='70%' class='vtable' align='left'>\n";
echo " <input type='checkbox' disabled='disabled' checked>&nbsp;".$text['label-contact_name']."&nbsp;\n";
echo " <input type='checkbox' disabled='disabled' checked>&nbsp;".$text['label-contact_organization']."&nbsp;\n";
echo " <input type='checkbox' name='import_fields[email]' id='field_email' value='1' checked><label for='field_email'>&nbsp;".$text['label-contact_email']."</label>&nbsp;\n";
echo " <input type='checkbox' name='import_fields[number]' id='field_number' value='1' checked><label for='field_number'>&nbsp;".$text['label-phone_number']."</label>&nbsp;\n";
echo " <input type='checkbox' name='import_fields[url]' id='field_url' value='1' checked><label for='field_url'>&nbsp;".$text['label-contact_url']."</label>&nbsp;\n";
echo " <input type='checkbox' name='import_fields[address]' id='field_address' value='1' checked><label for='field_address'>&nbsp;".$text['label-address_address']."</label>\n";
echo "<br />\n";
echo $text['description-import_fields']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-contact_type']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
if (!empty($_SESSION["contact"]["type"])) {
sort($_SESSION["contact"]["type"]);
echo " <select class='formfld' name='import_type'>\n";
echo " <option value=''></option>\n";
foreach($_SESSION["contact"]["type"] as $row) {
echo " <option value='".$row."'>".$row."</option>\n";
}
echo " </select>\n";
}
else {
echo " <select class='formfld' name='import_type'>\n";
echo " <option value=''></option>\n";
echo " <option value='customer'>".$text['option-contact_type_customer']."</option>\n";
echo " <option value='contractor'>".$text['option-contact_type_contractor']."</option>\n";
echo " <option value='friend'>".$text['option-contact_type_friend']."</option>\n";
echo " <option value='lead'>".$text['option-contact_type_lead']."</option>\n";
echo " <option value='member'>".$text['option-contact_type_member']."</option>\n";
echo " <option value='family'>".$text['option-contact_type_family']."</option>\n";
echo " <option value='subscriber'>".$text['option-contact_type_subscriber']."</option>\n";
echo " <option value='supplier'>".$text['option-contact_type_supplier']."</option>\n";
echo " <option value='provider'>".$text['option-contact_type_provider']."</option>\n";
echo " <option value='user'>".$text['option-contact_type_user']."</option>\n";
echo " <option value='volunteer'>".$text['option-contact_type_volunteer']."</option>\n";
echo " </select>\n";
}
echo "<br />\n";
echo $text['description-contact_type_import']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-contact_category']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
if (!empty($_SESSION["contact"]["category"])) {
sort($_SESSION["contact"]["category"]);
echo " <select class='formfld' name='import_category'>\n";
echo " <option value=''></option>\n";
foreach($_SESSION["contact"]["category"] as $row) {
echo " <option value='".$row."'>".$row."</option>\n";
}
echo " </select>\n";
}
else {
echo " <input class='formfld' type='text' name='import_category' maxlength='255'>\n";
}
echo "<br />\n";
echo $text['description-contact_category_import']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-shared']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='import_shared' id='import_shared'>\n";
echo " <option value='false'>".$text['option-false']."</option>\n";
echo " <option value='true'>".$text['option-true']."</option>\n";
echo " </select>\n";
echo " <br />\n";
echo $text['description-shared_import']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-import_duplicates']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' style='width: 150px;' name='import_duplicates'>\n";
echo " <option value='skip'>".$text['option-import_duplicates_skip']."</option>\n";
echo " <option value='replace'>".$text['option-import_duplicates_replace']."</option>\n";
echo " </select>\n";
echo "<br />\n";
echo $text['description-import_duplicates']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>";
echo "<br><br>";
//display groups
echo "<b>".$text['label-groups']."</b>";
echo "<br><br>";
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo " <th style='width: 30px; text-align: center; padding: 0px;'>&nbsp;</th>";
echo " <th>".$text['label-contact_name']."</th>\n";
echo "</tr>\n";
//determine contact count in groups
foreach ($contacts as $contact) {
foreach ($contact['groups'] as $group_id => $meh) {
$groups[$group_id]['count']++;
}
}
$c = 0;
foreach ($groups as $group['id'] => $group) {
if ($group['count'] > 0) {
echo "<tr>\n";
echo " <td valign='top' class='".$row_style[$c]."' style='text-align: center; padding: 3px 0px 0px 0px;'><input type='checkbox' name='group_id[]' id='group_id_".$group['id']."' value='".$group['id']."'></td>\n";
echo " <td valign='top' class='".$row_style[$c]."' onclick=\"document.getElementById('group_id_".$group['id']."').checked = (document.getElementById('group_id_".$group['id']."').checked) ? false : true;\">".$group['name']." (".$group['count'].")</td>\n";
echo "</tr>\n";
$c=($c)?0:1;
}
}
echo "</table>\n";
echo "<br>";
echo "<div style='text-align: right;'><input type='submit' class='btn' id='btn_submit' value=\"".$text['button-import']."\"></div>";
echo "<br>";
//display contacts
echo "<b>".$text['header-contacts']."</b>";
echo "<br><br>";
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo " <th style='width: 30px; text-align: center; padding: 0px;'><input type='checkbox' onchange=\"(this.checked) ? check('all') : check('none');\"></th>";
echo " <th>".$text['label-contact_name']."</th>\n";
echo " <th>".$text['label-contact_organization']."</th>\n";
echo " <th>".$text['label-contact_email']."</th>\n";
echo " <th>".$text['label-phone_number']."</th>\n";
echo " <th>".$text['label-contact_url']."</th>\n";
echo " <th>".$text['label-address_address']."</th>\n";
echo " <th>".$text['label-group']."</th>\n";
echo "</tr>\n";
$c = 0;
foreach ($contacts as $contact['id'] => $contact) {
$contact_ids[] = $contact['id'];
echo "<tr>\n";
echo " <td valign='top' class='".$row_style[$c]."' style='text-align: center; padding: 3px 0px 0px 0px;'><input type='checkbox' name='contact_id[]' id='contact_id_".$contact['id']."' value='".$contact['id']."'></td>\n";
echo " <td valign='top' class='".$row_style[$c]."' onclick=\"document.getElementById('contact_id_".$contact['id']."').checked = (document.getElementById('contact_id_".$contact['id']."').checked) ? false : true;\">";
$contact_name[] = $contact['name_prefix'];
$contact_name[] = $contact['name_given'];
$contact_name[] = $contact['name_middle'];
$contact_name[] = $contact['name_family'];
$contact_name[] = $contact['name_suffix'];
echo " ".implode(' ', $contact_name)."&nbsp;";
unset($contact_name);
echo " </td>\n";
echo " <td valign='top' class='".$row_style[$c]."' style='max-width: 50px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;'>";
echo " ".(($contact['title']) ? $contact['title']."<br>" : null).$contact['organization']."&nbsp;";
echo " </td>\n";
echo " <td valign='top' class='".$row_style[$c]."' style='width: 15%; max-width: 50px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;'>";
if (sizeof($contact['emails']) > 0) {
foreach ($contact['emails'] as $contact_email) {
$contact_emails[] = "<span style='font-size: 80%;'>".$contact_email['label'].":</span> <a href='mailto: ".$contact_email['address']."'>".$contact_email['address']."</a>";
}
echo implode('<br>', $contact_emails);
unset($contact_emails);
} else { echo "&nbsp;"; }
echo " </td>\n";
echo " <td valign='top' class='".$row_style[$c]."' style='width: 15%; max-width: 50px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;'>";
if (sizeof($contact['numbers']) > 0) {
foreach ($contact['numbers'] as $contact_number) {
$contact_number_part = "<span style='font-size: 80%;'>".$contact_number['label'].":</span> ";
if (substr_count(strtoupper($contact_number['label']), 'FAX') == 0) {
$contact_number_part .= "<a href='javascript:void(0);' onclick=\"send_cmd('".PROJECT_PATH."/app/click_to_call/click_to_call.php?src_cid_name=".urlencode($contact_number['number'])."&src_cid_number=".urlencode($contact_number['number'])."&dest_cid_name=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_name'])."&dest_cid_number=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_number'])."&src=".urlencode($_SESSION['user']['extension'][0]['user'])."&dest=".urlencode($contact_number['number'])."&rec=false&ringback=us-ring&auto_answer=true');\">";
}
$contact_number_part .= format_phone($contact_number['number']);
if (substr_count(strtoupper($contact_number['label']), 'FAX') == 0) {
$contact_number_part .= "</a>";
}
$contact_numbers[] = $contact_number_part;
unset($contact_number_part);
}
echo implode('<br>', $contact_numbers);
unset($contact_numbers);
} else { echo "&nbsp;"; }
echo " </td>\n";
echo " <td valign='top' class='".$row_style[$c]."' style='width: 15%; max-width: 50px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;'>";
if (sizeof($contact['urls']) > 0) {
foreach ($contact['urls'] as $contact_url) {
$contact_urls[] = "<span style='font-size: 80%;'>".$contact_url['label'].":</span> <a href='".$contact_url['url']."' target='_blank'>".str_replace("http://", "", str_replace("https://", "", $contact_url['url']))."</a>";
}
echo implode('<br>', $contact_urls);
unset($contact_urls);
} else { echo "&nbsp;"; }
echo " </td>\n";
echo " <td valign='top' class='".$row_style[$c]."' style='width: 15%; max-width: 50px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;'>";
if (sizeof($contact['addresses']) > 0) {
foreach ($contact['addresses'] as $contact_address) {
if ($contact_address['street'] != '') { $contact_address_parts[] = $contact_address['street']; }
if ($contact_address['extended'] != '') { $contact_address_parts[] = $contact_address['extended']; }
if ($contact_address['community'] != '') { $contact_address_parts[] = $contact_address['community']; }
if ($contact_address['locality'] != '') { $contact_address_parts[] = $contact_address['locality']; }
if ($contact_address['region'] != '') { $contact_address_parts[] = $contact_address['region']; }
if ($contact_address['postal_code'] != '') { $contact_address_parts[] = $contact_address['postal_code']; }
if ($contact_address['country'] != '') { $contact_address_parts[] = $contact_address['country']; }
$contact_addresses[] = "<span style='font-size: 80%;'>".$contact_address['label'].":</span> ".implode(', ', $contact_address_parts);
unset($contact_address_parts);
}
echo implode('<br>', $contact_addresses);
unset($contact_addresses);
} else { echo "&nbsp;"; }
echo " </td>\n";
echo " <td valign='top' class='".$row_style[$c]."' style='white-space: nowrap;'>";
foreach ($contact['groups'] as $contact_group['id'] => $contact_group['name']) {
$contact_groups[] = $contact_group['name'];
}
echo " ".implode('<br>', $contact_groups);
unset($contact_groups);
echo " </td>\n";
echo "</tr>\n";
$c=($c)?0:1;
}
echo "</table>\n";
echo "</div>\n";
echo "<br>";
echo "<div style='text-align: right;'><input type='submit' class='btn' id='btn_submit' value=\"".$text['button-import']."\"></div>";
echo "</form>";
echo "<br><br>";
// check or uncheck all contact checkboxes
if (sizeof($contact_ids) > 0) {
echo "<script>\n";
echo " function check(what) {\n";
foreach ($contact_ids as $contact_id) {
echo " document.getElementById('contact_id_".$contact_id."').checked = (what == 'all') ? true : false;\n";
}
echo " }\n";
echo "</script>\n";
}
/*
echo "<pre>";
print_r($contacts);
echo "</pre>";
echo "<br><br>";
echo "<hr>";
echo "<br><br><b>SOURCE JSON DECODED ARRAY</b>...<br><br><pre>";
print_r($records);
echo "</pre>";
*/
//include the footer
require_once "resources/footer.php";
// used above
function curl_file_get_contents($url) {
$curl = curl_init();
$userAgent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)';
curl_setopt($curl, CURLOPT_URL, $url); //The URL to retrieve. This can also be set when initializing a session with curl_init().
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); //TRUE to return the transfer as a string of the return value of curl_exec() instead of outputting it out directly.
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5); //The number of seconds to wait while trying to connect.
curl_setopt($curl, CURLOPT_USERAGENT, $userAgent); //The contents of the "User-Agent: " header to be used in a HTTP request.
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE); //To follow any "Location: " header that the server sends as part of the HTTP header.
curl_setopt($curl, CURLOPT_AUTOREFERER, TRUE); //To automatically set the Referer: field in requests where it follows a Location: redirect.
curl_setopt($curl, CURLOPT_TIMEOUT, 10); //The maximum number of seconds to allow cURL functions to execute.
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); //To stop cURL from verifying the peer's certificate.
$contents = curl_exec($curl);
curl_close($curl);
return $contents;
}
?>
+170
View File
@@ -0,0 +1,170 @@
<?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) 2022
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";
//check permissions
if (permission_exists('contact_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//set additional variables
$show = $_GET["show"] ?? '';
//retrieve current user's assigned groups (uuids)
foreach ($_SESSION['groups'] as $group_data) {
$user_group_uuids[] = $group_data['group_uuid'];
}
//add user's uuid to group uuid list to include private (non-shared) contacts
$user_group_uuids[] = $_SESSION["user_uuid"];
//add the search term
if (!empty($_GET["search"])) {
$search = strtolower($_GET["search"]);
}
//get the list of contacts
$sql = "select *, ";
$sql .= "( ";
$sql .= " select a.contact_attachment_uuid from v_contact_attachments as a ";
$sql .= " where a.contact_uuid = c.contact_uuid and a.attachment_primary = 1 ";
$sql .= ") as contact_attachment_uuid ";
$sql .= "from v_contacts as c ";
$sql .= "where true ";
if ($show != "all" || !permission_exists('contact_all')) {
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
}
if (!permission_exists('contact_domain_view')) {
$sql .= "and ( "; //only contacts assigned to current user's group(s) and those not assigned to any group
$sql .= " contact_uuid in ( ";
$sql .= " select contact_uuid from v_contact_groups ";
$sql .= " where ";
if (!empty($user_group_uuids)) {
foreach ($user_group_uuids as $index => $user_group_uuid) {
if (is_uuid($user_group_uuid)) {
$sql_where_or[] = "group_uuid = :group_uuid_".$index;
$parameters['group_uuid_'.$index] = $user_group_uuid;
}
}
if (!empty($sql_where_or)) {
$sql .= " ( ".implode(' or ', $sql_where_or)." ) ";
}
unset($sql_where_or, $index, $user_group_uuid);
}
$sql .= " and domain_uuid = :domain_uuid ";
$sql .= " ) ";
$sql .= " or contact_uuid in ( ";
$sql .= " select contact_uuid from v_contact_users ";
$sql .= " where user_uuid = :user_uuid ";
$sql .= " and domain_uuid = :domain_uuid ";
$sql .= "";
$sql .= " ) ";
$sql .= ") ";
$parameters['user_uuid'] = $_SESSION['user_uuid'];
}
if (isset($search)) {
if (is_numeric($search)) {
$sql .= "and contact_uuid in ( ";
$sql .= " select contact_uuid from v_contact_phones ";
$sql .= " where phone_number like :search ";
$sql .= ") ";
}
else {
//open container
$sql .= "and ( ";
//search contact
$sql .= "contact_uuid in ( ";
$sql .= " select contact_uuid from v_contacts ";
$sql .= " where domain_uuid = :domain_uuid ";
$sql .= " and ( ";
$sql .= " lower(contact_organization) like :search or ";
$sql .= " lower(contact_name_given) like :search or ";
$sql .= " lower(contact_name_family) like :search or ";
$sql .= " lower(contact_nickname) like :search or ";
$sql .= " lower(contact_title) like :search or ";
$sql .= " lower(contact_category) like :search or ";
$sql .= " lower(contact_role) like :search or ";
$sql .= " lower(contact_url) like :search or ";
$sql .= " lower(contact_time_zone) like :search or ";
$sql .= " lower(contact_note) like :search or ";
$sql .= " lower(contact_type) like :search ";
$sql .= " ) ";
$sql .= ") ";
//search contact emails
if (permission_exists('contact_email_view')) {
$sql .= "or contact_uuid in ( ";
$sql .= " select contact_uuid from v_contact_emails ";
$sql .= " where domain_uuid = :domain_uuid ";
$sql .= " and ( ";
$sql .= " lower(email_address) like :search or ";
$sql .= " lower(email_description) like :search ";
$sql .= " ) ";
$sql .= ") ";
}
//search contact notes
if (permission_exists('contact_note_view')) {
$sql .= "or contact_uuid in ( ";
$sql .= " select contact_uuid from v_contact_notes ";
$sql .= " where domain_uuid = :domain_uuid ";
$sql .= " and lower(contact_note) like :search ";
$sql .= ") ";
}
//close container
$sql .= ") ";
}
$parameters['search'] = '%'.$search.'%';
}
$sql .= "order by contact_organization asc ";
$sql .= "limit 300 ";
$database = new database;
$contact_array = $database->select($sql, $parameters ?? null, 'all');
unset($sql, $parameters);
//return the contacts as json
$i = 0;
if (!empty($contact_array)) {
foreach($contact_array as $row) {
$contact_name = array();
if (!empty($row['contact_organization'])) { $contact_name[] = $row['contact_organization']; }
if (!empty($row['contact_name_family'])) { $contact_name[] = $row['contact_name_family']; }
if (!empty($row['contact_name_given'])) { $contact_name[] = $row['contact_name_given']; }
if (empty($row['contact_name_family']) && empty($row['contact_name_given']) && !empty($row['contact_nickname'])) { $contact_name[] = $row['contact_nickname']; }
$contacts[$i]['id'] = $row['contact_uuid'];
$contacts[$i]['name'] = implode(', ', $contact_name);
$i++;
}
echo json_encode($contacts, true);
}
?>
+230
View File
@@ -0,0 +1,230 @@
<?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-2024
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";
//check permissions
if (permission_exists('contact_note_edit') || permission_exists('contact_note_add')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//action add or update
if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
$action = "update";
$contact_note_uuid = $_REQUEST["id"];
}
else {
$action = "add";
}
//get the primary id for the contact
if (!empty($_GET["contact_uuid"]) && is_uuid($_GET["contact_uuid"])) {
$contact_uuid = $_GET["contact_uuid"];
}
//get http post variables and set them to php variables
if (!empty($_POST)) {
$contact_note = $_POST["contact_note"];
$last_mod_date = $_POST["last_mod_date"] ?? null;
$last_mod_user = $_POST["last_mod_user"] ?? null;
}
//process the form data
if (!empty($_POST) && empty($_POST["persistformvar"])) {
//get the primary id for the contact note
if ($action == "update") {
$contact_note_uuid = $_POST["contact_note_uuid"];
}
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: contacts.php');
exit;
}
//check for all required data
$msg = '';
if (!empty($msg) && empty($_POST["persistformvar"])) {
require_once "resources/header.php";
require_once "resources/persist_form_var.php";
echo "<div align='center'>\n";
echo "<table><tr><td>\n";
echo $msg."<br />";
echo "</td></tr></table>\n";
persistformvar($_POST);
echo "</div>\n";
require_once "resources/footer.php";
return;
}
//add or update the database
if (empty($_POST["persistformvar"])) {
//update last modified
$array['contacts'][0]['contact_uuid'] = $contact_uuid;
$array['contacts'][0]['domain_uuid'] = $domain_uuid;
$array['contacts'][0]['last_mod_date'] = 'now()';
$array['contacts'][0]['last_mod_user'] = $_SESSION['username'];
$p = new permissions;
$p->add('contact_edit', 'temp');
$database = new database;
$database->app_name = 'contacts';
$database->app_uuid = '04481e0e-a478-c559-adad-52bd4174574c';
$database->save($array);
unset($array);
$p->delete('contact_edit', 'temp');
//add the note
if ($action == "add" && permission_exists('contact_note_add')) {
$contact_note_uuid = uuid();
$array['contact_notes'][0]['contact_note_uuid'] = $contact_note_uuid;
message::add($text['message-add']);
}
//update the note
if ($action == "update" && permission_exists('contact_note_edit')) {
$array['contact_notes'][0]['contact_note_uuid'] = $contact_note_uuid;
message::add($text['message-update']);
}
//execute
if (!empty($array)) {
$array['contact_notes'][0]['contact_uuid'] = $contact_uuid;
$array['contact_notes'][0]['domain_uuid'] = $domain_uuid;
$array['contact_notes'][0]['contact_note'] = $contact_note;
$array['contact_notes'][0]['last_mod_date'] = 'now()';
$array['contact_notes'][0]['last_mod_user'] = $_SESSION['username'];
$database = new database;
$database->app_name = 'contacts';
$database->app_uuid = '04481e0e-a478-c559-adad-52bd4174574c';
$database->save($array);
unset($array);
}
//redirect
header("Location: contact_edit.php?id=".escape($contact_uuid));
exit;
}
}
//pre-populate the form
if (!empty($_GET) && empty($_POST["persistformvar"])) {
$contact_note_uuid = $_GET["id"] ?? '';
$sql = "select * from v_contact_notes ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and contact_note_uuid = :contact_note_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['contact_note_uuid'] = $contact_note_uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (!empty($row)) {
$contact_note = $row["contact_note"];
$last_mod_date = $row["last_mod_date"];
$last_mod_user = $row["last_mod_user"];
}
unset($sql, $parameters, $row);
}
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//show the header
if ($action == "update") {
$document['title'] = $text['title-contact_notes-edit'];
}
else if ($action == "add") {
$document['title'] = $text['title-contact_notes-add'];
}
require_once "resources/header.php";
//show the content
echo "<form method='post' name='frm'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'>";
if ($action == "update") {
echo "<b>".$text['header-contact_notes-edit']."</b>";
}
else if ($action == "add") {
echo "<b>".$text['header-contact_notes-add']."</b>";
}
echo " </div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'contact_edit.php?id='.urlencode($contact_uuid)]);
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo "<div class='card'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-contact_note']."\n";
echo "</td>\n";
echo "<td width='70%' class='vtable' align='left'>\n";
echo " <textarea class='formfld' name='contact_note' style='min-width: 100%; height: 400px;'>".escape($contact_note ?? '')."</textarea>\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>";
echo "</div>\n";
echo "<br><br>";
echo "<input type='hidden' name='contact_uuid' value='".escape($contact_uuid)."'>\n";
if ($action == "update") {
echo "<input type='hidden' name='contact_note_uuid' value='".escape($contact_note_uuid)."'>\n";
}
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>";
//include the footer
require_once "resources/footer.php";
?>
+114
View File
@@ -0,0 +1,114 @@
<?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-2024
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";
//check permissions
if (permission_exists('contact_note_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//set the uuid
if (!empty($_GET['id']) && is_uuid($_GET['id'])) {
$contact_uuid = $_GET['id'];
}
//get the contact list
$sql = "select * from v_contact_notes ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and contact_uuid = :contact_uuid ";
$sql .= "order by last_mod_date desc ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['contact_uuid'] = $contact_uuid ?? '';
$database = new database;
$contact_notes = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//show if exists
if (!empty($contact_notes)) {
//show the content
echo "<div class='action_bar sub shrink'>\n";
echo " <div class='heading'><b>".$text['label-contact_notes']."</b></div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo "<div class='card'>\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
if (permission_exists('contact_note_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all_notes' name='checkbox_all' onclick=\"edit_all_toggle('notes');\" ".(!empty($contact_notes) ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
}
echo "<th>".$text['label-note_content']."</th>\n";
echo "<th class='shrink'>".$text['label-note_user']."</th>\n";
if (permission_exists('contact_note_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
if (!empty($contact_notes)) {
foreach ($contact_notes as $row) {
$contact_note = $row['contact_note'];
$contact_note = escape($contact_note);
$contact_note = str_replace("\n","<br />",$contact_note);
if (permission_exists('contact_note_add')) {
$list_row_url = "contact_note_edit.php?contact_uuid=".escape($row['contact_uuid'])."&id=".escape($row['contact_note_uuid']);
}
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('contact_note_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='contact_notes[$x][checked]' id='checkbox_".$x."' class='chk_delete checkbox_notes' value='true' onclick=\"edit_delete_action('notes');\">\n";
echo " <input type='hidden' name='contact_notes[$x][uuid]' value='".escape($row['contact_note_uuid'])."' />\n";
echo " </td>\n";
}
echo " <td class='overflow'>".$contact_note."</td>\n";
echo " <td class='description no-wrap'><strong>".escape($row['last_mod_user'])."</strong>: ".date("j M Y @ H:i:s", strtotime($row['last_mod_date']))."</td>\n";
if (permission_exists('contact_note_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n";
}
echo "</tr>\n";
$x++;
}
}
unset($contact_notes);
echo "</table>";
echo "</div>\n";
echo "<br />\n";
}
?>
+68
View File
@@ -0,0 +1,68 @@
<?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-2020
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";
//check permissions
if (permission_exists('contact_note_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//get the contact list
$sql = "select * from v_contact_notes ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and contact_uuid = :contact_uuid ";
$sql .= "order by last_mod_date desc ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['contact_uuid'] = $contact_uuid ?? '';
$database = new database;
$contact_notes = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//show if exists
if (!empty($contact_notes)) {
//show the content
echo "<div class='grid' style='grid-template-columns: auto 190px;'>\n";
$x = 0;
foreach ($contact_notes as $row) {
$contact_note = str_replace("\n","<br />",escape($row['contact_note']));
echo "<div class='box' style='padding-bottom: 15px;'>".$contact_note."</div>\n";
echo "<div class='box contact-details-label' style='padding-bottom: 15px; text-align: right;'><strong>".escape($row['last_mod_user'])."</strong>: ".date("j M Y @ H:i:s", strtotime($row['last_mod_date']))."</div>\n";
$x++;
}
echo "</div>\n";
unset($contact_notes);
}
?>
+412
View File
@@ -0,0 +1,412 @@
<?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-2024
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('contact_phone_edit') || permission_exists('contact_phone_add')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//set the defaults
$phone_label = '';
$phone_label_custom = '';
$phone_type_voice = '';
$phone_type_fax = '';
$phone_type_video = '';
$phone_type_text = '';
$phone_speed_dial = '';
$phone_country_code = '';
$phone_number = '';
$phone_extension = '';
$phone_primary = '';
$phone_description = '';
//action add or update
if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
$action = "update";
$contact_phone_uuid = $_REQUEST["id"];
}
else {
$action = "add";
}
//get the uuid
if (!empty($_GET["contact_uuid"]) && is_uuid($_GET["contact_uuid"])) {
$contact_uuid = $_GET["contact_uuid"];
}
//get http post variables and set them to php variables
if (!empty($_POST)) {
$phone_label = $_POST["phone_label"];
$phone_label_custom = $_POST["phone_label_custom"];
$phone_type_voice = $_POST["phone_type_voice"] ?? null;
$phone_type_fax = $_POST["phone_type_fax"] ?? null;
$phone_type_video = $_POST["phone_type_video"] ?? null;
$phone_type_text = $_POST["phone_type_text"] ?? null;
$phone_speed_dial = $_POST["phone_speed_dial"];
$phone_country_code = $_POST["phone_country_code"];
$phone_number = $_POST["phone_number"];
$phone_extension = $_POST["phone_extension"];
$phone_primary = $_POST["phone_primary"];
$phone_description = $_POST["phone_description"];
//remove any phone number formatting
$phone_number = preg_replace('{(?!^\+)[\D]}', '', $phone_number);
//use custom label if set
$phone_label = ($phone_label_custom != '') ? $phone_label_custom : $phone_label;
}
//process the form data
if (!empty($_POST) && empty($_POST["persistformvar"])) {
//set thge uuid
if ($action == "update") {
$contact_phone_uuid = $_POST["contact_phone_uuid"];
}
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: contacts.php');
exit;
}
//check for all required data
$msg = '';
if (!empty($msg) && empty($_POST["persistformvar"])) {
require_once "resources/header.php";
require_once "resources/persist_form_var.php";
echo "<div align='center'>\n";
echo "<table><tr><td>\n";
echo $msg."<br />";
echo "</td></tr></table>\n";
persistformvar($_POST);
echo "</div>\n";
require_once "resources/footer.php";
return;
}
//add or update the database
if (empty($_POST["persistformvar"])) {
//update last modified
$array['contacts'][0]['contact_uuid'] = $contact_uuid;
$array['contacts'][0]['domain_uuid'] = $domain_uuid;
$array['contacts'][0]['last_mod_date'] = 'now()';
$array['contacts'][0]['last_mod_user'] = $_SESSION['username'];
$p = new permissions;
$p->add('contact_edit', 'temp');
$database = new database;
$database->app_name = 'contacts';
$database->app_uuid = '04481e0e-a478-c559-adad-52bd4174574c';
$database->save($array);
unset($array);
$p->delete('contact_edit', 'temp');
//if primary, unmark other primary numbers
if ($phone_primary) {
$sql = "update v_contact_phones set phone_primary = 0 ";
$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;
$database->execute($sql, $parameters);
unset($sql, $parameters);
}
//add the phone
if ($action == "add" && permission_exists('contact_phone_add')) {
$contact_phone_uuid = uuid();
$array['contact_phones'][0]['contact_phone_uuid'] = $contact_phone_uuid;
message::add($text['message-add']);
}
//update the phone
if ($action == "update" && permission_exists('contact_phone_edit')) {
$array['contact_phones'][0]['contact_phone_uuid'] = $contact_phone_uuid;
message::add($text['message-update']);
}
//execute
if (!empty($array)) {
$array['contact_phones'][0]['contact_uuid'] = $contact_uuid;
$array['contact_phones'][0]['domain_uuid'] = $domain_uuid;
$array['contact_phones'][0]['phone_label'] = $phone_label;
$array['contact_phones'][0]['phone_type_voice'] = $phone_type_voice ? 1 : null;
$array['contact_phones'][0]['phone_type_fax'] = $phone_type_fax ? 1 : null;
$array['contact_phones'][0]['phone_type_video'] = $phone_type_video ? 1 : null;
$array['contact_phones'][0]['phone_type_text'] = $phone_type_text ? 1 : null;
$array['contact_phones'][0]['phone_speed_dial'] = $phone_speed_dial;
$array['contact_phones'][0]['phone_country_code'] = $phone_country_code;
$array['contact_phones'][0]['phone_number'] = $phone_number;
$array['contact_phones'][0]['phone_extension'] = $phone_extension;
$array['contact_phones'][0]['phone_primary'] = $phone_primary ? 1 : 0;
$array['contact_phones'][0]['phone_description'] = $phone_description;
$database = new database;
$database->app_name = 'contacts';
$database->app_uuid = '04481e0e-a478-c559-adad-52bd4174574c';
$database->save($array);
unset($array);
}
//redirect
header("Location: contact_edit.php?id=".escape($contact_uuid));
exit;
}
}
//pre-populate the form
if (!empty($_GET) && empty($_POST["persistformvar"])) {
$contact_phone_uuid = $_GET["id"] ?? '';
$sql = "select * from v_contact_phones ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and contact_phone_uuid = :contact_phone_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['contact_phone_uuid'] = $contact_phone_uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (!empty($row)) {
$phone_label = $row["phone_label"];
$phone_type_voice = $row["phone_type_voice"];
$phone_type_fax = $row["phone_type_fax"];
$phone_type_video = $row["phone_type_video"];
$phone_type_text = $row["phone_type_text"];
$phone_speed_dial = $row["phone_speed_dial"];
$phone_country_code = $row["phone_country_code"];
$phone_number = $row["phone_number"];
$phone_extension = $row["phone_extension"];
$phone_primary = $row["phone_primary"];
$phone_description = $row["phone_description"];
}
unset($sql, $parameters, $row);
}
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//show the header
if ($action == "update") {
$document['title'] = $text['title-contact_phones-edit'];
}
else if ($action == "add") {
$document['title'] = $text['title-contact_phones-add'];
}
require_once "resources/header.php";
//javascript to toggle input/select boxes
echo "<script type='text/javascript'>\n";
echo " function toggle_custom(field) {\n";
echo " $('#'+field).toggle();\n";
echo " document.getElementById(field).selectedIndex = 0;\n";
echo " document.getElementById(field+'_custom').value = '';\n";
echo " $('#'+field+'_custom').toggle();\n";
echo " if ($('#'+field+'_custom').is(':visible')) { $('#'+field+'_custom').trigger('focus'); } else { $('#'+field).trigger('focus'); }\n";
echo " }";
echo "</script>";
//show the content
echo "<form method='post' name='frm' id='frm'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'>";
if ($action == "update") {
echo "<b>".$text['header-contact_phones-edit']."</b>";
}
else if ($action == "add") {
echo "<b>".$text['header-contact_phones-add']."</b>";
}
echo " </div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'contact_edit.php?id='.urlencode($contact_uuid)]);
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo "<div class='card'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-phone_label']."\n";
echo "</td>\n";
echo "<td width='70%' class='vtable' align='left'>\n";
if (!empty($_SESSION["contact"]["phone_label"])) {
sort($_SESSION["contact"]["phone_label"]);
foreach($_SESSION["contact"]["phone_label"] as $row) {
$phone_label_options[] = "<option value='".$row."' ".(($row == $phone_label) ? "selected='selected'" : null).">".$row."</option>";
}
$phone_label_found = (in_array($phone_label, $_SESSION["contact"]["phone_label"])) ? true : false;
}
else {
$selected[$phone_label] = "selected";
$default_labels[] = $text['option-work'];
$default_labels[] = $text['option-home'];
$default_labels[] = $text['option-mobile'];
$default_labels[] = $text['option-main'];
$default_labels[] = $text['option-fax'];
$default_labels[] = $text['option-pager'];
$default_labels[] = $text['option-voicemail'];
$default_labels[] = $text['option-text'];
$default_labels[] = $text['option-other'];
foreach ($default_labels as $default_label) {
$phone_label_options[] = "<option value='".$default_label."' ".!empty($selected[$default_label]).">".$default_label."</option>";
}
$phone_label_found = (in_array(!empty($phone_label), $default_labels)) ? true : false;
}
echo " <select class='formfld' ".((!empty($phone_label) && !$phone_label_found) ? "style='display: none;'" : null)." name='phone_label' id='phone_label' onchange=\"getElementById('phone_label_custom').value='';\">\n";
echo " <option value=''></option>\n";
echo (!empty($phone_label_options)) ? implode("\n", $phone_label_options) : null;
echo " </select>\n";
echo " <input type='text' class='formfld' ".((empty($phone_label) || $phone_label_found) ? "style='display: none;'" : null)." name='phone_label_custom' id='phone_label_custom' value=\"".((!$phone_label_found) ? htmlentities($phone_label ?? '') : null)."\">\n";
echo " <input type='button' id='btn_toggle_type' class='btn' alt='".$text['button-back']."' value='&#9665;' onclick=\"toggle_custom('phone_label');\">\n";
echo "<br />\n";
echo $text['description-phone_label']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-phone_type']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <label><input type='checkbox' name='phone_type_voice' id='phone_type_voice' value='1' ".(($phone_type_voice) ? "checked='checked'" : null)."> ".$text['label-voice']."</label>&nbsp;\n";
echo " <label><input type='checkbox' name='phone_type_fax' id='phone_type_fax' value='1' ".(($phone_type_fax) ? "checked='checked'" : null)."> ".$text['label-fax']."</label>&nbsp;\n";
echo " <label><input type='checkbox' name='phone_type_video' id='phone_type_video' value='1' ".(($phone_type_video) ? "checked='checked'" : null)."> ".$text['label-video']."</label>&nbsp;\n";
echo " <label><input type='checkbox' name='phone_type_text' id='phone_type_text' value='1' ".(($phone_type_text) ? "checked='checked'" : null)."> ".$text['label-text']."</label>\n";
echo "<br />\n";
echo $text['description-phone_type']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-phone_speed_dial']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='phone_speed_dial' maxlength='255' min='0' step='1' value=\"".escape($phone_speed_dial)."\">\n";
echo "<br />\n";
echo $text['description-phone_speed_dial']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-phone_country_code']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='phone_country_code' maxlength='6' min='0' step='1' value=\"".escape($phone_country_code)."\">\n";
echo "<br />\n";
echo $text['description-phone_country_code']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-phone_number']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='phone_number' maxlength='255' min='0' step='1' value=\"".escape($phone_number)."\">\n";
echo "<br />\n";
echo $text['description-phone_number']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-phone_extension']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='number' name='phone_extension' min='0' step='1' maxlength='255' value=\"".escape($phone_extension)."\">\n";
echo "<br />\n";
echo $text['description-phone_extension']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-primary']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='phone_primary' id='phone_primary'>\n";
echo " <option value='0'>".$text['option-false']."</option>\n";
echo " <option value='1' ".(($phone_primary) ? "selected" : null).">".$text['option-true']."</option>\n";
echo " </select>\n";
echo "<br />\n";
echo $text['description-phone_primary']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-phone_description']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='phone_description' maxlength='255' value=\"".escape($phone_description)."\">\n";
echo "<br />\n";
echo $text['description-phone_description']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>";
echo "</div>\n";
echo "<br><br>";
echo "<input type='hidden' name='contact_uuid' value='".escape($contact_uuid)."'>\n";
if ($action == "update") {
echo "<input type='hidden' name='contact_phone_uuid' value='".escape($contact_phone_uuid)."'>\n";
}
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>";
//include the footer
require_once "resources/footer.php";
?>
+146
View File
@@ -0,0 +1,146 @@
<?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-2024
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";
//check permissions
if (permission_exists('contact_phone_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//get the contact list
$sql = "select * from v_contact_phones ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and contact_uuid = :contact_uuid ";
$sql .= "order by phone_primary desc, phone_label asc ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['contact_uuid'] = $contact_uuid ?? '';
$database = new database;
$contact_phones = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//show if exists
if (!empty($contact_phones)) {
//javascript function: send_cmd
echo "<script type=\"text/javascript\">\n";
echo "function send_cmd(url) {\n";
echo " if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari\n";
echo " xmlhttp=new XMLHttpRequest();\n";
echo " }\n";
echo " else {// code for IE6, IE5\n";
echo " xmlhttp=new ActiveXObject(\"Microsoft.XMLHTTP\");\n";
echo " }\n";
echo " xmlhttp.open(\"GET\",url,true);\n";
echo " xmlhttp.send(null);\n";
echo " document.getElementById('cmd_reponse').innerHTML=xmlhttp.responseText;\n";
echo "}\n";
echo "</script>\n";
//show the content
echo "<div class='action_bar sub shrink'>\n";
echo " <div class='heading'><b>".$text['label-phone_numbers']."</b></div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo "<div class='card'>\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
if (permission_exists('contact_phone_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all_phones' name='checkbox_all' onclick=\"edit_all_toggle('phones');\" ".($contact_phones ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
}
echo "<th class='pct-15'>".$text['label-phone_label']."</th>\n";
echo "<th>".$text['label-phone_number']."</th>\n";
echo "<th>".$text['label-phone_type']."</th>\n";
echo "<th>".$text['label-phone_tools']."</th>\n";
echo "<th class='hide-md-dn'>".$text['label-phone_description']."</th>\n";
if (permission_exists('contact_phone_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
if (!empty($contact_phones)) {
$x = 0;
foreach ($contact_phones as $row) {
if (permission_exists('contact_phone_edit')) {
$list_row_url = "contact_phone_edit.php?contact_uuid=".urlencode($row['contact_uuid'])."&id=".urlencode($row['contact_phone_uuid']);
}
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('contact_phone_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='contact_phones[$x][checked]' id='checkbox_".$x."' class='chk_delete checkbox_phones' value='true' onclick=\"edit_delete_action('phones');\">\n";
echo " <input type='hidden' name='contact_phones[$x][uuid]' value='".escape($row['contact_phone_uuid'])."' />\n";
echo " </td>\n";
}
echo " <td>".($row['phone_label'] == strtolower($row['phone_label']) ? ucwords($row['phone_label']) : $row['phone_label'])." ".($row['phone_primary'] ? "&nbsp;<i class='fas fa-star fa-xs' style='float: right; margin-top: 0.5em; margin-right: -0.5em;' title=\"".$text['label-primary']."\"></i>" : null)."</td>\n";
echo " <td class='no-link'>\n";
echo button::create(['type'=>'button','class'=>'link','label'=>escape(format_phone($row['phone_number'])),'title'=>$text['label-click_to_call'],'onclick'=>"send_cmd('".PROJECT_PATH."/app/click_to_call/click_to_call.php?src_cid_name=".urlencode($row['phone_number'])."&src_cid_number=".urlencode($row['phone_number'])."&dest_cid_name=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_name'])."&dest_cid_number=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_number'])."&src=".urlencode($_SESSION['user']['extension'][0]['user'])."&dest=".urlencode($row['phone_number'])."&rec=false&ringback=us-ring&auto_answer=true');"]);
echo " </td>\n";
echo " <td class='no-wrap'>\n";
if ($row['phone_type_voice']) { $phone_types[] = "<i class='fas fa-phone fa-fw' style='margin-right: 3px;' title=\"".$text['label-voice']."\"></i>"; }
if ($row['phone_type_fax']) { $phone_types[] = "<i class='fas fa-fax fa-fw' style='margin-right: 3px;' title=\"".$text['label-fax']."\"></i>"; }
if ($row['phone_type_video']) { $phone_types[] = "<i class='fas fa-video fa-fw' style='margin-right: 3px;' title=\"".$text['label-video']."\"></i>"; }
if ($row['phone_type_text']) { $phone_types[] = "<i class='fas fa-sms fa-fw' style='margin-right: 3px;' title=\"".$text['label-text']."\"></i>"; }
if (is_array($phone_types)) {
echo " ".implode(" ", $phone_types)."\n";
}
unset($phone_types);
echo " </td>\n";
echo " <td class='no-link no-wrap'>\n";
echo " <a href='../xml_cdr/xml_cdr.php?caller_id_number=".urlencode($row['phone_number'])."'>".$text['button-cdr']."</a>";
if ($row['phone_type_voice']) {
echo "&nbsp;<span class='hide-sm-dn'>\n";
echo button::create(['type'=>'button','class'=>'link','label'=>$text['label-phone_call'],'title'=>$text['label-click_to_call'],'onclick'=>"send_cmd('".PROJECT_PATH."/app/click_to_call/click_to_call.php?src_cid_name=".urlencode($row['phone_number'])."&src_cid_number=".urlencode($row['phone_number'])."&dest_cid_name=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_name'])."&dest_cid_number=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_number'])."&src=".urlencode($_SESSION['user']['extension'][0]['user'])."&dest=".urlencode($row['phone_number'])."&rec=false&ringback=us-ring&auto_answer=true');"]);
echo "</span>";
}
echo " </td>\n";
echo " <td class='description overflow hide-md-dn'>".escape($row['phone_description'])."&nbsp;</td>\n";
if (permission_exists('contact_phone_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n";
}
echo "</tr>\n";
$x++;
}
unset($contact_phones);
}
echo "</table>\n";
echo "</div>\n";
echo "<br />\n";
}
?>
+95
View File
@@ -0,0 +1,95 @@
<?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-2023
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";
//check permissions
if (permission_exists('contact_phone_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//get the contact list
$sql = "select * from v_contact_phones ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and contact_uuid = :contact_uuid ";
$sql .= "order by phone_primary desc, phone_label asc ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['contact_uuid'] = $contact_uuid ?? '';
$database = new database;
$contact_phones = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//show if exists
if (!empty($contact_phones)) {
//javascript function: send_cmd
echo "<script type='text/javascript'>\n";
echo "function send_cmd(url) {\n";
echo " if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari\n";
echo " xmlhttp=new XMLHttpRequest();\n";
echo " }\n";
echo " else {// code for IE6, IE5\n";
echo " xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');\n";
echo " }\n";
echo " xmlhttp.open('GET',url,true);\n";
echo " xmlhttp.send(null);\n";
echo " document.getElementById('cmd_reponse').innerHTML=xmlhttp.responseText;\n";
echo "}\n";
echo "</script>\n";
//show the content
echo "<div class='grid' style='grid-template-columns: 70px 120px auto;'>\n";
$x = 0;
foreach ($contact_phones as $row) {
echo "<div class='box contact-details-label'>".(!empty($row['phone_label']) && $row['phone_label'] == strtolower($row['phone_label']) ? ucwords($row['phone_label']) : $row['phone_label'])."</div>\n";
// ($row['phone_primary'] ? "&nbsp;<i class='fas fa-star fa-xs' style='float: right; margin-top: 0.5em; margin-right: -0.5em;' title=\"".$text['label-primary']."\"></i>" : null)."</td>\n";
echo "<div class='box'>";
echo button::create(['type'=>'button','class'=>'link','label'=>escape(format_phone($row['phone_number'] ?? '')),'title'=>$text['label-click_to_call'],'onclick'=>"send_cmd('".PROJECT_PATH."/app/click_to_call/click_to_call.php?src_cid_name=".urlencode($row['phone_number'] ?? '')."&src_cid_number=".urlencode($row['phone_number'] ?? '')."&dest_cid_name=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_name'] ?? '')."&dest_cid_number=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_number'] ?? '')."&src=".urlencode($_SESSION['user']['extension'][0]['user'] ?? '')."&dest=".urlencode($row['phone_number'] ?? '')."&rec=false&ringback=us-ring&auto_answer=true');"]);
echo "</div>\n";
echo "<div class='box no-wrap'>";
if ($row['phone_type_voice']) { $phone_types[] = "<i class='fas fa-phone fa-fw' style='margin-right: 3px;' title=\"".$text['label-voice']."\"></i>"; }
if ($row['phone_type_fax']) { $phone_types[] = "<i class='fas fa-fax fa-fw' style='margin-right: 3px;' title=\"".$text['label-fax']."\"></i>"; }
if ($row['phone_type_video']) { $phone_types[] = "<i class='fas fa-video fa-fw' style='margin-right: 3px;' title=\"".$text['label-video']."\"></i>"; }
if ($row['phone_type_text']) { $phone_types[] = "<i class='fas fa-sms fa-fw' style='margin-right: 3px;' title=\"".$text['label-text']."\"></i>"; }
if (!empty($phone_types)) {
echo " ".implode(" ", $phone_types)."\n";
}
unset($phone_types);
echo "</div>\n";
$x++;
}
echo "</div>\n";
unset($contact_phones);
}
?>
+382
View File
@@ -0,0 +1,382 @@
<?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-2024
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('contact_relation_edit') || permission_exists('contact_relation_add')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//action add or update
if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
$action = "update";
$contact_relation_uuid = $_REQUEST["id"];
}
else {
$action = "add";
}
//get the contact uuid
if (!empty($_GET["contact_uuid"]) && is_uuid($_GET["contact_uuid"])) {
$contact_uuid = $_GET["contact_uuid"];
}
//get http post variables and set them to php variables
if (!empty($_POST)) {
$relation_label = $_POST["relation_label"];
$relation_label_custom = $_POST["relation_label_custom"];
$relation_contact_uuid = $_POST["relation_contact_uuid"];
$relation_reciprocal = $_POST["relation_reciprocal"];
$relation_reciprocal_label = $_POST["relation_reciprocal_label"];
$relation_reciprocal_label_custom = $_POST["relation_reciprocal_label_custom"];
//use custom label(s), if set
$relation_label = ($relation_label_custom != '') ? $relation_label_custom : $relation_label;
$relation_reciprocal_label = ($relation_reciprocal_label_custom != '') ? $relation_reciprocal_label_custom : $relation_reciprocal_label;
}
//process the form data
if (!empty($_POST) && empty($_POST["persistformvar"])) {
//set the uuid
if ($action == "update") {
$contact_relation_uuid = $_POST["contact_relation_uuid"];
}
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: contacts.php');
exit;
}
//check for all required data
$msg = '';
if (!empty($msg) && empty($_POST["persistformvar"])) {
require_once "resources/header.php";
require_once "resources/persist_form_var.php";
echo "<div align='center'>\n";
echo "<table><tr><td>\n";
echo $msg."<br />";
echo "</td></tr></table>\n";
persistformvar($_POST);
echo "</div>\n";
require_once "resources/footer.php";
return;
}
//add or update the database
if (empty($_POST["persistformvar"])) {
//update last modified
$array['contacts'][0]['contact_uuid'] = $contact_uuid;
$array['contacts'][0]['domain_uuid'] = $domain_uuid;
$array['contacts'][0]['last_mod_date'] = 'now()';
$array['contacts'][0]['last_mod_user'] = $_SESSION['username'];
$p = new permissions;
$p->add('contact_edit', 'temp');
$database = new database;
$database->app_name = 'contacts';
$database->app_uuid = '04481e0e-a478-c559-adad-52bd4174574c';
$database->save($array);
unset($array);
$p->delete('contact_edit', 'temp');
//add the relation
if ($action == "add" && permission_exists('contact_relation_add')) {
$contact_relation_uuid = uuid();
$array['contact_relations'][0]['contact_relation_uuid'] = $contact_relation_uuid;
if ($relation_reciprocal) {
$contact_relation_uuid = uuid();
$array['contact_relations'][1]['contact_relation_uuid'] = $contact_relation_uuid;
$array['contact_relations'][1]['domain_uuid'] = $_SESSION['domain_uuid'];
$array['contact_relations'][1]['contact_uuid'] = $relation_contact_uuid;
$array['contact_relations'][1]['relation_label'] = $relation_reciprocal_label;
$array['contact_relations'][1]['relation_contact_uuid'] = $contact_uuid;
}
message::add($text['message-add']);
}
//update the relation
if ($action == "update" && permission_exists('contact_relation_edit')) {
$array['contact_relations'][0]['contact_relation_uuid'] = $contact_relation_uuid;
message::add($text['message-update']);
}
//execute
if (!empty($array)) {
$array['contact_relations'][0]['contact_uuid'] = $contact_uuid;
$array['contact_relations'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
$array['contact_relations'][0]['relation_label'] = $relation_label;
$array['contact_relations'][0]['relation_contact_uuid'] = $relation_contact_uuid;
$database = new database;
$database->app_name = 'contacts';
$database->app_uuid = '04481e0e-a478-c559-adad-52bd4174574c';
$database->save($array);
unset($array);
}
//redirect
header("Location: contact_edit.php?id=".escape($contact_uuid));
exit;
}
}
//pre-populate the form
if (!empty($_GET) && empty($_POST["persistformvar"])) {
$contact_relation_uuid = $_GET["id"] ?? '';
$sql = "select * from v_contact_relations ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and contact_relation_uuid = :contact_relation_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['contact_relation_uuid'] = $contact_relation_uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (is_array($row) && @sizeof($row) != 0) {
$relation_label = $row["relation_label"];
$relation_contact_uuid = $row["relation_contact_uuid"];
}
unset($sql, $parameters, $row);
}
//get contact details and contact_name
$sql = "select contact_uuid, contact_organization, contact_name_given, contact_name_family, contact_nickname ";
$sql .= "from v_contacts ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and contact_uuid <> :contact_uuid ";
$sql .= "order by contact_organization desc, contact_name_given asc, contact_name_family asc ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['contact_uuid'] = $contact_relation_uuid;
$database = new database;
$contacts = $database->select($sql, $parameters, 'all');
if (!empty($contacts) && is_uuid($row['relation_contact_uuid'])) {
foreach($contacts as $field) {
if ($field['contact_uuid'] == $row['relation_contact_uuid']) {
$name = array();
if (!empty($field['contact_organization'])) { $name[] = $field['contact_organization']; }
if (!empty($field['contact_name_family'])) { $name[] = $field['contact_name_family']; }
if (!empty($field['contact_name_given'])) { $name[] = $field['contact_name_given']; }
if (empty($field['contact_name_family']) && empty($field['contact_name_given']) && !empty($field['contact_nickname'])) { $name[] = $field['contact_nickname']; }
$contact_name = implode(', ', $name);
break;
}
}
}
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//show the header
$document['title'] = $text['title-contact_relation'];
require_once "resources/header.php";
?>
<script type="text/javascript">
function get_contacts(element_id, id, search) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
//create a handle for the contact select object
select = document.getElementById(element_id);
//remove current options
while (select.options.length > 0) {
select.remove(0);
}
//add an empty row
//select.add(new Option('', ''));
//add new options from the json results
obj = JSON.parse(this.responseText);
for (var i=0; i < obj.length; i++) {
select.add(new Option(obj[i].name, obj[i].id));
}
}
};
if (search) {
xhttp.open("GET", "/app/contacts/contact_json.php?search="+search, true);
}
else {
xhttp.open("GET", "/app/contacts/contact_json.php", true);
}
xhttp.send();
}
</script>
<?php
//javascript to toggle input/select boxes
echo "<script type='text/javascript'>";
echo " function toggle_custom(field) {";
echo " $('#'+field).toggle();";
echo " document.getElementById(field).selectedIndex = 0;";
echo " document.getElementById(field+'_custom').value = '';";
echo " $('#'+field+'_custom').toggle();";
echo " if ($('#'+field+'_custom').is(':visible')) { $('#'+field+'_custom').trigger('focus'); } else { $('#'+field).trigger('focus'); }";
echo " }";
echo "</script>";
//show the content
echo "<form method='post' name='frm'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-contact_relation']."</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'contact_edit.php?id='.urlencode($contact_uuid)]);
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo "<div class='card'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-contact_relation_label']."\n";
echo "</td>\n";
echo "<td width='70%' class='vtable' align='left'>\n";
if (!empty($_SESSION["contact"]["relation_label"])) {
sort($_SESSION["contact"]["relation_label"]);
foreach($_SESSION["contact"]["relation_label"] as $row) {
$relation_label_options[] = "<option value='".$row."' ".(($row == $relation_label) ? "selected='selected'" : null).">".$row."</option>";
}
$relation_label_found = (in_array($relation_label, $_SESSION["contact"]["relation_label"])) ? true : false;
}
else {
$selected[!empty($relation_label)] = "selected";
$default_labels[] = $text['label-contact_relation_option_parent'];
$default_labels[] = $text['label-contact_relation_option_child'];
$default_labels[] = $text['label-contact_relation_option_employee'];
$default_labels[] = $text['label-contact_relation_option_member'];
$default_labels[] = $text['label-contact_relation_option_associate'];
$default_labels[] = $text['label-contact_relation_option_other'];
foreach ($default_labels as $default_label) {
$relation_label_options[] = "<option value='".$default_label."' ".!empty($selected[$default_label]).">".$default_label."</option>";
}
$relation_label_found = (in_array(!empty($relation_label), $default_labels)) ? true : false;
}
echo " <select class='formfld' ".((!empty($relation_label) && !$relation_label_found) ? "style='display: none;'" : null)." name='relation_label' id='relation_label' onchange=\"getElementById('relation_label_custom').value='';\">\n";
echo " <option value=''></option>\n";
echo (is_array($relation_label_options)) ? implode("\n", $relation_label_options) : null;
echo " </select>\n";
echo " <input type='text' class='formfld' ".((empty($relation_label) || $relation_label_found) ? "style='display: none;'" : null)." name='relation_label_custom' id='relation_label_custom' value=\"".((!$relation_label_found) ? htmlentities($relation_label ?? '') : null)."\">\n";
echo " <input type='button' id='btn_toggle_label' class='btn' alt='".$text['button-back']."' value='&#9665;' onclick=\"toggle_custom('relation_label');\">\n";
echo "<br />\n";
echo !empty($text['description-relation_label'])."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-contact_relation_contact']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class=\"formfld\" type=\"text\" name=\"contact_search\" placeholder=\"search\" style=\"width: 80px;\" onkeyup=\"get_contacts('contact_select', 'contact_uuid', this.value);\" maxlength=\"255\" value=\"\">\n";
echo " <select class='formfld' style=\"width: 150px;\" id=\"contact_select\" name=\"relation_contact_uuid\" >\n";
echo " <option value='".escape($relation_contact_uuid ?? '')."'>".escape($contact_name ?? '')."</option>\n";
echo " </select>\n";
echo "</td>\n";
echo "</tr>\n";
if ($action == 'add') {
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-contact_relation_reciprocal']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='relation_reciprocal' id='relation_reciprocal' onchange=\"$('#reciprocal_label').slideToggle(400);\">\n";
echo " <option value='0'>".$text['option-false']."</option>\n";
echo " <option value='1'>".$text['option-true']."</option>\n";
echo " </select>\n";
echo "<br />\n";
echo $text['description-contact_relation_reciprocal']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<div id='reciprocal_label' style='display: none;'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-contact_relation_reciprocal_label']."\n";
echo "</td>\n";
echo "<td width='70%' class='vtable' align='left'>\n";
echo " <select class='formfld' name='relation_reciprocal_label' id='relation_reciprocal_label' onchange=\"getElementById('relation_reciprocal_label_custom').value='';\">\n";
echo " <option value=''></option>\n";
echo (!empty($relation_label_options)) ? implode("\n", $relation_label_options) : null;
echo " </select>\n";
echo " <input type='text' class='formfld' style='display: none;' name='relation_reciprocal_label_custom' id='relation_reciprocal_label_custom' value=''>\n";
echo " <input type='button' id='btn_toggle_reciprocal_label' class='btn' alt='".$text['button-back']."' value='&#9665;' onclick=\"toggle_custom('relation_reciprocal_label');\">\n";
echo "<br />\n";
echo $text['description-contact_relation_reciprocal_label']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</div>\n";
}
else {
echo "</table>\n";
}
echo "</div>\n";
echo "<br><br>";
echo "<input type='hidden' name='contact_uuid' value='".escape($contact_uuid)."'>\n";
if ($action == "update") {
echo "<input type='hidden' name='contact_relation_uuid' value='".escape($contact_relation_uuid)."'>\n";
}
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>";
//include the footer
require_once "resources/footer.php";
?>
+126
View File
@@ -0,0 +1,126 @@
<?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-2024
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";
//check permissions
if (permission_exists('contact_relation_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//set from session variables
$list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false';
//get the related contacts
$sql = "select ";
$sql .= "cr.contact_relation_uuid, ";
$sql .= "cr.relation_label, ";
$sql .= "c.contact_uuid, ";
$sql .= "c.contact_organization, ";
$sql .= "c.contact_name_given, ";
$sql .= "c.contact_name_family ";
$sql .= "from ";
$sql .= "v_contact_relations as cr, ";
$sql .= "v_contacts as c ";
$sql .= "where ";
$sql .= "cr.relation_contact_uuid = c.contact_uuid ";
$sql .= "and cr.domain_uuid = :domain_uuid ";
$sql .= "and cr.contact_uuid = :contact_uuid ";
$sql .= "order by ";
$sql .= "c.contact_organization desc, ";
$sql .= "c.contact_name_given asc, ";
$sql .= "c.contact_name_family asc ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['contact_uuid'] = $contact_uuid ?? '';
$database = new database;
$contact_relations = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//show if exists
if (!empty($contact_relations)) {
//show the content
echo "<div class='action_bar sub shrink'>\n";
echo " <div class='heading'><b>".$text['header-contact_relations']."</b></div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo "<div class='card'>\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
if (permission_exists('contact_relation_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all_relations' name='checkbox_all' onclick=\"edit_all_toggle('relations');\" ".(!empty($contact_relations) ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
}
echo "<th>".$text['label-contact_relation_label']."</th>\n";
echo "<th>".$text['label-contact_relation_organization']."</th>\n";
echo "<th>".$text['label-contact_relation_name']."</th>\n";
if (permission_exists('contact_relation_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
if (!empty($contact_relations)) {
$x = 0;
foreach ($contact_relations as $row) {
if (permission_exists('contact_relation_edit')) {
$list_row_url = "contact_relation_edit.php?contact_uuid=".urlencode($contact_uuid)."&id=".urlencode($row['contact_relation_uuid']);
}
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('contact_relation_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='contact_relations[$x][checked]' id='checkbox_".$x."' class='chk_delete checkbox_relations' value='true' onclick=\"edit_delete_action('relations');\">\n";
echo " <input type='hidden' name='contact_relations[$x][uuid]' value='".escape($row['contact_relation_uuid'])."' />\n";
echo " </td>\n";
}
echo " <td>".escape($row['relation_label'])."&nbsp;</td>\n";
echo " <td class='no-link'><a href='contact_edit.php?id=".urlencode($row['contact_uuid'])."'>".escape($row['contact_organization'])."</a>&nbsp;</td>\n";
echo " <td class='no-link'><a href='contact_edit.php?id=".urlencode($row['contact_uuid'])."'>".escape($row['contact_name_given']).((!empty($row['contact_name_given']) && !empty($row['contact_name_family'])) ? ' ' : null).escape($row['contact_name_family'])."</a>&nbsp;</td>\n";
if (permission_exists('contact_relation_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n";
}
echo "</tr>\n";
$x++;
}
unset($contact_relations);
}
echo "</table>";
echo "</div>\n";
echo "<br />\n";
}
?>
+82
View File
@@ -0,0 +1,82 @@
<?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-2020
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";
//check permissions
if (permission_exists('contact_relation_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//get the related contacts
$sql = "select ";
$sql .= "cr.contact_relation_uuid, ";
$sql .= "cr.relation_label, ";
$sql .= "c.contact_uuid, ";
$sql .= "c.contact_organization, ";
$sql .= "c.contact_name_given, ";
$sql .= "c.contact_name_family ";
$sql .= "from ";
$sql .= "v_contact_relations as cr, ";
$sql .= "v_contacts as c ";
$sql .= "where ";
$sql .= "cr.relation_contact_uuid = c.contact_uuid ";
$sql .= "and cr.domain_uuid = :domain_uuid ";
$sql .= "and cr.contact_uuid = :contact_uuid ";
$sql .= "order by ";
$sql .= "c.contact_organization desc, ";
$sql .= "c.contact_name_given asc, ";
$sql .= "c.contact_name_family asc ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['contact_uuid'] = $contact_uuid ?? '';
$database = new database;
$contact_relations = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//show if exists
if (!empty($contact_relations)) {
//show the content
echo "<div class='grid' style='grid-template-columns: 70px auto auto;'>\n";
$x = 0;
foreach ($contact_relations as $row) {
echo "<div class='box contact-details-label'>".escape($row['relation_label'])."</div>\n";
echo "<div class='box'><a href='contact_view.php?id=".urlencode($row['contact_uuid'])."'>".escape($row['contact_organization'])."</a></div>\n";
echo "<div class='box'><a href='contact_view.php?id=".urlencode($row['contact_uuid'])."'>".escape($row['contact_name_given']).(($row['contact_name_given'] && $row['contact_name_family']) ? ' ' : null).escape($row['contact_name_family'])."</a></div>\n";
$x++;
}
echo "</div>\n";
unset($contact_relations);
}
?>
+370
View File
@@ -0,0 +1,370 @@
<?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-2024
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('contact_setting_edit') || permission_exists('contact_setting_add')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//set the defaults
$contact_setting_category = '';
$contact_setting_subcategory = '';
$contact_setting_name = '';
$contact_setting_value = '';
$contact_setting_order = '';
$contact_setting_enabled = '';
$contact_setting_description = '';
//action add or update
if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
$action = "update";
$contact_setting_uuid = $_REQUEST["id"];
}
else {
$action = "add";
}
//get the contact uuid
if (!empty($_GET["contact_uuid"]) && is_uuid($_GET["contact_uuid"])) {
$contact_uuid = $_GET["contact_uuid"];
}
//set the session domain uuid as a variable
$domain_uuid = $_SESSION['domain_uuid'];
//get http post variables and set them to php variables
if (!empty($_POST)) {
$contact_setting_category = strtolower($_POST["contact_setting_category"]);
$contact_setting_subcategory = strtolower($_POST["contact_setting_subcategory"]);
$contact_setting_name = strtolower($_POST["contact_setting_name"]);
$contact_setting_value = $_POST["contact_setting_value"];
$contact_setting_order = $_POST["contact_setting_order"] ?? null;
$contact_setting_enabled = strtolower($_POST["contact_setting_enabled"]);
$contact_setting_description = $_POST["contact_setting_description"];
}
//process the form data
if (!empty($_POST) && empty($_POST["persistformvar"])) {
//set the uuid
if ($action == "update") {
$contact_setting_uuid = $_POST["contact_setting_uuid"];
}
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: contacts.php');
exit;
}
//check for all required data
$msg = '';
//if (empty($domain_setting_category)) { $msg .= $text['message-required'].$text['label-category']."<br>\n"; }
//if (empty($domain_setting_subcategory)) { $msg .= $text['message-required'].$text['label-subcategory']."<br>\n"; }
//if (empty($domain_setting_name)) { $msg .= $text['message-required'].$text['label-type']."<br>\n"; }
//if (empty($domain_setting_value)) { $msg .= $text['message-required'].$text['label-value']."<br>\n"; }
//if (empty($domain_setting_order)) { $msg .= $text['message-required'].$text['label-order']."<br>\n"; }
//if (empty($domain_setting_enabled)) { $msg .= $text['message-required'].$text['label-enabled']."<br>\n"; }
//if (empty($domain_setting_description)) { $msg .= $text['message-required'].$text['label-description']."<br>\n"; }
if (!empty($msg) && empty($_POST["persistformvar"])) {
require_once "resources/header.php";
require_once "resources/persist_form_var.php";
echo "<div align='center'>\n";
echo "<table><tr><td>\n";
echo $msg."<br />";
echo "</td></tr></table>\n";
persistformvar($_POST);
echo "</div>\n";
require_once "resources/footer.php";
return;
}
//add or update the database
if (empty($_POST["persistformvar"])) {
//set the order
$contact_setting_order = $contact_setting_order != '' ? $contact_setting_order : null;
//update last modified
$array['contacts'][0]['contact_uuid'] = $contact_uuid;
$array['contacts'][0]['domain_uuid'] = $domain_uuid;
$array['contacts'][0]['last_mod_date'] = 'now()';
$array['contacts'][0]['last_mod_user'] = $_SESSION['username'];
$p = new permissions;
$p->add('contact_edit', 'temp');
$database = new database;
$database->app_name = 'contacts';
$database->app_uuid = '04481e0e-a478-c559-adad-52bd4174574c';
$database->save($array);
unset($array);
$p->delete('contact_edit', 'temp');
//add the setting
if ($action == "add" && permission_exists('contact_setting_add')) {
$contact_setting_uuid = uuid();
$array['contact_settings'][0]['contact_setting_uuid'] = $contact_setting_uuid;
message::add($text['message-add']);
}
//update the setting
if ($action == "update" && permission_exists('contact_setting_edit')) {
$array['contact_settings'][0]['contact_setting_uuid'] = $contact_setting_uuid;
message::add($text['message-update']);
}
//execute
if (!empty($array)) {
$array['contact_settings'][0]['contact_uuid'] = $contact_uuid;
$array['contact_settings'][0]['domain_uuid'] = $domain_uuid;
$array['contact_settings'][0]['contact_setting_category'] = $contact_setting_category;
$array['contact_settings'][0]['contact_setting_subcategory'] = $contact_setting_subcategory;
$array['contact_settings'][0]['contact_setting_name'] = $contact_setting_name;
$array['contact_settings'][0]['contact_setting_value'] = $contact_setting_value;
$array['contact_settings'][0]['contact_setting_order'] = $contact_setting_order;
$array['contact_settings'][0]['contact_setting_enabled'] = $contact_setting_enabled;
$array['contact_settings'][0]['contact_setting_description'] = $contact_setting_description;
$database = new database;
$database->app_name = 'contacts';
$database->app_uuid = '04481e0e-a478-c559-adad-52bd4174574c';
$database->save($array);
unset($array);
}
//redirect the browser
header("Location: contact_edit.php?id=".escape($contact_uuid));
exit;
}
}
//pre-populate the form
if (!empty($_GET) && empty($_POST["persistformvar"])) {
$contact_setting_uuid = $_GET["id"] ?? '';
$sql = "select * from v_contact_settings ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and contact_setting_uuid = :contact_setting_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['contact_setting_uuid'] = $contact_setting_uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (!empty($row)) {
$contact_setting_category = escape($row["contact_setting_category"]);
$contact_setting_subcategory = escape($row["contact_setting_subcategory"]);
$contact_setting_name = escape($row["contact_setting_name"]);
$contact_setting_value = escape($row["contact_setting_value"]);
$contact_setting_order = escape($row["contact_setting_order"]);
$contact_setting_enabled = escape($row["contact_setting_enabled"]);
$contact_setting_description = escape($row["contact_setting_description"]);
}
unset($sql, $parameters, $row);
}
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//show the header
if ($action == "update") {
$document['title'] = $text['title-contact_setting_edit'];
}
elseif ($action == "add") {
$document['title'] = $text['title-contact_setting_add'];
}
require_once "resources/header.php";
//show the content
echo "<form method='post' name='frm'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'>";
if ($action == "update") {
echo "<b>".$text['header-contact_setting_edit']."</b>";
}
else if ($action == "add") {
echo "<b>".$text['header-contact_setting_add']."</b>";
}
echo " </div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'contact_edit.php?id='.urlencode($contact_uuid ?? '')]);
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
if ($action == "update") {
echo $text['description-contact_setting_edit'];
}
if ($action == "add") {
echo $text['description-contact_setting_add'];
}
echo "<br /><br />\n";
echo "<div class='card'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-contact_setting_category']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='contact_setting_category' maxlength='255' value=\"".escape($contact_setting_category)."\" required='required'>\n";
echo "<br />\n";
echo $text['description-contact_setting_category']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-contact_setting_subcategory']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='contact_setting_subcategory' maxlength='255' value=\"".escape($contact_setting_subcategory)."\">\n";
echo "<br />\n";
echo $text['description-contact_setting_subcategory']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-contact_setting_type']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='contact_setting_name' maxlength='255' value=\"".escape($contact_setting_name)."\">\n";
echo "<br />\n";
echo $text['description-contact_setting_type']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-contact_setting_value']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='contact_setting_value' maxlength='255' value=\"".escape($contact_setting_value)."\">\n";
echo "<br />\n";
echo $text['description-contact_setting_value']."\n";
echo "</td>\n";
echo "</tr>\n";
if ($contact_setting_name == "array") {
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap' width='30%'>\n";
echo " ".$text['label-order']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select name='contact_setting_order' class='formfld'>\n";
$i=0;
while($i<=999) {
$selected = ($i == $contact_setting_order) ? "selected" : null;
if (strlen($i) == 1) {
echo " <option value='00$i' ".$selected.">00$i</option>\n";
}
if (strlen($i) == 2) {
echo " <option value='0$i' ".$selected.">0$i</option>\n";
}
if (strlen($i) == 3) {
echo " <option value='$i' ".$selected.">$i</option>\n";
}
$i++;
}
echo " </select>\n";
echo " <br />\n";
echo $text['description-order']."\n";
echo "</td>\n";
echo "</tr>\n";
}
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " ".$text['label-enabled']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='contact_setting_enabled'>\n";
if ($contact_setting_enabled == "true") {
echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
}
else {
echo " <option value='true'>".$text['label-true']."</option>\n";
}
if ($contact_setting_enabled == "false") {
echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n";
}
else {
echo " <option value='false'>".$text['label-false']."</option>\n";
}
echo " </select>\n";
echo "<br />\n";
echo $text['description-enabled']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-description']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='contact_setting_description' maxlength='255' value=\"".escape($contact_setting_description)."\">\n";
echo "<br />\n";
echo $text['description-description']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>";
echo "</div>\n";
echo "<br><br>";
echo "<input type='hidden' name='contact_uuid' value='".!empty($contact_uuid)."'>\n";
if ($action == "update") {
echo "<input type='hidden' name='contact_setting_uuid' value='".$contact_setting_uuid."'>\n";
}
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>";
//include the footer
require_once "resources/footer.php";
?>
+135
View File
@@ -0,0 +1,135 @@
<?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-2024
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('contact_setting_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//set from session variables
$list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false';
//get the list
$sql = "select * from v_contact_settings ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and contact_uuid = :contact_uuid ";
$sql .= "order by ";
$sql .= "contact_setting_category asc ";
$sql .= ", contact_setting_subcategory asc ";
$sql .= ", contact_setting_order asc ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['contact_uuid'] = $contact_uuid ?? '';
$database = new database;
$contact_settings = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//show if exists
if (!empty($contact_settings)) {
//show the content
echo "<div class='action_bar sub shrink'>\n";
echo " <div class='heading'><b>".$text['label-contact_settings']."</b></div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo "<div class='card'>\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
if (permission_exists('contact_setting_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all_settings' name='checkbox_all' onclick=\"edit_all_toggle('settings');\" ".($contact_settings ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
}
echo "<th class='pct-15'>".$text['label-contact_setting_category']."</th>";
echo "<th>".$text['label-contact_setting_subcategory']."</th>";
echo "<th>".$text['label-contact_setting_type']."</th>";
echo "<th>".$text['label-contact_setting_value']."</th>";
echo "<th class='center'>".$text['label-enabled']."</th>";
echo "<th class='hide-md-dn'>".$text['label-description']."</th>";
if (permission_exists('contact_setting_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
if (!empty($contact_settings)) {
$x = 0;
foreach ($contact_settings as $row) {
if (permission_exists('contact_setting_edit')) {
$list_row_url = "contact_setting_edit.php?contact_uuid=".urlencode($contact_uuid)."&id=".urlencode($row['contact_setting_uuid']);
}
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('contact_setting_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='contact_settings[$x][checked]' id='checkbox_".$x."' class='chk_delete checkbox_settings' value='true' onclick=\"edit_delete_action('settings');\">\n";
echo " <input type='hidden' name='contact_settings[$x][uuid]' value='".escape($row['contact_setting_uuid'])."' />\n";
echo " </td>\n";
}
echo " <td>".escape($row['contact_setting_category'])."&nbsp;</td>\n";
echo " <td><a href='".$list_row_url."'>".escape($row['contact_setting_subcategory'])."</a></td>\n";
echo " <td>".escape($row['contact_setting_name'])."&nbsp;</td>\n";
echo " <td>\n";
$category = escape($row['contact_setting_category']);
$subcategory = escape($row['contact_setting_subcategory']);
$name = escape($row['contact_setting_name']);
if ($category == "callingcard" && $subcategory == "username" && $name == "var" ) {
echo " ********\n";
}
else if ($category == "callingcard" && $subcategory == "password" && $name == "var" ) {
echo " ********\n";
}
else {
echo escape($row['contact_setting_value']);
}
echo " </td>\n";
echo " <td class='center'>".$text['label-'.escape($row['contact_setting_enabled'])]."&nbsp;</td>\n";
echo " <td class='description overflow hide-md-dn'>".$row['contact_setting_description']."&nbsp;</td>\n";
if (permission_exists('contact_setting_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n";
}
echo "</tr>\n";
$x++;
}
unset($contact_settings);
}
echo "</table>";
echo "</div>\n";
echo "<br />\n";
}
?>
+249
View File
@@ -0,0 +1,249 @@
<?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-2018
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";
//check permissions
if (permission_exists('contact_time_edit') || permission_exists('contact_time_add')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//action add or update
if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
$action = "update";
$contact_time_uuid = $_REQUEST["id"];
}
else {
$action = "add";
}
//get the contact uuid
if (!empty($_GET["contact_uuid"]) && is_uuid($_GET["contact_uuid"])) {
$contact_uuid = $_GET["contact_uuid"];
}
//get http post variables and set them to php variables
if (!empty($_POST)) {
$time_start = $_POST["time_start"];
$time_stop = $_POST["time_stop"];
$time_description = $_POST["time_description"];
}
//process the form data
if (!empty($_POST) && empty($_POST["persistformvar"])) {
//set the uuid
if ($action == "update") {
$contact_time_uuid = $_POST["contact_time_uuid"];
}
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: contacts.php');
exit;
}
//check for all required data
$msg = '';
if (!empty($msg) && empty($_POST["persistformvar"])) {
require_once "resources/header.php";
require_once "resources/persist_form_var.php";
echo "<div align='center'>\n";
echo "<table><tr><td>\n";
echo $msg."<br />";
echo "</td></tr></table>\n";
persistformvar($_POST);
echo "</div>\n";
require_once "resources/footer.php";
return;
}
//add or update the database
if (empty($_POST["persistformvar"])) {
//update last modified
$array['contacts'][0]['contact_uuid'] = $contact_uuid;
$array['contacts'][0]['domain_uuid'] = $domain_uuid;
$array['contacts'][0]['last_mod_date'] = 'now()';
$array['contacts'][0]['last_mod_user'] = $_SESSION['username'];
$p = new permissions;
$p->add('contact_edit', 'temp');
$database = new database;
$database->app_name = 'contacts';
$database->app_uuid = '04481e0e-a478-c559-adad-52bd4174574c';
$database->save($array);
unset($array);
$p->delete('contact_edit', 'temp');
if ($action == "add" && permission_exists('contact_time_add')) {
$contact_time_uuid = uuid();
$array['contact_times'][0]['contact_time_uuid'] = $contact_time_uuid;
message::add($text['message-add']);
}
if ($action == "update" && permission_exists('contact_time_edit')) {
$array['contact_times'][0]['contact_time_uuid'] = $contact_time_uuid;
message::add($text['message-update']);
}
if (!empty($array)) {
$array['contact_times'][0]['domain_uuid'] = $domain_uuid;
$array['contact_times'][0]['contact_uuid'] = $contact_uuid;
$array['contact_times'][0]['user_uuid'] = $_SESSION["user"]["user_uuid"];
$array['contact_times'][0]['time_start'] = $time_start;
$array['contact_times'][0]['time_stop'] = $time_stop;
$array['contact_times'][0]['time_description'] = $time_description;
$database = new database;
$database->app_name = 'contacts';
$database->app_uuid = '04481e0e-a478-c559-adad-52bd4174574c';
$database->save($array);
unset($array);
}
header("Location: contact_edit.php?id=".$contact_uuid);
exit;
}
}
//pre-populate the form
if (!empty($_GET) && empty($_POST["persistformvar"])) {
$contact_time_uuid = $_GET["id"];
$sql = "select ct.*, u.username ";
$sql .= "from v_contact_times as ct, v_users as u ";
$sql .= "where ct.user_uuid = u.user_uuid ";
$sql .= "and ct.domain_uuid = :domain_uuid ";
$sql .= "and ct.contact_uuid = :contact_uuid ";
$sql .= "and ct.user_uuid = :user_uuid ";
$sql .= "and contact_time_uuid = :contact_time_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['contact_uuid'] = $contact_uuid ?? '';
$parameters['user_uuid'] = $_SESSION["user"]["user_uuid"];
$parameters['contact_time_uuid'] = $contact_time_uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
$time_start = $row["time_start"];
$time_stop = $row["time_stop"];
$time_description = $row["time_description"];
unset($sql, $parameters, $row);
}
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//show the header
if ($action == "update") {
$document['title'] = $text['title-contact_time_edit'];
}
else if ($action == "add") {
$document['title'] = $text['title-contact_time_add'];
}
require_once "resources/header.php";
//show the content
echo "<form method='post' name='frm'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'>";
if ($action == "update") {
echo "<b>".$text['header-contact_time_edit']."</b>";
}
else if ($action == "add") {
echo "<b>".$text['header-contact_time_add']."</b>";
}
echo " </div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'contact_edit.php?id='.urlencode($contact_uuid ?? '')]);
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo "<div class='card'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-time_start']."\n";
echo "</td>\n";
echo "<td width='70%' class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld datetimesecpicker' data-toggle='datetimepicker' data-target='#time_start' type='text' name='time_start' id='time_start' style='min-width: 135px; width: 135px;' value='".$time_start."' onblur=\"$(this).datetimepicker('hide');\">\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-time_stop']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld datetimesecpicker' data-toggle='datetimepicker' data-target='#time_stop' type='text' name='time_stop' id='time_stop' style='min-width: 135px; width: 135px;' value='".$time_stop."' onblur=\"$(this).datetimepicker('hide');\">\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-time_description']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <textarea class='formfld' type='text' name='time_description' id='time_description' style='width: 400px; height: 100px;'>".$time_description."</textarea>\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>";
echo "</div>\n";
echo "<br><br>";
echo "<input type='hidden' name='contact_uuid' value='".escape($contact_uuid)."'>\n";
if ($action == "update") {
echo "<input type='hidden' name='contact_time_uuid' value='".escape($contact_time_uuid)."'>\n";
}
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>";
//include the footer
require_once "resources/footer.php";
?>
+361
View File
@@ -0,0 +1,361 @@
<?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-2015
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_time_add')) { echo "access denied"; exit; }
//add multi-lingual support
$language = new text;
$text = $language->get();
//get contact uuid
$domain_uuid = $_REQUEST['domain_uuid'];
$contact_uuid = $_REQUEST['contact_uuid'];
//get posted variables & set time status
if (!empty($_POST)) {
$contact_time_uuid = $_POST['contact_time_uuid'];
$contact_uuid = $_POST['contact_uuid'];
$time_action = $_POST['time_action'];
$time_description = $_POST['time_description'];
if ($time_description == 'Description...') { unset($time_description); }
if ($time_action == 'start') {
$contact_time_uuid = uuid();
$array['contact_times'][0]['domain_uuid'] = $domain_uuid;
$array['contact_times'][0]['contact_time_uuid'] = $contact_time_uuid;
$array['contact_times'][0]['contact_uuid'] = $contact_uuid;
$array['contact_times'][0]['user_uuid'] = $_SESSION["user"]["user_uuid"];
$array['contact_times'][0]['time_start'] = date("Y-m-d H:i:s");
$array['contact_times'][0]['time_description'] = $time_description;
}
if ($time_action == 'stop') {
$array['contact_times'][0]['contact_time_uuid'] = $contact_time_uuid;
$array['contact_times'][0]['time_stop'] = date("Y-m-d H:i:s");
$array['contact_times'][0]['time_description'] = $time_description;
}
if (!empty($array)) {
$database = new database;
$database->app_name = 'contacts';
$database->app_uuid = '04481e0e-a478-c559-adad-52bd4174574c';
$database->save($array);
unset($array);
}
header("Location: contact_timer.php?domain_uuid=".$domain_uuid."&contact_uuid=".$contact_uuid);
}
//get contact details
$sql = "select ";
$sql .= "contact_organization, ";
$sql .= "contact_name_given, ";
$sql .= "contact_name_family, ";
$sql .= "contact_nickname ";
$sql .= "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_organization = $row["contact_organization"];
$contact_name_given = $row["contact_name_given"];
$contact_name_family = $row["contact_name_family"];
$contact_nickname = $row["contact_nickname"];
}
else {
exit;
}
unset($sql, $parameters, $row);
//determine timer state and action
$sql = "select ";
$sql .= "contact_time_uuid, ";
$sql .= "time_description ";
$sql .= "from v_contact_times ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and user_uuid = :user_uuid ";
$sql .= "and contact_uuid = :contact_uuid ";
$sql .= "and time_start is not null ";
$sql .= "and time_stop is null ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['user_uuid'] = $_SESSION['user']['user_uuid'];
$parameters['contact_uuid'] = $contact_uuid ?? '';
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (!empty($row)) {
$contact_time_uuid = $row["contact_time_uuid"];
$time_description = $row["time_description"];
}
unset($sql, $parameters, $row);
$timer_state = is_uuid($contact_time_uuid) ? 'running' : 'stopped';
$timer_action = $timer_state == 'running' ? 'stop' : 'start';
//determine contact name to display
if (!empty($contact_nickname)) {
$contact = $contact_nickname;
}
else if (!empty($contact_name_given)) {
$contact = $contact_name_given;
}
if (!empty($contact_name_family)) {
$contact .= (!empty($contact)) ? ' '.$contact_name_family : $contact_name_family;
}
if (!empty($contact_organization)) {
$contact .= (!empty($contact)) ? ', '.$contact_organization : $contact_organization;
}
//get the browser version
$user_agent = http_user_agent();
$browser_version = $user_agent['version'];
$browser_name = $user_agent['name'];
$browser_version_array = explode('.', $browser_version);
//set the doctype
echo ($browser_name != "Internet Explorer") ? "<!DOCTYPE html>\n" : "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
?>
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
<head>
<title><?php echo $text['label-time_timer']; ?>: <?php echo $contact; ?></title>
<style>
body {
color: #5f5f5f;
font-size: 12px;
font-family: arial;
margin: 0;
padding: 15px;
}
b {
color: #952424;
font-size: 15px;
font-family: arial;
}
a {
color: #004083;
width: 100%;
}
a:hover {
color: #5082ca;
}
form {
margin: 0;
}
input.btn, input.button {
font-family: Candara, Calibri, Segoe, "Segoe UI", Optima, Arial, sans-serif;
padding: 2px 6px 3px 6px;
color: #fff;
font-weight: bold;
cursor: pointer;
font-size: 11px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
-khtml-border-radius: 3px;
border-radius: 3px;
background-image: -moz-linear-gradient(top, #524f59 25%, #000 64%);
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0.25, #524f59), color-stop(0.64, #000));
border: 1px solid #26242a;
background-color: #000;
text-align: center;
text-transform: uppercase;
text-shadow: 0px 0px 1px rgba(0, 0, 0, 0.85);
opacity: 0.9;
-moz-opacity: 0.9;
}
input.btn:hover, input.button:hover, img.list_control_icon:hover {
box-shadow: 0 0 5px #cddaf0;
-webkit-box-shadow: 0 0 5px #cddaf0;
-moz-box-shadow: 0 0 5px #cddaf0;
opacity: 1.0;
-moz-opacity: 1.0;
cursor: pointer;
}
input.txt, textarea.txt, select.txt, .formfld {
font-family: arial;
font-size: 12px;
color: #000;
text-align: left;
padding: 5px;
border: 1px solid #c0c0c0;
background-color: #fff;
box-shadow: 0 0 3px #cddaf0 inset;
-moz-box-shadow: 0 0 3px #cddaf0 inset;
-webkit-box-shadow: 0 0 3px #cddaf0 inset;
border-radius: 3px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
}
input.txt, .formfld {
transition: width 0.25s;
-moz-transition: width 0.25s;
-webkit-transition: width 0.25s;
max-width: 500px;
}
input.txt:focus, .formfld:focus {
-webkit-box-shadow: 0 0 5px #cddaf0;
-moz-box-shadow: 0 0 5px #cddaf0;
box-shadow: 0 0 5px #cddaf0;
}
td {
color: #5f5f5f;
font-size: 12px;
font-family: arial;
}
.vncell {
border-bottom: 1px solid #fff;
background-color: #e5e9f0;
padding: 8px;
text-align: right;
color: #000;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
border-right: 3px solid #e5e9f0;
}
DIV.timer_running {
vertical-align: middle;
padding-top: 7px;
line-height: 50px;
width: 100%;
height: 53px;
text-align: center;
background-color: #2C9DE8;
font-size: 50px;
color: #FFFFFF;
/*-webkit-text-shadow: 0px 0px 5px #000;*/
/*-moz-text-shadow: 0px 0px 5px #000;*/
/*text-shadow: 0px 0px 5px #000;*/
font-weight: bold;
letter-spacing: -0.05em;
font-family: "Courier New",Courier,"Lucida Sans Typewriter","Lucida Typewriter",monospace;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
}
DIV.timer_stopped {
vertical-align: middle;
padding-top: 7px;
line-height: 50px;
width: 100%;
height: 53px;
text-align: center;
background-color: #2C9DE8;
font-size: 50px;
color: #FFFFFF;
/*-webkit-text-shadow: 0px 0px 5px #000;*/
/*-moz-text-shadow: 0px 0px 5px #000;*/
/*text-shadow: 0px 0px 5px #000;*/
font-weight: bold;
letter-spacing: -0.05em;
font-family: "Courier New",Courier,"Lucida Sans Typewriter","Lucida Typewriter",monospace;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
}
</style>
<script language='JavaScript' type='text/javascript' src='<?php echo PROJECT_PATH; ?>/resources/jquery/jquery-3.6.1.min.js'></script>
<script src='https://code.jquery.com/jquery-migrate-3.1.0.js'></script>
<script type="text/javascript">
$(document).ready(function(){
//ajax for refresh
var refresh = 1500;
var source_url = 'contact_timer_inc.php?domain_uuid=<?php echo escape($domain_uuid); ?>&contact_uuid=<?php echo escape($contact_uuid); ?>&contact_time_uuid=<?php echo escape($contact_time_uuid); ?>';
var ajax_get = function () {
$.ajax({
url: source_url, success: function(response){
$("#ajax_reponse").html(response);
}
});
setTimeout(ajax_get, refresh);
};
<?php if ($timer_state == 'running') { ?>
ajax_get();
<?php } ?>
});
//set window title to time when timer is running
function set_title(title_text) {
window.document.title = title_text;
}
</script>
</head>
<body>
<img src='resources/images/icon_timer.png' style='width: 24px; height: 24px; border: none; margin-left: 15px;' alt="<?php echo $text['label-time_timer']; ?>" align='right'>
<b><?php echo $text['label-time_timer']; ?></b>
<br><br>
<?php echo $text['description_timer']; ?>
<br><br>
<strong><a href="javascript:void(0);" onclick="window.opener.location.href='contact_edit.php?id=<?php echo escape($contact_uuid); ?>';"><?php echo escape($contact); ?></a></strong>
<br><br>
<div id='ajax_reponse' class='timer_<?php echo escape($timer_state);?>'>00:00:00</div>
<br>
<form name='frm' id='frm' method='post'>
<input type='hidden' name='domain_uuid' value="<?php echo escape($domain_uuid); ?>">
<input type='hidden' name='contact_time_uuid' value="<?php echo escape($contact_time_uuid); ?>">
<input type='hidden' name='contact_uuid' value="<?php echo escape($contact_uuid); ?>">
<input type='hidden' name='time_action' value="<?php echo escape($timer_action); ?>">
<table cellpadding='0' cellspacing='0' border='0' style='width: 100%;'>
<tr>
<td class='vncell' style='text-align: center; border: none; padding: 0 !important; padding-top: 10px !important;'>
<?php echo $text['label-description']; ?><br>
<textarea name='time_description' id='timer_description' class='formfld' style='width: calc(100% - 30px); height: 50px; margin: 5px 10px 10px;'><?php echo escape($time_description); ?></textarea>
</td>
</tr>
</table>
<br>
<center>
<?php if ($timer_state == 'running') { ?>
<input type='submit' class='btn' value="<?php echo $text['button-stop']; ?>">
<?php } else if ($timer_state == 'stopped') { ?>
<input type='submit' class='btn' value="<?php echo $text['button-start']; ?>">
<?php } ?>
</center>
</form>
<?php if ($timer_state == 'stopped') { ?><script>$('#timer_description').trigger('focus');</script><?php } ?>
</body>
</html>
+60
View File
@@ -0,0 +1,60 @@
<?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-2015
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_time_add')) { echo "access denied"; exit; }
//get contact and time uuids
$domain_uuid = $_REQUEST['domain_uuid'];
$contact_uuid = $_REQUEST['contact_uuid'] ?? '';
$contact_time_uuid = $_REQUEST['contact_time_uuid'];
//get time quantity
$sql = "select ";
$sql .= "time_start ";
$sql .= "from v_contact_times ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and contact_time_uuid = :contact_time_uuid ";
$sql .= "and user_uuid = :user_uuid ";
$sql .= "and contact_uuid = :contact_uuid ";
$sql .= "and time_start is not null ";
$sql .= "and time_stop is null ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['contact_uuid'] = $contact_uuid;
$parameters['user_uuid'] = $_SESSION['user']['user_uuid'];
$parameters['contact_time_uuid'] = $contact_time_uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (!empty($row)) {
$time_start = strtotime($row["time_start"]);
$time_now = strtotime(date("Y-m-d H:i:s"));
$time_diff = gmdate("H:i:s", ($time_now - $time_start));
echo $time_diff;
echo "<script id='title_script'>set_title('".$time_diff."');</script>";
}
unset ($sql, $parameters, $row);
?>
+131
View File
@@ -0,0 +1,131 @@
<?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-2024
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";
//check permissions
if (permission_exists('contact_time_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//set from session variables
$list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false';
//set the uuid
if (!empty($_GET['id']) && is_uuid($_GET['id'])) {
$contact_uuid = $_GET['id'];
}
//get the contact list
$sql = "select ct.*, u.username, u.domain_uuid as user_domain_uuid ";
$sql .= "from v_contact_times as ct, v_users as u ";
$sql .= "where ct.user_uuid = u.user_uuid ";
$sql .= "and ct.domain_uuid = :domain_uuid ";
$sql .= "and ct.contact_uuid = :contact_uuid ";
$sql .= "order by ct.time_start desc ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['contact_uuid'] = $contact_uuid ?? '';
$database = new database;
$contact_times = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//show if exists
if (!empty($contact_times)) {
//show the content
echo "<div class='action_bar sub shrink'>\n";
echo " <div class='heading'><b>".$text['header_contact_times']."</b></div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo "<div class='card'>\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
if (permission_exists('contact_time_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all_times' name='checkbox_all' onclick=\"edit_all_toggle('times');\" ".($contact_times ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
}
echo "<th class='pct-20'>".$text['label-time_user']."</th>\n";
echo "<th class='pct-20'>".$text['label-time_start']."</th>\n";
echo "<th class='pct-20'>".$text['label-time_duration']."</th>\n";
echo "<th class='pct-40 hide-md-dn'>".$text['label-time_description']."</th>\n";
if (permission_exists('contact_time_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
if (!empty($contact_times)) {
$x = 0;
foreach ($contact_times as $row) {
if (!empty($row["time_start"]) && !empty($row['time_stop'])) {
$time_start = strtotime($row["time_start"]);
$time_stop = strtotime($row['time_stop']);
$time = gmdate("H:i:s", ($time_stop - $time_start));
}
else {
unset($time);
}
$tmp = explode(' ', $row['time_start']);
$time_start = $tmp[0];
if (permission_exists('contact_time_edit')) {
$list_row_url = "contact_time_edit.php?contact_uuid=".urlencode($row['contact_uuid'])."&id=".urlencode($row['contact_time_uuid']);
}
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('contact_time_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='contact_times[$x][checked]' id='checkbox_".$x."' class='chk_delete checkbox_times' value='true' onclick=\"edit_delete_action('times');\">\n";
echo " <input type='hidden' name='contact_times[$x][uuid]' value='".escape($row['contact_time_uuid'])."' />\n";
echo " </td>\n";
}
echo " <td><span ".($row['user_domain_uuid'] != $domain_uuid ? "title='".$_SESSION['domains'][escape($row['user_domain_uuid'])]['domain_name']."' style='cursor: help;'" : null).">".escape($row["username"])."</span>&nbsp;</td>\n";
echo " <td>".$time_start."&nbsp;</td>\n";
echo " <td>".$time."&nbsp;</td>\n";
echo " <td class='description overflow hide-md-dn'>".escape($row['time_description'])."&nbsp;</td>\n";
if (permission_exists('contact_time_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n";
}
echo "</tr>\n";
$x++;
}
unset($contact_times);
}
echo "</table>\n";
echo "</div>\n";
echo "<br />\n";
}
?>
+80
View File
@@ -0,0 +1,80 @@
<?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-2020
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";
//check permissions
if (permission_exists('contact_time_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//get the contact list
$sql = "select ct.*, u.username, u.domain_uuid as user_domain_uuid ";
$sql .= "from v_contact_times as ct, v_users as u ";
$sql .= "where ct.user_uuid = u.user_uuid ";
$sql .= "and ct.domain_uuid = :domain_uuid ";
$sql .= "and ct.contact_uuid = :contact_uuid ";
$sql .= "order by ct.time_start desc ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['contact_uuid'] = $contact_uuid;
$database = new database;
$contact_times = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//show if exists
if (is_array($contact_times) && @sizeof($contact_times) != 0) {
//show the content
echo "<div class='grid' style='grid-template-columns: 70px auto auto;'>\n";
$x = 0;
foreach ($contact_times as $row) {
if ($row["time_start"] != '' && $row['time_stop'] != '') {
$time_start = strtotime($row["time_start"]);
$time_stop = strtotime($row['time_stop']);
$time = gmdate("H:i:s", ($time_stop - $time_start));
}
else {
unset($time);
}
$tmp = explode(' ', $row['time_start']);
$time_start = $tmp[0];
echo "<div class='box contact-details-label'><span ".($row['user_domain_uuid'] != $domain_uuid ? "title='".$_SESSION['domains'][escape($row['user_domain_uuid'])]['domain_name']."' style='cursor: help;'" : null).">".escape($row["username"])."</span></div>\n";
echo "<div class='box'>".$time_start."</div>\n";
echo "<div class='box'>".$time."</div>\n";
$x++;
}
echo "</div>\n";
unset($contact_times);
}
?>
+332
View File
@@ -0,0 +1,332 @@
<?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-2024
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('contact_url_edit') || permission_exists('contact_url_add')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//set the defaults
$url_label = '';
$url_label_custom = '';
$url_address = '';
$url_primary = '';
$url_description = '';
//action add or update
if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
$action = "update";
$contact_url_uuid = $_REQUEST["id"];
}
else {
$action = "add";
}
//get the contact uuid
if (!empty($_GET["contact_uuid"]) && is_uuid($_GET["contact_uuid"])) {
$contact_uuid = $_GET["contact_uuid"];
}
//get http post variables and set them to php variables
if (!empty($_POST)) {
$url_label = $_POST["url_label"];
$url_label_custom = $_POST["url_label_custom"];
$url_address = $_POST["url_address"];
$url_primary = $_POST["url_primary"];
$url_description = $_POST["url_description"];
//use custom label if set
$url_label = !empty($url_label_custom) ? $url_label_custom : $url_label;
}
//process the form data
if (!empty($_POST) && empty($_POST["persistformvar"])) {
//set the uuid
if ($action == "update") {
$contact_url_uuid = $_POST["contact_url_uuid"];
}
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: contacts.php');
exit;
}
//check for all required data
$msg = '';
if (!empty($msg) && empty($_POST["persistformvar"])) {
require_once "resources/header.php";
require_once "resources/persist_form_var.php";
echo "<div align='center'>\n";
echo "<table><tr><td>\n";
echo $msg."<br />";
echo "</td></tr></table>\n";
persistformvar($_POST);
echo "</div>\n";
require_once "resources/footer.php";
return;
}
//add or update the database
if (empty($_POST["persistformvar"])) {
//update last modified
$array['contacts'][0]['contact_uuid'] = $contact_uuid;
$array['contacts'][0]['domain_uuid'] = $domain_uuid;
$array['contacts'][0]['last_mod_date'] = 'now()';
$array['contacts'][0]['last_mod_user'] = $_SESSION['username'];
$p = new permissions;
$p->add('contact_edit', 'temp');
$database = new database;
$database->app_name = 'contacts';
$database->app_uuid = '04481e0e-a478-c559-adad-52bd4174574c';
$database->save($array);
unset($array);
$p->delete('contact_edit', 'temp');
//if primary, unmark other primary urls
if ($url_primary) {
$sql = "update v_contact_urls set url_primary = 0 ";
$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;
$database->execute($sql, $parameters ?? null);
unset($sql, $parameters);
}
if ($action == "add" && permission_exists('contact_url_add')) {
$contact_url_uuid = uuid();
$array['contact_urls'][0]['contact_url_uuid'] = $contact_url_uuid;
message::add($text['message-add']);
}
if ($action == "update" && permission_exists('contact_url_edit')) {
$array['contact_urls'][0]['contact_url_uuid'] = $contact_url_uuid;
message::add($text['message-update']);
}
if (!empty($array)) {
$array['contact_urls'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
$array['contact_urls'][0]['contact_uuid'] = $contact_uuid;
$array['contact_urls'][0]['url_label'] = $url_label;
$array['contact_urls'][0]['url_address'] = $url_address;
$array['contact_urls'][0]['url_primary'] = $url_primary ? 1 : 0;
$array['contact_urls'][0]['url_description'] = $url_description;
$database = new database;
$database->app_name = 'contacts';
$database->app_uuid = '04481e0e-a478-c559-adad-52bd4174574c';
$database->save($array);
unset($array);
}
header("Location: contact_edit.php?id=".$contact_uuid);
exit;
}
}
//pre-populate the form
if (!empty($_GET) && empty($_POST["persistformvar"])) {
$contact_url_uuid = $_GET["id"] ?? '';
$sql = "select * from v_contact_urls ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and contact_url_uuid = :contact_url_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['contact_url_uuid'] = $contact_url_uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (!empty($row)) {
$url_label = $row["url_label"];
$url_address = $row["url_address"];
$url_primary = $row["url_primary"];
$url_description = $row["url_description"];
}
unset($sql, $parameters, $row);
}
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//show the header
if ($action == "update") {
$document['title'] = $text['title-contact_url-edit'];
}
else if ($action == "add") {
$document['title'] = $text['title-contact_url-add'];
}
require_once "resources/header.php";
//javascript to toggle input/select boxes
echo "<script type='text/javascript'>";
echo " function toggle_custom(field) {";
echo " $('#'+field).toggle();";
echo " document.getElementById(field).selectedIndex = 0;";
echo " document.getElementById(field+'_custom').value = '';";
echo " $('#'+field+'_custom').toggle();";
echo " if ($('#'+field+'_custom').is(':visible')) { $('#'+field+'_custom').trigger('focus'); } else { $('#'+field).trigger('focus'); }";
echo " }";
echo "</script>";
//show the content
echo "<form method='post' name='frm' id='frm'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'>";
if ($action == "update") {
echo "<b>".$text['header-contact_url-edit']."</b>";
}
else if ($action == "add") {
echo "<b>".$text['header-contact_url-add']."</b>";
}
echo " </div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'contact_edit.php?id='.urlencode($contact_uuid ?? '')]);
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
if ($action == "update") {
echo $text['description-contact_url-edit'];
}
else if ($action == "add") {
echo $text['description-contact_url-add'];
}
echo "<br /><br />\n";
echo "<div class='card'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-url_label']."\n";
echo "</td>\n";
echo "<td width='70%' class='vtable' align='left'>\n";
if (!empty($_SESSION["contact"]["url_label"])) {
sort($_SESSION["contact"]["url_label"]);
foreach($_SESSION["contact"]["url_label"] as $row) {
$url_label_options[] = "<option value='".$row."' ".(($row == $url_label) ? "selected='selected'" : null).">".$row."</option>";
}
$url_label_found = (in_array($url_label, $_SESSION["contact"]["url_label"])) ? true : false;
}
else {
$selected[$url_label] = "selected";
$default_labels[] = $text['option-work'];
$default_labels[] = $text['option-personal'];
$default_labels[] = $text['option-other'];
foreach ($default_labels as $default_label) {
$url_label_options[] = "<option value='".$default_label."' ".!empty($selected[$default_label]).">".$default_label."</option>";
}
$url_label_found = (in_array($url_label, $default_labels)) ? true : false;
}
echo " <select class='formfld' ".((!empty($url_label) && !$url_label_found) ? "style='display: none;'" : null)." name='url_label' id='url_label' onchange=\"getElementById('url_label_custom').value='';\">\n";
echo " <option value=''></option>\n";
echo (!empty($url_label_options)) ? implode("\n", $url_label_options) : null;
echo " </select>\n";
echo " <input type='text' class='formfld' ".((empty($url_label) || $url_label_found) ? "style='display: none;'" : null)." name='url_label_custom' id='url_label_custom' value=\"".((!$url_label_found) ? htmlentities($url_label ?? '') : null)."\">\n";
echo " <input type='button' id='btn_toggle_label' class='btn' alt='".$text['button-back']."' value='&#9665;' onclick=\"toggle_custom('url_label');\">\n";
echo "<br />\n";
echo !empty($text['description-url_label'])."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-url_address']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='url' name='url_address' maxlength='255' value=\"".escape($url_address)."\" placeholder='http://...'>\n";
echo "<br />\n";
echo !empty($text['description-url_address'])."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-primary']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='url_primary' id='url_primary'>\n";
echo " <option value='0'>".$text['option-false']."</option>\n";
echo " <option value='1' ".(($url_primary) ? "selected" : null).">".$text['option-true']."</option>\n";
echo " </select>\n";
echo "<br />\n";
echo $text['description-url_primary']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-url_description']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='url_description' maxlength='255' value=\"".escape($url_description)."\">\n";
echo "<br />\n";
echo !empty($text['description-url_description'])."\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>";
echo "</div>\n";
echo "<br><br>";
echo "<input type='hidden' name='contact_uuid' value='".escape($contact_uuid ?? '')."'>\n";
if ($action == "update") {
echo "<input type='hidden' name='contact_url_uuid' value='".escape($contact_url_uuid)."'>\n";
}
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>";
//include the footer
require_once "resources/footer.php";
?>
+114
View File
@@ -0,0 +1,114 @@
<?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-2024
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";
//check permissions
if (permission_exists('contact_url_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//set the uuid
if (!empty($_GET['id']) && is_uuid($_GET['id'])) {
$contact_uuid = $_GET['id'];
}
//get the contact list
$sql = "select * from v_contact_urls ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and contact_uuid = :contact_uuid ";
$sql .= "order by url_primary desc, url_label asc ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['contact_uuid'] = $contact_uuid ?? '';
$database = new database;
$contact_urls = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//show if exists
if (!empty($contact_urls)) {
//show the content
echo "<div class='action_bar sub shrink'>\n";
echo " <div class='heading'><b>".$text['label-urls']."</b></div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo "<div class='card'>\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
if (permission_exists('contact_url_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all_urls' name='checkbox_all' onclick=\"edit_all_toggle('urls');\" ".($contact_urls ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
}
echo "<th class='pct-15'>".$text['label-url_label']."</th>\n";
echo "<th>".$text['label-url_address']."</th>\n";
echo "<th class='hide-md-dn'>".$text['label-url_description']."</th>\n";
if (permission_exists('contact_url_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
if (!empty($contact_urls)) {
$x = 0;
foreach ($contact_urls as $row) {
if (permission_exists('contact_url_edit')) {
$list_row_url = "contact_url_edit.php?contact_uuid=".urlencode($row['contact_uuid'])."&id=".urlencode($row['contact_url_uuid']);
}
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('contact_url_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='contact_urls[$x][checked]' id='checkbox_".$x."' class='chk_delete checkbox_urls' value='true' onclick=\"edit_delete_action('urls');\">\n";
echo " <input type='hidden' name='contact_urls[$x][uuid]' value='".escape($row['contact_url_uuid'])."' />\n";
echo " </td>\n";
}
echo " <td>".escape($row['url_label'])." ".($row['url_primary'] ? "&nbsp;<i class='fas fa-star fa-xs' style='float: right; margin-top: 0.5em; margin-right: -0.5em;' title=\"".$text['label-primary']."\"></i>" : null)."</td>\n";
echo " <td class='no-link overflow no-wrap'><a href='".escape($row['url_address'])."' target='_blank'>".str_replace("http://", "", str_replace("https://", "", escape($row['url_address'])))."</a></td>\n";
echo " <td class='description overflow hide-md-dn'>".escape($row['url_description'])."&nbsp;</td>\n";
if (permission_exists('contact_url_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n";
}
echo "</tr>\n";
$x++;
}
}
unset($contact_urls);
echo "</table>\n";
echo "</div>\n";
echo "<br />\n";
}
?>
+68
View File
@@ -0,0 +1,68 @@
<?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-2020
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";
//check permissions
if (permission_exists('contact_url_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//get the contact list
$sql = "select * from v_contact_urls ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and contact_uuid = :contact_uuid ";
$sql .= "order by url_primary desc, url_label asc ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['contact_uuid'] = $contact_uuid ?? '';
$database = new database;
$contact_urls = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//show if exists
if (!empty($contact_urls)) {
//show the content
echo "<div class='grid' style='grid-template-columns: 70px auto;'>\n";
$x = 0;
foreach ($contact_urls as $row) {
echo "<div class='box contact-details-label'>".escape($row['url_label'])."</div>\n";
// ($row['url_primary'] ? "&nbsp;<i class='fas fa-star fa-xs' style='float: right; margin-top: 0.5em; margin-right: -0.5em;' title=\"".$text['label-primary']."\"></i>" : null)."</td>\n";
echo "<div class='box'><a href='".escape($row['url_address'])."' target='_blank'>".escape(str_replace(['http://','https://'], '', $row['url_address']))."</a></div>\n";
$x++;
}
echo "</div>\n";
unset($contact_urls);
}
?>
+550
View File
@@ -0,0 +1,550 @@
<?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-2023
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";
//check permissions
if (permission_exists('contact_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//connect to the database
$database = new database;
//add multi-lingual support
$language = new text;
$text = $language->get();
//action add or update
if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
$contact_uuid = $_REQUEST["id"];
}
else {
header("Location: contacts.php");
}
//main contact details
$sql = "select * from v_contacts ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and contact_uuid = :contact_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['contact_uuid'] = $contact_uuid;
$row = $database->select($sql, $parameters, 'row');
if (!empty($row)) {
$contact_type = $row["contact_type"];
$contact_organization = $row["contact_organization"];
$contact_name_prefix = $row["contact_name_prefix"];
$contact_name_given = $row["contact_name_given"];
$contact_name_middle = $row["contact_name_middle"];
$contact_name_family = $row["contact_name_family"];
$contact_name_suffix = $row["contact_name_suffix"];
$contact_nickname = $row["contact_nickname"];
$contact_title = $row["contact_title"];
$contact_category = $row["contact_category"];
$contact_role = $row["contact_role"];
$contact_time_zone = $row["contact_time_zone"];
$contact_note = $row["contact_note"];
}
unset($sql, $parameters, $row);
//get the available users for this contact
$sql = "select * from v_users ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "order by username asc ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$users = $database->select($sql, $parameters ?? null, 'all');
unset($sql, $parameters);
//determine if contact assigned to a user
if (!empty($users)) {
foreach ($users as $user) {
if ($user['contact_uuid'] == $contact_uuid) {
$contact_user_uuid = $user['user_uuid'];
break;
}
}
}
//get the assigned users that can view this contact
$sql = "select u.username, u.user_uuid, a.contact_user_uuid from v_contacts as c, v_users as u, v_contact_users as a ";
$sql .= "where c.contact_uuid = :contact_uuid ";
$sql .= "and c.domain_uuid = :domain_uuid ";
$sql .= "and u.user_uuid = a.user_uuid ";
$sql .= "and c.contact_uuid = a.contact_uuid ";
$sql .= "order by u.username asc ";
$parameters['contact_uuid'] = $contact_uuid;
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$contact_users_assigned = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//get the assigned groups that can view this contact
$sql = "select g.*, cg.contact_group_uuid ";
$sql .= "from v_groups as g, v_contact_groups as cg ";
$sql .= "where cg.group_uuid = g.group_uuid ";
$sql .= "and cg.domain_uuid = :domain_uuid ";
$sql .= "and cg.contact_uuid = :contact_uuid ";
$sql .= "and cg.group_uuid <> :group_uuid ";
$sql .= "order by g.group_name asc ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['contact_uuid'] = $contact_uuid;
$parameters['group_uuid'] = $_SESSION["user_uuid"];
$contact_groups_assigned = $database->select($sql, $parameters, 'all');
if (!empty($contact_groups_assigned)) {
foreach ($contact_groups_assigned as $field) {
$contact_groups[] = "'".$field['group_uuid']."'";
}
}
unset($sql, $parameters);
//get the available groups for this contact
$sql = "select group_uuid, group_name from v_groups ";
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
if (!empty($contact_groups)) {
$sql .= "and group_uuid not in (".implode(',', $contact_groups).") ";
}
$sql .= "order by group_name asc ";
$parameters['domain_uuid'] = $domain_uuid;
$contact_groups_available = $database->select($sql, $parameters, 'all');
unset($sql, $parameters, $contact_groups);
//determine title name
if ($contact_name_given || $contact_name_family) {
$contact_name = $contact_name_prefix ? escape($contact_name_prefix).' ' : null;
$contact_name .= $contact_name_given ? escape($contact_name_given).' ' : null;
$contact_name .= $contact_name_middle ? escape($contact_name_middle).' ' : null;
$contact_name .= $contact_name_family ? escape($contact_name_family).' ' : null;
$contact_name .= $contact_name_suffix ? escape($contact_name_suffix).' ' : null;
}
else {
$contact_name = $contact_organization;
}
//show the header
$document['title'] = $text['title-contact-edit'].($contact_name ? ': '.$contact_name : null);
require_once "resources/header.php";
//determine qr branding
if (!empty($_SESSION['theme']['qr_brand_type']['text']) && !empty($_SESSION['theme']['qr_brand_image']['text']) && $_SESSION['theme']['qr_brand_type']['text'] == 'image') {
echo "<img id='img-buffer' style='display: none;' src='".$_SESSION["theme"]["qr_brand_image"]["text"]."'>";
$qr_option = "image: $('#img-buffer')[0],";
$qr_mode = '4';
$qr_size = '0.2';
}
elseif (!empty($_SESSION['theme']['qr_brand_type']['text']) && empty($_SESSION['theme']['qr_brand_image']['text']) && $_SESSION['theme']['qr_brand_type']['text'] == 'image') {
$qr_option = '';
$qr_mode = '3';
$qr_size = '0';
}
elseif (!empty($_SESSION['theme']['qr_brand_type']['text']) && !empty($_SESSION['theme']['qr_brand_text']['text']) && $_SESSION['theme']['qr_brand_type']['text'] == 'text') {
$qr_option = 'label: "'.$_SESSION['theme']['qr_brand_text']['text'].'"';
$qr_mode = '2';
$qr_size = '0.05';
}
elseif (!empty($_SESSION['theme']['qr_brand_type']['text']) && $_SESSION['theme']['qr_brand_type']['text'] == 'none') {
$qr_option = '';
$qr_mode = '3';
$qr_size = '0';
}
else {
echo "<img id='img-buffer' style='display: none;' src='".PROJECT_PATH."/themes/".$_SESSION["domain"]["template"]["name"]."/images/qr_code.png'>";
$qr_option = "image: $('#img-buffer')[0],";
$qr_mode = '4';
$qr_size = '0.2';
}
//qr code generation
$_GET['type'] = "text";
$qr_vcard = true;
include "contacts_vcard.php";
echo "<input type='hidden' id='qr_vcard' value=\"".$qr_vcard."\">";
echo "<style>";
echo " #qr_code_container {";
echo " z-index: 999999; ";
echo " position: fixed; ";
echo " left: 0; ";
echo " top: 0; ";
echo " right: 0; ";
echo " bottom: 0; ";
echo " text-align: center; ";
echo " vertical-align: middle;";
echo " }";
echo " #qr_code {";
echo " display: block; ";
echo " width: 100%; ";
echo " max-width: 650px; ";
echo " height: auto; ";
echo " -webkit-box-shadow: 0px 1px 20px #888; ";
echo " -moz-box-shadow: 0px 1px 20px #888; ";
echo " box-shadow: 0px 1px 20px #888;";
echo " }";
echo " #qr_code > img {";
echo " width: 100%; ";
echo " max-width: 650px; ";
echo " height: auto; ";
echo " }";
echo "</style>";
echo "<script src='".PROJECT_PATH."/resources/jquery/jquery-qrcode.min.js'></script>";
echo "<script language='JavaScript' type='text/javascript'>";
echo " $(document).ready(function() {";
echo " $('#qr_code').qrcode({ ";
echo " render: 'image', ";
echo " minVersion: 6, ";
echo " maxVersion: 40, ";
echo " ecLevel: 'H', ";
echo " size: 650, ";
echo " radius: 0.2, ";
echo " quiet: 6, ";
echo " background: '#fff', ";
echo " mode: ".$qr_mode.", ";
echo " mSize: ".$qr_size.", ";
echo " mPosX: 0.5, ";
echo " mPosY: 0.5, ";
echo " text: document.getElementById('qr_vcard').value, ";
echo " ".$qr_option;
echo " });";
echo " });";
echo "</script>";
//show the content
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".($contact_name ? $contact_name : $text['header-contact-edit'])."</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','collapse'=>'hide-sm-dn','style'=>'margin-right: 15px;','link'=>'contacts.php']);
if (permission_exists('contact_time_add')) {
//detect timer state (and start time)
$sql = "select ";
$sql .= "time_start ";
$sql .= "from v_contact_times ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and user_uuid = :user_uuid ";
$sql .= "and contact_uuid = :contact_uuid ";
$sql .= "and time_start is not null ";
$sql .= "and time_stop is null ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['user_uuid'] = $_SESSION['user']['user_uuid'];
$parameters['contact_uuid'] = $contact_uuid;
$time_start = $database->select($sql, $parameters ?? null, 'column');
$btn_style = $time_start ? 'color: #fff; background-color: #3693df; background-image: none;' : null;
unset($sql, $parameters);
echo button::create(['type'=>'button','label'=>$text['button-timer'],'icon'=>'clock','style'=>$btn_style,'title'=>$time_start,'collapse'=>'hide-sm-dn','onclick'=>"window.open('contact_timer.php?domain_uuid=".urlencode($domain_uuid)."&contact_uuid=".urlencode($contact_uuid)."','contact_time_".escape($contact_uuid)."','width=300, height=375, top=30, left='+(screen.width - 350)+', menubar=no, scrollbars=no, status=no, toolbar=no, resizable=no');"]);
}
echo button::create(['type'=>'button','label'=>$text['button-qr_code'],'icon'=>'qrcode','collapse'=>'hide-sm-dn','onclick'=>"$('#qr_code_container').fadeIn(400);"]);
echo button::create(['type'=>'button','label'=>$text['button-vcard'],'icon'=>'address-card','collapse'=>'hide-sm-dn','link'=>'contacts_vcard.php?id='.urlencode($contact_uuid).'&type=download']);
if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/invoices')) {
echo button::create(['type'=>'button','label'=>$text['button-invoices'],'icon'=>'file-invoice-dollar','collapse'=>'hide-sm-dn','link'=>'../invoices/invoices.php?id='.urlencode($contact_uuid)]);
}
if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/certificates')) {
echo button::create(['type'=>'button','label'=>$text['button-certificate'],'icon'=>'certificate','collapse'=>'hide-sm-dn','link'=>'../certificates/index.php?name='.urlencode($contact_name_given." ".$contact_name_family)]);
}
if (!empty($contact_user_uuid) && permission_exists('user_edit') && is_uuid($contact_user_uuid)) {
echo button::create(['type'=>'button','label'=>$text['button-user'],'icon'=>'user','collapse'=>'hide-sm-dn','link'=>'../../core/users/user_edit.php?id='.urlencode($contact_user_uuid)]);
}
if (
permission_exists('contact_phone_add') ||
permission_exists('contact_address_add') ||
permission_exists('contact_email_add') ||
permission_exists('contact_url_add') ||
permission_exists('contact_relation_add') ||
permission_exists('contact_note_add') ||
permission_exists('contact_time_add') ||
permission_exists('contact_setting_add') ||
permission_exists('contact_attachment_add')
) {
echo "<select class='formfld' style='width: auto; margin-left: 15px;' id='select_add' onchange=\"document.location.href='contact_' + (this.options[this.selectedIndex].value) + '_edit.php?contact_uuid=".urlencode($contact_uuid)."';\">\n";
echo " <option value=''>".$text['button-add']."...</option>\n";
if (permission_exists('contact_phone_add')) { echo "<option value='phone'>".$text['label-phone_number']."</option>\n"; }
if (permission_exists('contact_address_add')) { echo "<option value='address'>".$text['label-address_address']."</option>\n"; }
if (permission_exists('contact_email_add')) { echo "<option value='email'>".$text['label-email']."</option>\n"; }
if (permission_exists('contact_url_add')) { echo "<option value='url'>".$text['label-url']."</option>\n"; }
if (permission_exists('contact_relation_add')) { echo "<option value='relation'>".$text['label-contact_relation_label']."</option>\n"; }
if (permission_exists('contact_note_add')) { echo "<option value='note'>".$text['label-contact_note']."</option>\n"; }
if (permission_exists('contact_time_add')) { echo "<option value='time'>".$text['label-time_time']."</option>\n"; }
if (permission_exists('contact_setting_add')) { echo "<option value='setting'>".$text['label-setting']."</option>\n"; }
if (permission_exists('contact_attachment_add')) { echo "<option value='attachment'>".$text['label-attachment']."</option>\n"; }
echo " </select>";
}
if (permission_exists('contact_edit')) {
echo button::create(['type'=>'button','label'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'id'=>'btn_edit','style'=>'margin-left: 15px;','collapse'=>'hide-sm-dn','link'=>'contact_edit.php?id='.urlencode($contact_uuid)]);
}
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
if (
!empty($action) &&
$action == "update" && (
permission_exists('contact_delete') ||
permission_exists('contact_user_delete') ||
permission_exists('contact_group_delete') ||
permission_exists('contact_phone_delete') ||
permission_exists('contact_address_delete') ||
permission_exists('contact_email_delete') ||
permission_exists('contact_url_delete') ||
permission_exists('contact_relation_delete') ||
permission_exists('contact_note_delete') ||
permission_exists('contact_time_delete') ||
permission_exists('contact_setting_delete') ||
permission_exists('contact_attachment_delete')
)) {
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'delete','onclick'=>"modal_close();"])]);
}
if ($contact_title || $contact_organization) {
echo ($contact_title ? '<i>'.$contact_title.'</i>' : null).($contact_title && $contact_organization ? ', ' : null).($contact_organization ? '<strong>'.$contact_organization.'</strong>' : null)."\n";
}
else {
echo $contact_note."\n";
}
echo "<br /><br />\n";
echo "<div class='grid' style='grid-gap: 15px; grid-template-columns: repeat(auto-fill, minmax(375px, 1fr));'>\n";
//general info
echo " <div class='box contact-details'>\n";
echo " <div class='grid contact-details'>\n";
echo " <div class='box'><b class='fas fa-user fa-fw fa-lg'></b></div>\n";
echo " <div class='box'>\n";
echo " <div class='grid' style='grid-template-columns: 70px auto;'>\n";
//nickname
if ($contact_nickname) {
echo "<div class='box contact-details-label'>".$text['label-contact_nickname']."</div>\n";
echo "<div class='box'>\"".escape($contact_nickname)."\"</div>\n";
}
//name
if ($contact_name_given) {
echo "<div class='box contact-details-label'>".$text['label-name']."</div>\n";
echo "<div class='box'>".escape($contact_name_given).(!empty($contact_name_family) ? ' '.escape($contact_name_family) : null)."</div>\n";
}
//contact type
if ($contact_type) {
echo "<div class='box contact-details-label'>".$text['label-contact_type']."</div>\n";
echo "<div class='box'>";
if (!empty($_SESSION["contact"]["type"])) {
sort($_SESSION["contact"]["type"]);
foreach ($_SESSION["contact"]["type"] as $type) {
if ($contact_type == $type) {
echo escape($type);
}
}
}
else if ($text['option-contact_type_'.$contact_type]) {
echo $text['option-contact_type_'.$contact_type];
}
else {
echo escape($contact_type);
}
echo "</div>\n";
}
//category
if ($contact_category) {
echo "<div class='box contact-details-label'>".$text['label-contact_category']."</div>\n";
echo "<div class='box'>";
if (!empty($_SESSION["contact"]["category"])) {
sort($_SESSION["contact"]["category"]);
foreach ($_SESSION["contact"]["category"] as $category) {
if ($contact_category == $category) {
echo escape($category);
break;
}
}
}
else {
echo escape($contact_category);
}
echo "</div>\n";
}
//role
if ($contact_role) {
echo "<div class='box contact-details-label'>".$text['label-contact_role']."</div>\n";
echo "<div class='box'>";
if (!empty($_SESSION["contact"]["role"])) {
sort($_SESSION["contact"]["role"]);
foreach ($_SESSION["contact"]["role"] as $role) {
if ($contact_role == $role) {
echo escape($role);
break;
}
}
}
else {
echo escape($contact_role);
}
echo "</div>\n";
}
//time_zone
if ($contact_time_zone) {
echo "<div class='box contact-details-label'>".$text['label-contact_time_zone']."</div>\n";
echo "<div class='box'>";
echo $contact_time_zone."<br>\n";
echo "</div>\n";
}
//users (viewing contact)
if (permission_exists('contact_user_view') && !empty($contact_users_assigned)) {
echo "<div class='box contact-details-label'>".$text['label-users']."</div>\n";
echo "<div class='box'>";
foreach ($contact_users_assigned as $field) {
echo escape($field['username'])."<br>\n";
}
echo "</div>\n";
}
//groups (viewing contact)
if (permission_exists('contact_group_view') && !empty($contact_groups_assigned)) {
echo "<div class='box contact-details-label'>".$text['label-groups']."</div>\n";
echo "<div class='box'>";
foreach ($contact_groups_assigned as $field) {
echo escape($field['group_name'])."<br>\n";
}
echo "</div>\n";
}
echo " </div>\n";
echo " </div>\n";
echo " </div>\n";
echo " </div>\n";
//numbers
if (permission_exists('contact_phone_view')) {
echo " <div class='box contact-details'>\n";
echo " <div class='grid contact-details'>\n";
echo " <div class='box' title=\"".$text['label-phone_numbers']."\"><b class='fas fa-hashtag fa-fw fa-lg'></b></div>\n";
echo " <div class='box'>\n";
require 'contact_phones_view.php';
echo " </div>\n";
echo " </div>\n";
echo " </div>\n";
}
//emails
if (permission_exists('contact_email_view')) {
echo " <div class='box contact-details'>\n";
echo " <div class='grid contact-details'>\n";
echo " <div class='box' title=\"".$text['label-emails']."\"><b class='fas fa-envelope fa-fw fa-lg'></b></div>\n";
echo " <div class='box'>\n";
require 'contact_emails_view.php';
echo " </div>\n";
echo " </div>\n";
echo " </div>\n";
}
//addresses
if (permission_exists('contact_address_view')) {
echo " <div class='box contact-details'>\n";
echo " <div class='grid contact-details'>\n";
echo " <div class='box' title=\"".$text['label-addresses']."\"><b class='fas fa-map-marker-alt fa-fw fa-lg'></b></div>\n";
echo " <div class='box'>\n";
require 'contact_addresses_view.php';
echo " </div>\n";
echo " </div>\n";
echo " </div>\n";
}
//urls
if (permission_exists('contact_url_view')) {
echo " <div class='box contact-details'>\n";
echo " <div class='grid contact-details'>\n";
echo " <div class='box' title=\"".$text['label-urls']."\"><b class='fas fa-link fa-fw fa-lg'></b></div>\n";
echo " <div class='box'>\n";
require "contact_urls_view.php";
echo " </div>\n";
echo " </div>\n";
echo " </div>\n";
}
//relations
if (permission_exists('contact_relation_view')) {
echo " <div class='box contact-details'>\n";
echo " <div class='grid contact-details'>\n";
echo " <div class='box' title=\"".$text['header-contact_relations']."\"><b class='fas fa-diagram-project fa-fw fa-lg'></b></div>\n";
echo " <div class='box'>\n";
require "contact_relations_view.php";
echo " </div>\n";
echo " </div>\n";
echo " </div>\n";
}
//attachments
if (permission_exists('contact_attachment_view')) {
echo " <div class='box contact-details'>\n";
echo " <div class='grid contact-details'>\n";
echo " <div class='box' title=\"".$text['label-attachments']."\"><b class='fas fa-paperclip fa-fw fa-lg'></b></div>\n";
echo " <div class='box'>\n";
require "contact_attachments_view.php";
echo " </div>\n";
echo " </div>\n";
echo " </div>\n";
}
//times
if (permission_exists('contact_time_view')) {
echo " <div class='box contact-details'>\n";
echo " <div class='grid contact-details'>\n";
echo " <div class='box' title=\"".$text['header_contact_times']."\"><b class='fas fa-clock fa-fw fa-lg'></b></div>\n";
echo " <div class='box'>\n";
require "contact_times_view.php";
echo " </div>\n";
echo " </div>\n";
echo " </div>\n";
}
//extensions
if (permission_exists('contact_extension_view')) {
echo " <div class='box contact-details'>\n";
echo " <div class='grid contact-details'>\n";
echo " <div class='box' title=\"".$text['label-contact_extensions']."\"><b class='fas fa-fax fa-fw fa-lg'></b></div>\n";
echo " <div class='box'>\n";
require "contact_extensions_view.php";
echo " </div>\n";
echo " </div>\n";
echo " </div>\n";
}
echo "</div>\n";
echo "<div class='grid' style='margin-top: 15px; grid-template-columns: auto;'>\n";
//notes
if (permission_exists('contact_note_view')) {
echo " <div class='box contact-details'>\n";
echo " <div class='grid contact-details'>\n";
echo " <div class='box' title=\"".$text['label-contact_notes']."\"><b class='fas fa-sticky-note fa-fw fa-lg'></b></div>\n";
echo " <div class='box'>\n";
require "contact_notes_view.php";
echo " </div>\n";
echo " </div>\n";
echo " </div>\n";
}
echo "</div>\n";
echo "<br><br>\n";
//include the footer
require_once "resources/footer.php";
?>
+471
View File
@@ -0,0 +1,471 @@
<?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-2024
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";
require_once "resources/paging.php";
//check permissions
if (permission_exists('contact_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//set additional variables
$show = $_GET["show"] ?? '';
//set from session variables
$list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false';
//get posted data
if (!empty($_POST['contacts'])) {
$action = $_POST['action'];
$search = $_POST['search'];
$contacts = $_POST['contacts'];
}
//process the http post data by action
if (!empty($action) && !empty($contacts)) {
switch ($action) {
case 'delete':
if (permission_exists('contact_delete')) {
$obj = new contacts;
$obj->delete($contacts);
}
break;
}
header('Location: contacts.php'.(!empty($search) ? '?search='.urlencode($search) : null));
exit;
}
//retrieve current user's assigned groups (uuids)
foreach ($_SESSION['groups'] as $group_data) {
$user_group_uuids[] = $group_data['group_uuid'];
}
//add user's uuid to group uuid list to include private (non-shared) contacts
$user_group_uuids[] = $_SESSION["user_uuid"];
//get contact settings - sync sources
$sql = "select contact_uuid, contact_setting_value ";
$sql .= "from v_contact_settings ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and contact_setting_category = 'sync' ";
$sql .= "and contact_setting_subcategory = 'source' ";
$sql .= "and contact_setting_name = 'array' ";
$sql .= "and contact_setting_value <> '' ";
$sql .= "and contact_setting_value is not null ";
if (!permission_exists('contact_domain_view')) {
$sql .= "and ( "; //only contacts assigned to current user's group(s) and those not assigned to any group
$sql .= " contact_uuid in ( ";
$sql .= " select contact_uuid from v_contact_groups ";
$sql .= " where ";
if (!empty($user_group_uuids)) {
foreach ($user_group_uuids as $index => $user_group_uuid) {
if (is_uuid($user_group_uuid)) {
$sql_where_or[] = "group_uuid = :group_uuid_".$index;
$parameters['group_uuid_'.$index] = $user_group_uuid;
}
}
if (!empty($sql_where_or)) {
$sql .= " ( ".implode(' or ', $sql_where_or)." ) ";
}
unset($sql_where_or, $index, $user_group_uuid);
}
$sql .= " and domain_uuid = :domain_uuid ";
$sql .= " ) ";
$sql .= " or ";
$sql .= " contact_uuid not in ( ";
$sql .= " select contact_uuid from v_contact_groups ";
$sql .= " where group_uuid = :group_uuid ";
$sql .= " and domain_uuid = :domain_uuid ";
$sql .= " ) ";
$sql .= ") ";
}
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['group_uuid'] = $_SESSION['group_uuid'] ?? '';
$database = new database;
$result = $database->select($sql, $parameters, 'all');
if (!empty($result)) {
foreach($result as $row) {
$contact_sync_sources[$row['contact_uuid']][] = $row['contact_setting_value'];
}
}
unset($sql, $parameters, $result);
//get variables used to control the order
$order_by = $_GET["order_by"] ?? '';
$order = $_GET["order"] ?? '';
//add the search term
$search = strtolower(trim($_GET["search"]) ?? '');
if (!empty($search)) {
if (is_numeric($search)) {
$sql_search = "and contact_uuid in ( ";
$sql_search .= " select contact_uuid from v_contact_phones ";
$sql_search .= " where ( ";
$sql_search .= " concat(phone_country_code, phone_number) like :search ";
$sql_search .= " or phone_number like :search ";
$sql_search .= " ) ";
$sql_search .= ") ";
}
else {
//open container
$sql_search = "and ( ";
//search contact
$sql_search .= "contact_uuid in ( ";
$sql_search .= " select contact_uuid from v_contacts ";
$sql_search .= " where domain_uuid = :domain_uuid ";
$sql_search .= " and ( ";
$sql_search .= " lower(contact_organization) like :search or ";
$sql_search .= " lower(contact_name_given) like :search or ";
$sql_search .= " lower(contact_name_family) like :search or ";
$sql_search .= " lower(contact_nickname) like :search or ";
$sql_search .= " lower(contact_title) like :search or ";
$sql_search .= " lower(contact_category) like :search or ";
$sql_search .= " lower(contact_role) like :search or ";
$sql_search .= " lower(contact_url) like :search or ";
$sql_search .= " lower(contact_time_zone) like :search or ";
$sql_search .= " lower(contact_note) like :search or ";
$sql_search .= " lower(contact_type) like :search ";
$sql_search .= " ) ";
$sql_search .= ") ";
//search contact emails
if (permission_exists('contact_email_view')) {
$sql_search .= "or contact_uuid in ( ";
$sql_search .= " select contact_uuid from v_contact_emails ";
$sql_search .= " where domain_uuid = :domain_uuid ";
$sql_search .= " and ( ";
$sql_search .= " lower(email_address) like :search or ";
$sql_search .= " lower(email_description) like :search ";
$sql_search .= " ) ";
$sql_search .= ") ";
}
//search contact notes
if (permission_exists('contact_note_view')) {
$sql_search .= "or contact_uuid in ( ";
$sql_search .= " select contact_uuid from v_contact_notes ";
$sql_search .= " where domain_uuid = :domain_uuid ";
$sql_search .= " and lower(contact_note) like :search ";
$sql_search .= ") ";
}
//close container
$sql_search .= ") ";
}
$parameters['search'] = '%'.$search.'%';
}
//build query for paging and list
$sql = "select count(*) ";
$sql .= "from v_contacts as c ";
$sql .= "where true ";
if ($show != "all" || !permission_exists('contact_all')) {
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
}
if (!permission_exists('contact_domain_view')) {
$sql .= "and ( "; //only contacts assigned to current user's group(s) and those not assigned to any group
$sql .= " contact_uuid in ( ";
$sql .= " select contact_uuid from v_contact_groups ";
$sql .= " where ";
if (!empty($user_group_uuids)) {
foreach ($user_group_uuids as $index => $user_group_uuid) {
if (is_uuid($user_group_uuid)) {
$sql_where_or[] = "group_uuid = :group_uuid_".$index;
$parameters['group_uuid_'.$index] = $user_group_uuid;
}
}
if (!empty($sql_where_or)) {
$sql .= " ( ".implode(' or ', $sql_where_or)." ) ";
}
unset($sql_where_or, $index, $user_group_uuid);
}
$sql .= " and domain_uuid = :domain_uuid ";
$sql .= " ) ";
$sql .= " or contact_uuid in ( ";
$sql .= " select contact_uuid from v_contact_users ";
$sql .= " where user_uuid = :user_uuid ";
$sql .= " and domain_uuid = :domain_uuid ";
$sql .= "";
$sql .= " ) ";
$sql .= ") ";
$parameters['user_uuid'] = $_SESSION['user_uuid'];
}
$sql .= $sql_search ?? '';
$database = new database;
$num_rows = $database->select($sql, $parameters ?? null, 'column');
//prepare to page the results
$rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50;
$param = "&search=".urlencode($search);
if ($show == "all" && permission_exists('contact_all')) {
$param .= "&show=all";
}
$page = $_GET['page'] ?? '';
if (empty($page)) { $page = 0; $_GET['page'] = 0; }
list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); //bottom
list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true); //top
$offset = $rows_per_page * $page;
//get the list
$sql = "select *, ";
$sql .= "(select a.contact_attachment_uuid from v_contact_attachments as a where a.contact_uuid = c.contact_uuid and a.attachment_primary = 1) as contact_attachment_uuid ";
$sql .= "from v_contacts as c ";
$sql .= "where true ";
if ($show != "all" || !permission_exists('contact_all')) {
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
}
if (!permission_exists('contact_domain_view')) {
$sql .= "and ( "; //only contacts assigned to current user's group(s) and those not assigned to any group
$sql .= " contact_uuid in ( ";
$sql .= " select contact_uuid from v_contact_groups ";
$sql .= " where ";
if (!empty($user_group_uuids)) {
foreach ($user_group_uuids as $index => $user_group_uuid) {
if (is_uuid($user_group_uuid)) {
$sql_where_or[] = "group_uuid = :group_uuid_".$index;
$parameters['group_uuid_'.$index] = $user_group_uuid;
}
}
if (!empty($sql_where_or)) {
$sql .= " ( ".implode(' or ', $sql_where_or)." ) ";
}
unset($sql_where_or, $index, $user_group_uuid);
}
$sql .= " and domain_uuid = :domain_uuid ";
$sql .= " ) ";
$sql .= " or contact_uuid in ( ";
$sql .= " select contact_uuid from v_contact_users ";
$sql .= " where user_uuid = :user_uuid ";
$sql .= " and domain_uuid = :domain_uuid ";
$sql .= "";
$sql .= " ) ";
$sql .= ") ";
$parameters['user_uuid'] = $_SESSION['user_uuid'];
}
$sql .= $sql_search ?? '';
$database = new database;
if (!empty($order_by)) {
$sql .= order_by($order_by, $order);
$sql .= ", contact_organization asc ";
}
else {
$contact_default_sort_column = !empty($_SESSION['contacts']['default_sort_column']['text']) ? $_SESSION['contacts']['default_sort_column']['text'] : "last_mod_date";
$contact_default_sort_order = !empty($_SESSION['contacts']['default_sort_order']['text']) ? $_SESSION['contacts']['default_sort_order']['text'] : "desc";
$sql .= order_by($contact_default_sort_column, $contact_default_sort_order);
if ($db_type == "pgsql") {
$sql .= " nulls last ";
}
}
$sql .= limit_offset($rows_per_page, $offset);
$database = new database;
$contacts = $database->select($sql, $parameters ?? null, 'all');
unset($sql, $parameters);
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//includes and title
$document['title'] = $text['title-contacts'];
require_once "resources/header.php";
//contact attachment layer
echo "<style>\n";
echo " #contact_attachment_layer {\n";
echo " z-index: 999999;\n";
echo " position: fixed;\n";
echo " left: 0px;\n";
echo " top: 0px;\n";
echo " right: 0px;\n";
echo " bottom: 0px;\n";
echo " text-align: center;\n";
echo " vertical-align: middle;\n";
echo " }\n";
echo "</style>\n";
echo "<div id='contact_attachment_layer' style='display: none;'></div>\n";
//show the content
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-contacts']."</b><div class='count'>".number_format($num_rows)."</div></div>\n";
echo " <div class='actions'>\n";
if (permission_exists('contact_add')) {
echo button::create(['type'=>'button','label'=>$text['button-import'],'icon'=>$_SESSION['theme']['button_icon_import'],'collapse'=>'hide-sm-dn','style'=>'margin-right: 15px;','link'=>'contact_import.php']);
}
if (permission_exists('contact_add')) {
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'id'=>'btn_add','collapse'=>'hide-sm-dn','link'=>'contact_edit.php']);
}
if (permission_exists('contact_delete') && $contacts) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none;','collapse'=>'hide-sm-dn','onclick'=>"modal_open('modal-delete','btn_delete');"]);
}
echo "<form id='form_search' class='inline' method='get'>\n";
if (permission_exists('contact_all')) {
if ($show == 'all') {
echo " <input type='hidden' name='show' value='all'>";
}
else {
echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'?type=&show=all'.(!empty($search) ? "&search=".urlencode($search) : null)]);
}
}
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown=''>";
echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','collapse'=>'hide-sm-dn']);
//echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','collapse'=>'hide-sm-dn','link'=>'contacts.php','style'=>($search == '' ? 'display: none;' : null)]);
if (!empty($paging_controls_mini)) {
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>";
}
echo " </form>\n";
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
if (permission_exists('contact_delete') && $contacts) {
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]);
}
echo $text['description-contacts']."\n";
echo "<br /><br />\n";
echo "<form id='form_list' method='post'>\n";
echo "<input type='hidden' id='action' name='action' value=''>\n";
echo "<input type='hidden' name='search' value=\"".escape($search)."\">\n";
echo "<div class='card'>\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
if (permission_exists('contact_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".(!empty($contacts) ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
}
if ($show == "all" && permission_exists('contact_all')) {
echo th_order_by('domain_name', $text['label-domain'], $order_by, $order, $param, "class='shrink'");
}
echo th_order_by('contact_type', $text['label-contact_type'], $order_by, $order);
echo th_order_by('contact_organization', $text['label-contact_organization'], $order_by, $order);
echo "<th class='shrink hide-xs'>&nbsp;</th>\n";
echo th_order_by('contact_name_given', $text['label-contact_name_given'], $order_by, $order);
echo th_order_by('contact_name_family', $text['label-contact_name_family'], $order_by, $order);
echo th_order_by('contact_nickname', $text['label-contact_nickname'], $order_by, $order, null, "class='hide-xs'");
echo th_order_by('contact_title', $text['label-contact_title'], $order_by, $order, null, "class='hide-sm-dn'");
echo th_order_by('contact_role', $text['label-contact_role'], $order_by, $order, null, "class='hide-sm-dn'");
echo "<th class='shrink hide-sm-dn'>&nbsp;</th>\n";
if ($list_row_edit_button == 'true') {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
if (!empty($contacts)) {
$x = 0;
foreach($contacts as $row) {
$list_row_url = "contact_view.php?id=".urlencode($row['contact_uuid'])."&query_string=".urlencode($_SERVER["QUERY_STRING"]);
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('contact_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='contacts[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"checkbox_on_change(this); if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='contacts[$x][uuid]' value='".escape($row['contact_uuid'])."' />\n";
echo " </td>\n";
}
if ($show == "all" && permission_exists('contact_all')) {
if (!empty($_SESSION['domains'][$row['domain_uuid']]['domain_name'])) {
$domain = $_SESSION['domains'][$row['domain_uuid']]['domain_name'];
}
else {
$domain = $text['label-global'];
}
echo " <td>".escape($domain)."</td>\n";
}
echo " <td>".ucwords(escape($row['contact_type']))."&nbsp;</td>\n";
echo " <td class='overflow'><a href='".$list_row_url."'>".escape($row['contact_organization'])."</a>&nbsp;</td>\n";
echo " <td class='shrink no-link hide-xs center'>";
if (is_uuid($row['contact_attachment_uuid'])) {
echo "<i class='fas fa-portrait' style='cursor: pointer;' onclick=\"display_attachment('".escape($row['contact_attachment_uuid'])."');\"></i>";
}
echo " </td>\n";
echo " <td class='no-wrap'><a href='".$list_row_url."'>".escape($row['contact_name_given'])."</a>&nbsp;</td>\n";
echo " <td class='no-wrap'><a href='".$list_row_url."'>".escape($row['contact_name_family'])."</a>&nbsp;</td>\n";
echo " <td class='no-wrap hide-xs'>".escape($row['contact_nickname'])."&nbsp;</td>\n";
echo " <td class='overflow hide-sm-dn'>".escape($row['contact_title'])."&nbsp;</td>\n";
echo " <td class='overflow hide-sm-dn'>".escape($row['contact_role'])."&nbsp;</td>\n";
echo " <td class='hide-sm-dn'>";
if (!empty($contact_sync_sources[$row['contact_uuid']])) {
foreach ($contact_sync_sources[$row['contact_uuid']] as $contact_sync_source) {
switch ($contact_sync_source) {
case 'google': echo "<img src='resources/images/icon_gcontacts.png' style='width: 21px; height: 21px; border: none; padding-left: 2px;' alt='".$text['label-contact_google']."'>"; break;
}
}
}
else {
echo "&nbsp;";
}
echo " </td>\n";
if ($list_row_edit_button == 'true') {
echo " <td class='action-button'>";
echo button::create(['type'=>'button','title'=>$text['button-view'],'icon'=>$_SESSION['theme']['button_icon_view'],'link'=>$list_row_url]);
echo " </td>\n";
}
echo "</tr>\n";
$x++;
}
unset($contacts);
}
echo "</table>\n";
echo "</div>\n";
echo "<br />\n";
echo "<div align='center'>".$paging_controls."</div>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
//javascript
echo "<script>\n";
echo " function display_attachment(id) {\n";
echo " $('#contact_attachment_layer').load('contact_attachment.php?id=' + id + '&action=display', function(){\n";
echo " $('#contact_attachment_layer').fadeIn(200);\n";
echo " });\n";
echo " }\n";
echo "</script>\n";
//include the footer
require_once "resources/footer.php";
?>
+258
View File
@@ -0,0 +1,258 @@
<?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
require_once "resources/classes/vcard.php";
$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 = 1 ";
$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
*/
?>
@@ -0,0 +1,282 @@
<?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-2023
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//define the contacts class
if (!class_exists('contacts')) {
class contacts {
const APP_NAME = "contacts";
const APP_UUID = "04481e0e-a478-c559-adad-52bd4174574c";
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $permission_prefix;
private $list_page;
private $tables;
private $uuid_prefix;
/**
* declare public variables
*/
public $contact_uuid;
/**
* called when the object is created
*/
public function __construct() {
//assign private variables
$this->app_name = self::APP_NAME;
$this->app_uuid = self::APP_UUID;
$this->permission_prefix = 'contact_';
$this->list_page = 'contacts.php';
$this->tables[] = 'contact_addresses';
$this->tables[] = 'contact_attachments';
$this->tables[] = 'contact_emails';
$this->tables[] = 'contact_groups';
$this->tables[] = 'contact_notes';
$this->tables[] = 'contact_phones';
$this->tables[] = 'contact_relations';
$this->tables[] = 'contact_settings';
$this->tables[] = 'contact_times';
$this->tables[] = 'contact_urls';
$this->tables[] = 'contact_users';
$this->tables[] = 'contacts';
$this->uuid_prefix = 'contact_';
}
/**
* delete records
*/
public function delete($records) {
if (permission_exists($this->permission_prefix.'delete')) {
//add multi-lingual support
$language = new text;
$text = $language->get();
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->list_page);
exit;
}
//delete multiple records
if (is_array($records) && @sizeof($records) != 0) {
//build the delete array
foreach ($records as $x => $record) {
if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) {
if (is_array($this->tables) && @sizeof($this->tables) != 0) {
foreach ($this->tables as $table) {
$array[$table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
$array[$table][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
}
}
}
}
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//grant temp permissions
$p = new permissions;
$database = new database;
foreach ($this->tables as $table) {
$p->add(database::singular($table).'_delete', 'temp');
}
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
unset($array);
//revoke temp permissions
$database = new database;
foreach ($this->tables as $table) {
$p->delete(database::singular($table).'_delete', 'temp');
}
//set message
message::add($text['message-delete']);
}
unset($records);
}
}
}
public function delete_properties($records) {
//add multi-lingual support
$language = new text;
$text = $language->get();
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->list_page);
exit;
}
//delete multiple records
if (is_array($records) && @sizeof($records) != 0) {
//check permissions and build the delete array
$x = 0;
foreach ($records as $property_name => $properties) {
$database = new database;
if (permission_exists(database::singular($property_name).'_delete')) {
if (is_array($properties) && @sizeof($properties) != 0) {
foreach ($properties as $property) {
if ($property['checked'] == 'true' && is_uuid($property['uuid'])) {
$array[$property_name][$x][database::singular($property_name).'_uuid'] = $property['uuid'];
$array[$property_name][$x]['contact_uuid'] = $this->contact_uuid;
$array[$property_name][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
$x++;
}
}
}
}
}
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
unset($array);
}
unset($records);
}
}
public function delete_users($records) {
//assign private variables
$this->permission_prefix = 'contact_user_';
$this->table = 'contact_users';
$this->uuid_prefix = 'contact_user_';
if (permission_exists($this->permission_prefix.'delete')) {
//add multi-lingual support
$language = new text;
$text = $language->get();
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->list_page);
exit;
}
//delete multiple records
if (is_array($records) && @sizeof($records) != 0) {
//filter out unchecked ivr menu options, build delete array
$x = 0;
foreach ($records as $record) {
if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) {
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
$array[$this->table][$x]['contact_uuid'] = $this->contact_uuid;
$x++;
}
}
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
unset($array);
}
unset($records);
}
}
}
public function delete_groups($records) {
//assign private variables
$this->permission_prefix = 'contact_group_';
$this->table = 'contact_groups';
$this->uuid_prefix = 'contact_group_';
if (permission_exists($this->permission_prefix.'delete')) {
//add multi-lingual support
$language = new text;
$text = $language->get();
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->list_page);
exit;
}
//delete multiple records
if (is_array($records) && @sizeof($records) != 0) {
//filter out unchecked ivr menu options, build delete array
$x = 0;
foreach ($records as $record) {
if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) {
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
$array[$this->table][$x]['contact_uuid'] = $this->contact_uuid;
$x++;
}
}
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
unset($array);
}
unset($records);
}
}
} //method
} //class
}
?>
@@ -0,0 +1,42 @@
<?php
//contacts
$array['dashboard'][$x]['dashboard_uuid'] = '3b0cbb2f-733d-4646-8332-7d108808f2fd';
$array['dashboard'][$x]['dashboard_name'] = 'Contacts';
$array['dashboard'][$x]['dashboard_path'] = 'dashboard/icon';
$array['dashboard'][$x]['dashboard_icon'] = 'fa-regular fa-address-card';
$array['dashboard'][$x]['dashboard_url'] = '/app/contacts/contacts.php';
$array['dashboard'][$x]['dashboard_target'] = 'self';
$array['dashboard'][$x]['dashboard_width'] = '';
$array['dashboard'][$x]['dashboard_height'] = '';
$array['dashboard'][$x]['dashboard_content'] = '';
$array['dashboard'][$x]['dashboard_content_text_align'] = '';
$array['dashboard'][$x]['dashboard_content_details'] = '';
$array['dashboard'][$x]['dashboard_chart_type'] = '';
$array['dashboard'][$x]['dashboard_heading_text_color'] = '';
$array['dashboard'][$x]['dashboard_heading_text_color_hover'] = '';
$array['dashboard'][$x]['dashboard_heading_background_color'] = '';
$array['dashboard'][$x]['dashboard_heading_background_color_hover'] = '';
$array['dashboard'][$x]['dashboard_number_background_color'] = '';
$array['dashboard'][$x]['dashboard_number_text_color'] = '#0292FF';
$array['dashboard'][$x]['dashboard_number_text_color_hover'] = '';
$array['dashboard'][$x]['dashboard_background_color'] ='';
$array['dashboard'][$x]['dashboard_background_color_hover'] = '';
$array['dashboard'][$x]['dashboard_detail_background_color'] = '';
$array['dashboard'][$x]['dashboard_column_span'] = '1';
$array['dashboard'][$x]['dashboard_row_span'] = '1';
$array['dashboard'][$x]['dashboard_details_state'] = 'disabled';
$array['dashboard'][$x]['dashboard_order'] = '50';
$array['dashboard'][$x]['dashboard_enabled'] = 'true';
$array['dashboard'][$x]['dashboard_description'] = '';
$y = 0;
$array['dashboard'][$x]['dashboard_groups'][$y]['dashboard_group_uuid'] = 'ec16fd64-5333-4372-bb9c-21603358e283';
$array['dashboard'][$x]['dashboard_groups'][$y]['dashboard_uuid'] = '3b0cbb2f-733d-4646-8332-7d108808f2fd';
$array['dashboard'][$x]['dashboard_groups'][$y]['group_name'] = 'superadmin';
$y++;
$array['dashboard'][$x]['dashboard_groups'][$y]['dashboard_group_uuid'] = 'c46035ba-9d23-4e77-84a9-c8ffeea48415';
$array['dashboard'][$x]['dashboard_groups'][$y]['dashboard_uuid'] = '3b0cbb2f-733d-4646-8332-7d108808f2fd';
$array['dashboard'][$x]['dashboard_groups'][$y]['group_name'] = 'admin';
$y++;
?>
@@ -0,0 +1,116 @@
<?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-2013
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
if (!function_exists('google_get_contacts')) {
function google_get_contacts($token, $max_results = 50) {
//global $records;
global $groups;
//$url = 'https://www.google.com/m8/feeds/contacts/default/full?max-results='.$max_results.'&oauth_token='.$_SESSION['contact_auth']['token']; // all contacts as xml
//$url = 'https://www.google.com/m8/feeds/contacts/default/full/78967d550d3fdd99?alt=json&v=3.0&oauth_token='.$_SESSION['contact_auth']['token']; // single contact
$url = 'https://www.google.com/m8/feeds/contacts/default/full?max-results='.$max_results.'&alt=json&v=3.0&oauth_token='.$token; // all contacts as json
$xml_response = curl_file_get_contents($url);
$records = json_decode($xml_response, true);
//check for authentication errors (logged out of google account, or app access permission revoked, etc)
if ($records['error']['code']) {
header("Location: contact_auth.php?source=google&target=".substr($_SERVER["PHP_SELF"], strrpos($_SERVER["PHP_SELF"],'/')+1));
exit;
}
//create new array of contacts
foreach($records['feed']['entry'] as $contact['number'] => $contact) {
$contact_id = substr($contact['id']['$t'], strrpos($contact['id']['$t'], "/")+1);
$contacts[$contact_id]['etag'] = $contact['gd$etag'];
$contacts[$contact_id]['updated'] = $contact['updated']['$t'];
$contacts[$contact_id]['name_prefix'] = $contact['gd$name']['gd$namePrefix']['$t'];
$contacts[$contact_id]['name_given'] = $contact['gd$name']['gd$givenName']['$t'];
$contacts[$contact_id]['name_middle'] = $contact['gd$name']['gd$additionalName']['$t'];
$contacts[$contact_id]['name_family'] = $contact['gd$name']['gd$familyName']['$t'];
$contacts[$contact_id]['name_suffix'] = $contact['gd$name']['gd$nameSuffix']['$t'];
$contacts[$contact_id]['nickname'] = $contact['gContact$nickname']['$t'];
$contacts[$contact_id]['title'] = $contact['gd$organization'][0]['gd$orgTitle']['$t'];
$contacts[$contact_id]['organization'] = $contact['gd$organization'][0]['gd$orgName']['$t'];
foreach ($contact['gd$email'] as $contact_email['number'] => $contact_email) {
if ($contact_email['label']) {
$contact_email_label = $contact_email['label'];
}
else {
$contact_email_label = substr($contact_email['rel'], strpos($contact_email['rel'], "#")+1);
$contact_email_label = ucwords(str_replace("_", " ", $contact_email_label));
}
$contacts[$contact_id]['emails'][$contact_email['number']]['label'] = $contact_email_label;
$contacts[$contact_id]['emails'][$contact_email['number']]['address'] = $contact_email['address'];
$contacts[$contact_id]['emails'][$contact_email['number']]['primary'] = ($contact_email['primary']) ? 1 : 0;
}
foreach ($contact['gd$phoneNumber'] as $contact_phone['number'] => $contact_phone) {
if ($contact_phone['label']) {
$contact_phone_label = $contact_phone['label'];
}
else {
$contact_phone_label = substr($contact_phone['rel'], strpos($contact_phone['rel'], "#")+1);
$contact_phone_label = ucwords(str_replace("_", " ", $contact_phone_label));
}
$contacts[$contact_id]['numbers'][$contact_phone['number']]['label'] = $contact_phone_label;
$contacts[$contact_id]['numbers'][$contact_phone['number']]['number'] = preg_replace('{\D}', '', $contact_phone['$t']);
}
foreach ($contact['gContact$website'] as $contact_website['number'] => $contact_website) {
$contact_website_label = ($contact_website['label']) ? $contact_website['label'] : ucwords(str_replace("_", " ", $contact_website['rel']));
$contacts[$contact_id]['urls'][$contact_website['number']]['label'] = $contact_website_label;
$contacts[$contact_id]['urls'][$contact_website['number']]['url'] = $contact_website['href'];
}
foreach ($contact['gd$structuredPostalAddress'] as $contact_address['number'] => $contact_address) {
if ($contact_address['label']) {
$contact_address_label = $contact_address['label'];
}
else {
$contact_address_label = substr($contact_address['rel'], strpos($contact_address['rel'], "#")+1);
$contact_address_label = ucwords(str_replace("_", " ", $contact_address_label));
}
$contacts[$contact_id]['addresses'][$contact_address['number']]['label'] = $contact_address_label;
$contacts[$contact_id]['addresses'][$contact_address['number']]['street'] = $contact_address['gd$street']['$t'];
$contacts[$contact_id]['addresses'][$contact_address['number']]['extended'] = $contact_address['gd$pobox']['$t'];
$contacts[$contact_id]['addresses'][$contact_address['number']]['community'] = $contact_address['gd$neighborhood']['$t'];
$contacts[$contact_id]['addresses'][$contact_address['number']]['locality'] = $contact_address['gd$city']['$t'];
$contacts[$contact_id]['addresses'][$contact_address['number']]['region'] = $contact_address['gd$region']['$t'];
$contacts[$contact_id]['addresses'][$contact_address['number']]['postal_code'] = $contact_address['gd$postcode']['$t'];
$contacts[$contact_id]['addresses'][$contact_address['number']]['country'] = $contact_address['gd$country']['$t'];
}
foreach ($contact['gContact$groupMembershipInfo'] as $contact_group['number'] => $contact_group) {
$contact_group_id = substr($contact_group['href'], strrpos($contact_group['href'], "/")+1);
$contacts[$contact_id]['groups'][$contact_group_id] = $groups[$contact_group_id]['name'];
}
$contacts[$contact_id]['notes'] = $contact['content']['$t'];
}
//set account holder info
$_SESSION['contact_auth']['name'] = $records['feed']['author'][0]['name']['$t'];
$_SESSION['contact_auth']['email'] = $records['feed']['author'][0]['email']['$t'];
return $contacts;
}
}
?>
@@ -0,0 +1,54 @@
<?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-2013
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
function google_get_groups($token) {
// retrieve groups
$url = 'https://www.google.com/m8/feeds/groups/default/full?alt=json&v=3.0&oauth_token='.$token;
$xml_response = curl_file_get_contents($url);
$records = json_decode($xml_response, true);
//check for authentication errors
if ($records['error']['code']) {
header("Location: contact_auth.php?source=google&target=".substr($_SERVER["PHP_SELF"], strrpos($_SERVER["PHP_SELF"],'/')+1));
exit;
}
//create new array of groups
foreach($records['feed']['entry'] as $group['number'] => $group) {
$group_id = substr($group['id']['$t'], strrpos($group['id']['$t'], "/")+1);
$groups[$group_id]['name'] = ($group['gContact$systemGroup']['id']) ? $group['gContact$systemGroup']['id'] : $group['title']['$t'];
$groups[$group_id]['count'] = 0;
unset($group_id);
}
unset($group);
//set account holder info
$_SESSION['contact_auth']['name'] = $records['feed']['author'][0]['name']['$t'];
$_SESSION['contact_auth']['email'] = $records['feed']['author'][0]['email']['$t'];
return $groups;
}
?>
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB