From 46225da3f416bd47571798cc923af319ee87cebc Mon Sep 17 00:00:00 2001 From: luis daniel lucio quiroz Date: Sat, 8 Nov 2014 03:34:02 +0000 Subject: [PATCH] contact settings support --- app/contacts/app_languages.php | 79 ++++++ app/contacts/contact_edit.php | 3 +- app/contacts/contact_setting_delete.php | 57 ++++ app/contacts/contact_setting_edit.php | 352 ++++++++++++++++++++++++ app/contacts/contact_settings.php | 172 ++++++++++++ 5 files changed, 662 insertions(+), 1 deletion(-) create mode 100644 app/contacts/contact_setting_delete.php create mode 100644 app/contacts/contact_setting_edit.php create mode 100644 app/contacts/contact_settings.php diff --git a/app/contacts/app_languages.php b/app/contacts/app_languages.php index ca7a35d77c..a8efdae923 100644 --- a/app/contacts/app_languages.php +++ b/app/contacts/app_languages.php @@ -133,6 +133,16 @@ $text['description-contact_category']['pt-pt'] = "Introduza a categoria."; $text['description-contact_category']['fr-fr'] = ""; + $text['label-contact_subcategory']['en-us'] = "Subcategory"; + $text['label-contact_subcategory']['es-cl'] = "Subcategoría"; + $text['label-contact_subcategory']['pt-pt'] = "Subcategoria"; + $text['label-contact_subcategory']['fr-fr'] = "Sous-Catégorie"; + + $text['description-contact_subcategory']['en-us'] = "Enter the subcategory."; + $text['description-contact_subcategory']['es-cl'] = "Ingrese la categoría."; + $text['description-contact_subcategory']['pt-pt'] = "Introduza a subcategoria"; + $text['description-contact_subcategory']['fr-fr'] = ""; + $text['label-contact_role']['en-us'] = "Role"; $text['label-contact_role']['es-cl'] = "Rol"; $text['label-contact_role']['pt-pt'] = "Papel"; @@ -183,6 +193,75 @@ $text['description-contact_note']['pt-pt'] = "Introduza uma nota."; $text['description-contact_note']['fr-fr'] = ""; + $text['label-contact_properties']['en-us'] = "Properties"; + $text['label-contact_properties']['es-cl'] = "Propiedades"; + $text['label-contact_properties']['pt-pt'] = "Propiedades"; + $text['label-contact_properties']['fr-fr'] = "Propietés"; + + + $text['label-contact_value']['en-us'] = "Value"; + + $text['label-contact_value']['es-cl'] = "Valor"; + $text['label-contact_value']['pt-pt'] = "Valor"; + $text['label-contact_value']['fr-fr'] = "Valeur"; + + + $text['description-contact_value']['en-us'] = "Enter the value of this setting."; + $text['description-contact_value']['es-cl'] = "Ingrese el valor para esta configuración."; + $text['description-contact_value']['pt-pt'] = "Introduza o valor desta definição."; + $text['description-contact_value']['fr-fr'] = ""; + + + $text['label-true']['en-us'] = "True"; + $text['label-true']['es-cl'] = "Verdadero"; + $text['label-true']['pt-pt'] = "Sim"; + $text['label-true']['fr-fr'] = "Oui"; + + + $text['label-false']['en-us'] = "False"; + $text['label-false']['es-cl'] = "Falso"; + $text['label-false']['pt-pt'] = "Não"; + $text['label-false']['fr-fr'] = "Non"; + + + $text['label-order']['en-us'] = "Order"; + $text['label-order']['es-cl'] = "Orden"; + $text['label-order']['pt-pt'] = "Ordem"; + $text['label-order']['fr-fr'] = "Ordre"; + + + $text['description-order']['en-us'] = "Set the order (index) for this array element."; + $text['description-order']['es-cl'] = "Establecer el orden (ndice) para este elemento de la matriz."; + $text['description-order']['pt-pt'] = "Defina a ordem (ndice) para este elemento da matriz."; + $text['description-order']['fr-fr'] = "Dfinir l'ordre (index) pour cet lment de tableau."; + + + $text['header-contact_setting-edit']['en-us'] = "Contact Setting"; + $text['header-contact_setting-edit']['es-cl'] = "Configuraciones de contacto"; + $text['header-contact_setting-edit']['pt-pt'] = "Definições do Contacto"; + $text['header-contact_setting-edit']['fr-fr'] = "Paramètres du Contact"; + + + $text['header-contact_setting-add']['en-us'] = "Contact Setting Add"; + $text['header-contact_setting-add']['es-cl'] = "Agregar Configuración de Contacto"; + $text['header-contact_setting-add']['pt-pt'] = "Adicionar Definição ao Contacto"; + $text['header-contact_setting-add']['fr-fr'] = "Ajouter un paramètre au Contact"; + $text['title-contact_setting-edit']['en-us'] = "Contact Setting"; + $text['title-contact_setting-edit']['es-cl'] = "Configuraciones de contacto"; + $text['title-contact_setting-edit']['pt-pt'] = "Definições do Contacto"; + $text['title-contact_setting-edit']['fr-fr'] = "Paramètres du Contact"; + + + $text['title-contact_setting-add']['en-us'] = "Contact Setting Add"; + $text['title-contact_setting-add']['es-cl'] = "Agregar Configuración de Contacto"; + $text['title-contact_setting-add']['pt-pt'] = "Adicionar Definição ao Contacto"; + $text['title-contact_setting-add']['fr-fr'] = "Ajouter un paramètre au Contact"; + + $text['description-contact_setting-edit']['en-us'] = "Edit a setting for this contact."; + $text['description-contact_setting-edit']['es-cl'] = "Edita una configuración para este contacto."; + $text['description-contact_setting-edit']['pt-pt'] = "Editar uma definição deste contacto."; + $text['description-contact_setting-edit']['fr-fr'] = "Editer un paramètre du contact."; + $text['label-shared']['en-us'] = "Shared"; $text['label-shared']['es-cl'] = "Compartido"; $text['label-shared']['pt-pt'] = "Partilhada"; diff --git a/app/contacts/contact_edit.php b/app/contacts/contact_edit.php index 7ac3d5d3e1..5845c206a6 100644 --- a/app/contacts/contact_edit.php +++ b/app/contacts/contact_edit.php @@ -766,6 +766,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { require "contact_addresses.php"; require "contact_extensions.php"; require "contact_notes.php"; + require "contact_settings.php"; echo "\n"; } @@ -775,4 +776,4 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { //include the footer require_once "resources/footer.php"; -?> \ No newline at end of file +?> diff --git a/app/contacts/contact_setting_delete.php b/app/contacts/contact_setting_delete.php new file mode 100644 index 0000000000..fc40f034f2 --- /dev/null +++ b/app/contacts/contact_setting_delete.php @@ -0,0 +1,57 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane + Luis Daniel Lucio Quiroz +*/ +require_once "root.php"; +require_once "resources/require.php"; +require_once "resources/check_auth.php"; + +//add multi-lingual support + require_once "app_languages.php"; + foreach($text as $key => $value) { + $text[$key] = $value[$_SESSION['domain']['language']['code']]; + } + +if (count($_GET)>0) { + $id = check_str($_GET["id"]); + $contact_uuid = check_str($_GET["contact_uuid"]); +} + +if (strlen($id)>0) { + //delete domain_setting + $sql = "delete from v_contact_settings "; + $sql .= "where contact_uuid = '$contact_uuid' "; + $sql .= "and contact_setting_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); +} + +//redirect the user + $_SESSION["message"] = $text['message-delete']; + header("Location: contact_edit.php?id=".$contact_uuid); + return; + +?> diff --git a/app/contacts/contact_setting_edit.php b/app/contacts/contact_setting_edit.php new file mode 100644 index 0000000000..ece5382f8f --- /dev/null +++ b/app/contacts/contact_setting_edit.php @@ -0,0 +1,352 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane + Luis Daniel Lucio Quiroz +*/ +require_once "root.php"; +require_once "resources/require.php"; +require_once "resources/check_auth.php"; +//add multi-lingual support + require_once "app_languages.php"; + foreach($text['button-save'] as $key => $value) { + $languages[$key] = ''; + } + foreach($text as $key => $value) { + $text[$key] = $value[$_SESSION['domain']['language']['code']]; + } + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $contact_setting_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +if (strlen($_GET["contact_uuid"]) > 0) { + $contact_uuid = check_str($_GET["contact_uuid"]); +} +$domain_uuid = $_SESSION['domain_uuid']; + +//get http post variables and set them to php variables + if (count($_POST) > 0) { + $contact_setting_category = strtolower(check_str($_POST["contact_setting_category"])); + $contact_setting_subcategory = strtolower(check_str($_POST["contact_setting_subcategory"])); + $contact_setting_name = strtolower(check_str($_POST["contact_setting_name"])); + $contact_setting_value = check_str($_POST["contact_setting_value"]); + $contact_setting_order = check_str($_POST["contact_setting_order"]); + $contact_setting_enabled = strtolower(check_str($_POST["contact_setting_enabled"])); + $contact_setting_description = check_str($_POST["contact_setting_description"]); + } + +if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $contact_setting_uuid = check_str($_POST["contact_setting_uuid"]); + } + + //check for all required data + //if (strlen($domain_setting_category) == 0) { $msg .= $text['message-required'].$text['label-category']."
\n"; } + //if (strlen($domain_setting_subcategory) == 0) { $msg .= $text['message-required'].$text['label-subcategory']."
\n"; } + //if (strlen($domain_setting_name) == 0) { $msg .= $text['message-required'].$text['label-type']."
\n"; } + //if (strlen($domain_setting_value) == 0) { $msg .= $text['message-required'].$text['label-value']."
\n"; } + //if (strlen($domain_setting_order) == 0) { $msg .= $text['message-required'].$text['label-order']."
\n"; } + //if (strlen($domain_setting_enabled) == 0) { $msg .= $text['message-required'].$text['label-enabled']."
\n"; } + //if (strlen($domain_setting_description) == 0) { $msg .= $text['message-required'].$text['label-description']."
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "resources/header.php"; + require_once "resources/persist_form_var.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "resources/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + $contact_setting_order = ($contact_setting_order != '') ? $contact_setting_order : 'null'; + + //add the domain + if ($action == "add" && permission_exists('domain_setting_add')) { + $sql = "insert into v_contact_settings "; + $sql .= "("; + $sql .= "contact_setting_uuid, "; + $sql .= "contact_uuid, "; + $sql .= "domain_uuid, "; + $sql .= "contact_setting_category, "; + $sql .= "contact_setting_subcategory, "; + $sql .= "contact_setting_name, "; + $sql .= "contact_setting_value, "; + $sql .= "contact_setting_order, "; + $sql .= "contact_setting_enabled, "; + $sql .= "contact_setting_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".uuid()."', "; + $sql .= "'$contact_uuid', "; + $sql .= "'$domain_uuid', "; + $sql .= "'$contact_setting_category', "; + $sql .= "'$contact_setting_subcategory', "; + $sql .= "'$contact_setting_name', "; + $sql .= "'$contact_setting_value', "; + $sql .= "$contact_setting_order, "; + $sql .= "'$contact_setting_enabled', "; + $sql .= "'$contact_setting_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } //if ($action == "add") + + //update the domain + if ($action == "update") { + $sql = "update v_contact_settings set "; + $sql .= "contact_setting_category = '$contact_setting_category', "; + $sql .= "contact_setting_subcategory = '$contact_setting_subcategory', "; + $sql .= "contact_setting_name = '$contact_setting_name', "; + $sql .= "contact_setting_value = '$contact_setting_value', "; + $sql .= "contact_setting_order = $contact_setting_order, "; + $sql .= "contact_setting_enabled = '$contact_setting_enabled', "; + $sql .= "contact_setting_description = '$contact_setting_description' "; + $sql .= "where contact_uuid = '$contact_uuid' "; + $sql .= "and contact_setting_uuid = '$contact_setting_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + } //if ($action == "update") + + //redirect the browser + if ($action == "update") { + $_SESSION["message"] = $text['message-update']; + } + if ($action == "add") { + $_SESSION["message"] = $text['message-add']; + } + header("Location: contact_edit.php?id=".$contact_uuid); + return; + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $contact_setting_uuid = check_str($_GET["id"]); + $sql = "select * from v_contact_settings "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and contact_setting_uuid = '$contact_setting_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $contact_setting_category = $row["contact_setting_category"]; + $contact_setting_subcategory = $row["contact_setting_subcategory"]; + $contact_setting_name = $row["contact_setting_name"]; + $contact_setting_value = $row["contact_setting_value"]; + $contact_setting_order = $row["contact_setting_order"]; + $contact_setting_enabled = $row["contact_setting_enabled"]; + $contact_setting_description = $row["contact_setting_description"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//show the header + require_once "resources/header.php"; + if ($action == "update") { + $document['title'] = $text['title-contact_setting-edit']; + } + elseif ($action == "add") { + $document['title'] = $text['title-contact_setting-add']; + } + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + if ($name == "array") { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo " \n"; + echo " \n"; + echo " "; + echo "
"; + if ($action == "update") { + echo $text['header-contact_setting-edit']; + } + if ($action == "add") { + echo $text['header-contact_setting-add']; + } + echo ""; + echo " "; + echo " \n"; + echo "
\n"; + if ($action == "update") { + echo $text['description-contact_setting-edit']; + } + if ($action == "add") { + echo $text['header-contact_setting-add']; + } + echo "

\n"; + echo "
\n"; + echo " ".$text['label-contact_category'].":\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-contact_category']."\n"; + echo "
\n"; + echo " ".$text['label-contact_subcategory'].":\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-contact_subcategory']."\n"; + echo "
\n"; + echo " ".$text['label-contact_name'].":\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-contact_name']."\n"; + echo "
\n"; + echo " ".$text['label-contact_value'].":\n"; + echo "\n"; + $category = $row['contact_setting_category']; + $subcategory = $row['contact_setting_subcategory']; + $name = $row['contact_setting_name']; + echo " \n"; + echo "
\n"; + echo $text['description-contact_value']."\n"; + echo "
\n"; + echo " ".$text['label-order']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-order']."\n"; + echo "
\n"; + echo " ".$text['label-enabled'].":\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-enabled']."\n"; + echo "
\n"; + echo " ".$text['label-description'].":\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-description']."\n"; + echo "
\n"; + echo " \n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + +//include the footer + require_once "resources/footer.php"; +?> diff --git a/app/contacts/contact_settings.php b/app/contacts/contact_settings.php new file mode 100644 index 0000000000..4c2d1ac3cf --- /dev/null +++ b/app/contacts/contact_settings.php @@ -0,0 +1,172 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane + Luis Daniel Lucio Quiroz +*/ +require_once "root.php"; +require_once "resources/require.php"; +require_once "resources/check_auth.php"; + +//require_once "resources/header.php"; +require_once "resources/paging.php"; + +//get variables used to control the order + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + + +//prepare to page the results + $sql = "select count(*) as num_rows from v_contact_settings "; + $sql .= "where contact_uuid = '$contact_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } + } + +//prepare to page the results + $rows_per_page = 100; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + +//get the list + $sql = "select * from v_contact_settings "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and contact_uuid = '$contact_uuid' "; + if (strlen($order_by) == 0) { + $sql .= "order by contact_setting_category, contact_setting_subcategory, contact_setting_order asc "; + } + else { + $sql .= "order by $order_by $order "; + } + $sql .= "limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + +//show the content + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
".$text['label-contact_properties']." 
\n"; + + echo "

"; + echo "\n"; + + if ($result_count > 0) { + $previous_category = ''; + foreach($result as $row) { + if ($previous_category != $row['contact_setting_category']) { + echo ""; + echo " \n"; + echo "\n"; + echo "\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + } + $tr_link = " href='contact_setting_edit.php?contact_uuid=".$contact_uuid."&id=".$row['contact_setting_uuid']."'"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + $previous_category = $row['contact_setting_category']; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + echo " "; + echo " ".ucfirst($row['contact_setting_category']); + echo " \n"; + echo "
".$text['label-subcategory']."".$text['label-type']."".$text['label-value']."".$text['label-enabled']."".$text['label-description'].""; + echo "$v_link_label_add"; + echo "
"; + echo "".$row['contact_setting_subcategory'].""; + echo " ".$row['contact_setting_name']." \n"; + + $category = $row['contact_setting_category']; + $subcategory = $row['contact_setting_subcategory']; + $name = $row['contact_setting_name']; + if ($category == "callingcard" && $subcategory == "username" && $name == "var" ) { + echo " ********  \n"; + } + elseif ($category == "callingcard" && $subcategory == "password" && $name == "var" ) { + echo " ********  \n"; + } else { + echo $row['contact_setting_value']; + } + echo "  \n"; + echo " ".ucwords($row['contact_setting_enabled'])." ".$row['contact_setting_description']." "; + echo "$v_link_label_edit"; + echo "$v_link_label_delete"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls"; + echo "$v_link_label_add"; + echo "
\n"; + echo "
"; + + +//include the footer + //require_once "resources/footer.php"; +?>