diff --git a/app/contacts/app_config.php b/app/contacts/app_config.php index 891f14c96c..0f925caa9c 100644 --- a/app/contacts/app_config.php +++ b/app/contacts/app_config.php @@ -101,6 +101,74 @@ $apps[$x]['permissions'][$y]['name'] = "contact_group_delete"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "contact_email_view"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "contact_email_add"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "contact_email_edit"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "contact_email_delete"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "contact_url_view"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "contact_url_add"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "contact_url_edit"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "contact_url_delete"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "contact_setting_view"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "contact_setting_add"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "contact_setting_edit"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "contact_setting_delete"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "contact_relation_view"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "contact_relation_add"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "contact_relation_edit"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "contact_relation_delete"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "contact_extension_view"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; //schema details $y = 0; //table array index @@ -187,14 +255,14 @@ $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Enter the category."; $z++; -$apps[$x]['db'][$y]['fields'][$z]['name'] = "contact_email"; -$apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; -$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Enter the email address."; -$z++; -$apps[$x]['db'][$y]['fields'][$z]['name'] = "contact_url"; -$apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; -$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Enter the website address."; -$z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = "contact_email"; + $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; + $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Enter the email address."; + $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = "contact_url"; + $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; + $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Enter the website address."; + $z++; $apps[$x]['db'][$y]['fields'][$z]['name'] = "contact_time_zone"; $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Enter the time zone."; @@ -502,6 +570,43 @@ $z++; $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; + $y = 6; //table array index + $apps[$x]['db'][$y]['table'] = "v_contact_relations"; + $apps[$x]['db'][$y]['fields'][$z]['name'] = "contact_relation_uuid"; + $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid"; + $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text"; + $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)"; + $apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "primary"; + $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = "domain_uuid"; + $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid"; + $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text"; + $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)"; + $apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign"; + $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = "contact_uuid"; + $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid"; + $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text"; + $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)"; + $apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign"; + $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = "v_contacts"; + $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "contact_uuid"; + $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; + $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = "relation_label"; + $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; + $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; + $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = "relation_contact_uuid"; + $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid"; + $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text"; + $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)"; + $apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign"; + $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = "v_contacts"; + $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "contact_uuid"; + $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; + $z++; + $y = 7; //table array index $apps[$x]['db'][$y]['table'] = "v_contact_emails"; $apps[$x]['db'][$y]['fields'][$z]['name'] = "contact_email_uuid"; diff --git a/app/contacts/app_languages.php b/app/contacts/app_languages.php index ea8b2c0f93..5414906d71 100644 --- a/app/contacts/app_languages.php +++ b/app/contacts/app_languages.php @@ -949,6 +949,93 @@ $text['description-contact_setting_value']['pt-pt'] = "Introduza o valor desta definição."; $text['description-contact_setting_value']['fr-fr'] = "Entrez la valeur de ce paramètre."; + // contact relations + $text['header-contact_relations']['en-us'] = "Relations"; + $text['header-contact_relations']['es-cl'] = "Relaciones"; + $text['header-contact_relations']['pt-pt'] = "Relações"; + $text['header-contact_relations']['fr-fr'] = "Rapports"; + + $text['title-contact_relation']['en-us'] = "Contact Relation"; + $text['title-contact_relation']['es-cl'] = "Contacto Relación"; + $text['title-contact_relation']['pt-pt'] = "Contato Relação"; + $text['title-contact_relation']['fr-fr'] = "Contactez Relation"; + + $text['header-contact_relation']['en-us'] = "Contact Relation"; + $text['header-contact_relation']['es-cl'] = "Contacto Relación"; + $text['header-contact_relation']['pt-pt'] = "Contato Relação"; + $text['header-contact_relation']['fr-fr'] = "Contactez Relation"; + + $text['label-contact_relation_organization']['en-us'] = "Organization"; + $text['label-contact_relation_organization']['es-cl'] = "Organización"; + $text['label-contact_relation_organization']['pt-pt'] = "Organização"; + $text['label-contact_relation_organization']['fr-fr'] = "Organisation"; + + $text['label-contact_relation_name']['en-us'] = "Name"; + $text['label-contact_relation_name']['es-cl'] = "Nombre"; + $text['label-contact_relation_name']['pt-pt'] = "Nom"; + $text['label-contact_relation_name']['fr-fr'] = "Nome"; + + $text['label-contact_relation_label']['en-us'] = "Relation"; + $text['label-contact_relation_label']['es-cl'] = "Relación"; + $text['label-contact_relation_label']['pt-pt'] = "Relação"; + $text['label-contact_relation_label']['fr-fr'] = "Relation"; + + $text['label-contact_relation_option_parent']['en-us'] = "Parent"; + $text['label-contact_relation_option_parent']['es-cl'] = "Padre"; + $text['label-contact_relation_option_parent']['pt-pt'] = "Parente"; + $text['label-contact_relation_option_parent']['fr-fr'] = "Mère"; + + $text['label-contact_relation_option_child']['en-us'] = "Child"; + $text['label-contact_relation_option_child']['es-cl'] = "Niño"; + $text['label-contact_relation_option_child']['pt-pt'] = "Criança"; + $text['label-contact_relation_option_child']['fr-fr'] = "Enfant"; + + $text['label-contact_relation_option_employee']['en-us'] = "Employee"; + $text['label-contact_relation_option_employee']['es-cl'] = "Empleado"; + $text['label-contact_relation_option_employee']['pt-pt'] = "Empregado"; + $text['label-contact_relation_option_employee']['fr-fr'] = "Employé"; + + $text['label-contact_relation_option_member']['en-us'] = "Member"; + $text['label-contact_relation_option_member']['es-cl'] = "Miembro"; + $text['label-contact_relation_option_member']['pt-pt'] = "Membro"; + $text['label-contact_relation_option_member']['fr-fr'] = "Membre"; + + $text['label-contact_relation_option_associate']['en-us'] = "Associate"; + $text['label-contact_relation_option_associate']['es-cl'] = "Asociado"; + $text['label-contact_relation_option_associate']['pt-pt'] = "Associado"; + $text['label-contact_relation_option_associate']['fr-fr'] = "Associé"; + + $text['label-contact_relation_option_other']['en-us'] = "Other"; + $text['label-contact_relation_option_other']['es-cl'] = "Otro"; + $text['label-contact_relation_option_other']['pt-pt'] = "Outro"; + $text['label-contact_relation_option_other']['fr-fr'] = "Autre"; + + $text['label-contact_relation_contact']['en-us'] = "Contact"; + $text['label-contact_relation_contact']['es-cl'] = "Contacto"; + $text['label-contact_relation_contact']['pt-pt'] = "Contato"; + $text['label-contact_relation_contact']['fr-fr'] = "Contact"; + + $text['label-contact_relation_reciprocal']['en-us'] = "Reciprocal"; + $text['label-contact_relation_reciprocal']['es-cl'] = "Recíproca"; + $text['label-contact_relation_reciprocal']['pt-pt'] = "Recíproco"; + $text['label-contact_relation_reciprocal']['fr-fr'] = "Réciproque"; + + $text['description-contact_relation_reciprocal']['en-us'] = "Select whether to also create a reciprocal relationship for the contact selected above."; + $text['description-contact_relation_reciprocal']['es-cl'] = "Seleccione si desea crear también una relación recíproca para el contacto seleccionado anteriormente."; + $text['description-contact_relation_reciprocal']['pt-pt'] = "Seleccione se pretende também criar uma relação de reciprocidade para o contato selecionado acima."; + $text['description-contact_relation_reciprocal']['fr-fr'] = "Sélectionnez si vous souhaitez créer également une relation réciproque pour le contact sélectionné ci-dessus."; + + $text['label-contact_relation_reciprocal_label']['en-us'] = "Reciprocal Relation"; + $text['label-contact_relation_reciprocal_label']['es-cl'] = "Relación Recíproca"; + $text['label-contact_relation_reciprocal_label']['pt-pt'] = "Relação Recíproca"; + $text['label-contact_relation_reciprocal_label']['fr-fr'] = "Relation Réciproque"; + + $text['description-contact_relation_reciprocal_label']['en-us'] = "Define the relationship of this contact to the contact selected above."; + $text['description-contact_relation_reciprocal_label']['es-cl'] = "Definir la relación de este contacto para el contacto seleccionado anteriormente."; + $text['description-contact_relation_reciprocal_label']['pt-pt'] = "Definir a relação desse contato para o contato selecionado acima."; + $text['description-contact_relation_reciprocal_label']['fr-fr'] = "Définir la relation de ce contact au contact sélectionné ci-dessus."; + + // contact import $text['title-contacts_import']['en-us'] = "Import Contacts"; $text['title-contacts_import']['es-cl'] = "Importar Contactos"; @@ -1171,4 +1258,6 @@ $text['message-required']['pt-pt'] = "Por favor indique: "; $text['message-required']['fr-fr'] = "Merci d'indiquer: "; + + ?> \ No newline at end of file diff --git a/app/contacts/contact_address_delete.php b/app/contacts/contact_address_delete.php index 8a7425ffb1..6235e5bc2a 100644 --- a/app/contacts/contact_address_delete.php +++ b/app/contacts/contact_address_delete.php @@ -26,7 +26,7 @@ require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; -if (permission_exists('contact_delete')) { +if (permission_exists('contact_address_delete')) { //access granted } else { diff --git a/app/contacts/contact_address_edit.php b/app/contacts/contact_address_edit.php index 1263c122d9..c0b679289e 100644 --- a/app/contacts/contact_address_edit.php +++ b/app/contacts/contact_address_edit.php @@ -27,7 +27,7 @@ require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; -if (permission_exists('contact_edit')) { +if (permission_exists('contact_address_edit') || permission_exists('contact_address_add')) { //access granted } else { @@ -54,7 +54,6 @@ if (strlen($_GET["contact_uuid"]) > 0) { //get http post variables and set them to php variables if (count($_POST)>0) { - //$address_name = check_str($_POST["address_name"]); $address_type = check_str($_POST["address_type"]); $address_label = check_str($_POST["address_label"]); $address_label_custom = check_str($_POST["address_label_custom"]); @@ -193,7 +192,6 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); foreach ($result as &$row) { - //$address_name = $row["address_name"]; $address_type = $row["address_type"]; $address_label = $row["address_label"]; $address_street = $row["address_street"]; diff --git a/app/contacts/contact_addresses.php b/app/contacts/contact_addresses.php index d11b8058f2..42a75d99db 100644 --- a/app/contacts/contact_addresses.php +++ b/app/contacts/contact_addresses.php @@ -26,7 +26,7 @@ require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; -if (permission_exists('contact_view')) { +if (permission_exists('contact_address_view')) { //access granted } else { @@ -34,15 +34,7 @@ else { exit; } -//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"]; - //show the content - echo "\n"; echo "\n"; echo "\n"; @@ -50,38 +42,11 @@ require_once "resources/paging.php"; echo "\n"; echo "
".$text['label-addresses']."
\n"; - //prepare to page the results -// $sql = " select count(*) as num_rows from v_contact_addresses "; -// $sql .= " where domain_uuid = '".$_SESSION['domain_uuid']."' "; -// $sql .= " and 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 = 10; -// $param = ""; -// $page = $_GET['page']; -// if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } -// list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); -// $offset = $rows_per_page * $page; - //get the contact list $sql = "select * from v_contact_addresses "; $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; $sql .= "and contact_uuid = '$contact_uuid' "; $sql .= "order by address_primary desc, address_label asc "; -// if (strlen($order_by)> 0) { $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); @@ -102,14 +67,18 @@ require_once "resources/paging.php"; echo " \n"; echo "".$text['label-address_description']."\n"; echo ""; - echo "$v_link_label_add"; + if (permission_exists('contact_address_add')) { + echo "$v_link_label_add"; + } echo "\n"; echo "\n"; if ($result_count > 0) { foreach($result as $row) { $map_query = $row['address_street']." ".$row['address_extended'].", ".$row['address_locality'].", ".$row['address_region'].", ".$row['address_region'].", ".$row['address_postal_code']; - $tr_link = "href='contact_address_edit.php?contact_uuid=".$row['contact_uuid']."&id=".$row['contact_address_uuid']."'"; + if (permission_exists('contact_address_edit')) { + $tr_link = "href='contact_address_edit.php?contact_uuid=".$row['contact_uuid']."&id=".$row['contact_address_uuid']."'"; + } echo "\n"; echo " ".$row['address_label']." \n"; echo " ".$row['address_street']." \n"; @@ -120,11 +89,15 @@ require_once "resources/paging.php"; echo " \n"; echo " ".$row['address_description']." \n"; echo " "; - echo "$v_link_label_edit"; - echo "$v_link_label_delete"; + if (permission_exists('contact_address_edit')) { + echo "$v_link_label_edit"; + } + if (permission_exists('contact_address_delete')) { + echo "$v_link_label_delete"; + } echo " \n"; echo "\n"; - if ($c==0) { $c=1; } else { $c=0; } + $c = ($c) ? 0 : 1; } //end foreach unset($sql, $result, $row_count); } //end if results diff --git a/app/contacts/contact_delete.php b/app/contacts/contact_delete.php index fccac8d0eb..8fc0b73f36 100644 --- a/app/contacts/contact_delete.php +++ b/app/contacts/contact_delete.php @@ -86,6 +86,18 @@ if (strlen($contact_uuid) > 0) { $prep_statement->execute(); unset($prep_statement, $sql); + //delete relations + $sql = "delete from v_contact_relations "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and "; + $sql .= "( "; + $sql .= " contact_uuid = '".$contact_uuid."' "; + $sql .= " or relation_contact_uuid = '".$contact_uuid."' "; + $sql .= ") "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($prep_statement, $sql); + //delete settings $sql = "delete from v_contact_settings "; $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; diff --git a/app/contacts/contact_edit.php b/app/contacts/contact_edit.php index 241ec1a3b8..01ae0d5c4d 100644 --- a/app/contacts/contact_edit.php +++ b/app/contacts/contact_edit.php @@ -396,8 +396,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { echo " \n"; echo " \n"; } - echo "
\n"; - echo $text['description-contact_type']."\n"; +// echo "
\n"; +// echo $text['description-contact_type']."\n"; echo "\n"; echo "\n"; @@ -407,8 +407,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; echo "\n"; echo " \n"; - echo "
\n"; - echo $text['description-contact_organization']."\n"; +// echo "
\n"; +// echo $text['description-contact_organization']."\n"; echo "\n"; echo "\n"; @@ -418,8 +418,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; echo "\n"; echo " \n"; - echo "
\n"; - echo $text['description-contact_name_prefix']."\n"; +// echo "
\n"; +// echo $text['description-contact_name_prefix']."\n"; echo "\n"; echo "\n"; @@ -429,8 +429,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; echo "\n"; echo " \n"; - echo "
\n"; - echo $text['description-contact_name_given']."\n"; +// echo "
\n"; +// echo $text['description-contact_name_given']."\n"; echo "\n"; echo "\n"; @@ -440,8 +440,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; echo "\n"; echo " \n"; - echo "
\n"; - echo $text['description-contact_name_middle']."\n"; +// echo "
\n"; +// echo $text['description-contact_name_middle']."\n"; echo "\n"; echo "\n"; @@ -451,8 +451,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; echo "\n"; echo " \n"; - echo "
\n"; - echo $text['description-contact_name_family']."\n"; +// echo "
\n"; +// echo $text['description-contact_name_family']."\n"; echo "\n"; echo "\n"; @@ -462,8 +462,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; echo "\n"; echo " \n"; - echo "
\n"; - echo $text['description-contact_name_suffix']."\n"; +// echo "
\n"; +// echo $text['description-contact_name_suffix']."\n"; echo "\n"; echo "\n"; @@ -473,8 +473,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; echo "\n"; echo " \n"; - echo "
\n"; - echo $text['description-contact_nickname']."\n"; +// echo "
\n"; +// echo $text['description-contact_nickname']."\n"; echo "\n"; echo "\n"; @@ -495,8 +495,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { else { echo " \n"; } - echo "
\n"; - echo $text['description-contact_title']."\n"; +// echo "
\n"; +// echo $text['description-contact_title']."\n"; echo "\n"; echo "\n"; @@ -517,8 +517,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { else { echo " \n"; } - echo "
\n"; - echo $text['description-contact_category']."\n"; +// echo "
\n"; +// echo $text['description-contact_category']."\n"; echo "\n"; echo "\n"; @@ -539,8 +539,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { else { echo " \n"; } - echo "
\n"; - echo $text['description-contact_role']."\n"; +// echo "
\n"; +// echo $text['description-contact_role']."\n"; echo "\n"; echo "\n"; @@ -550,8 +550,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; echo "\n"; echo " \n"; - echo "
\n"; - echo $text['description-contact_time_zone']."\n"; +// echo "
\n"; +// echo $text['description-contact_time_zone']."\n"; echo "\n"; echo "\n"; @@ -678,8 +678,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; echo "\n"; echo " \n"; - echo "
\n"; - echo $text['description-contact_note']."\n"; +// echo "
\n"; +// echo $text['description-contact_note']."\n"; echo "\n"; echo "\n"; echo " \n"; @@ -698,14 +698,15 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { if ($action == "update") { echo "       "; echo "\n"; - //echo "

\n"; - require "contact_phones.php"; - require "contact_addresses.php"; - require "contact_emails.php"; - require "contact_urls.php"; - require "contact_extensions.php"; - require "contact_notes.php"; - require "contact_settings.php"; + //echo "

\n"; + if (permission_exists('contact_phone_view')) { require "contact_phones.php"; } + if (permission_exists('contact_address_view')) { require "contact_addresses.php"; } + if (permission_exists('contact_email_view')) { require "contact_emails.php"; } + if (permission_exists('contact_url_view')) { require "contact_urls.php"; } + if (permission_exists('contact_extension_view')) { require "contact_extensions.php"; } + if (permission_exists('contact_relation_view')) { require "contact_relations.php"; } + if (permission_exists('contact_note_view')) { require "contact_notes.php"; } + if (permission_exists('contact_setting_view')) { require "contact_settings.php"; } echo "\n"; } diff --git a/app/contacts/contact_email_delete.php b/app/contacts/contact_email_delete.php index 8345c46349..b37d65f9fd 100644 --- a/app/contacts/contact_email_delete.php +++ b/app/contacts/contact_email_delete.php @@ -26,7 +26,7 @@ require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; -if (permission_exists('contact_delete')) { +if (permission_exists('contact_email_delete')) { //access granted } else { diff --git a/app/contacts/contact_email_edit.php b/app/contacts/contact_email_edit.php index 175d2c23fa..f3c7e97665 100644 --- a/app/contacts/contact_email_edit.php +++ b/app/contacts/contact_email_edit.php @@ -27,7 +27,7 @@ require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; -if (permission_exists('contact_edit')) { +if (permission_exists('contact_email_edit') || permission_exists('contact_email_add')) { //access granted } else { diff --git a/app/contacts/contact_emails.php b/app/contacts/contact_emails.php index 7e60954500..93131b3e36 100644 --- a/app/contacts/contact_emails.php +++ b/app/contacts/contact_emails.php @@ -26,7 +26,7 @@ require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; -if (permission_exists('contact_view')) { +if (permission_exists('contact_email_view')) { //access granted } else { @@ -34,15 +34,7 @@ else { exit; } -//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"]; - //show the content - echo "\n"; echo "\n"; echo "\n"; @@ -50,37 +42,11 @@ require_once "resources/paging.php"; echo "\n"; echo "
".$text['label-emails']."
\n"; - //prepare to page the results -// $sql = " select count(*) as num_rows from v_contact_emails "; -// $sql .= " where domain_uuid = '".$_SESSION['domain_uuid']."' "; -// $sql .= " and contact_uuid = '$contact_uuid' "; -// $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 = 10; -// $param = ""; -// $page = $_GET['page']; -// if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } -// list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); -// $offset = $rows_per_page * $page; - //get the contact list $sql = "select * from v_contact_emails "; $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; $sql .= "and contact_uuid = '$contact_uuid' "; $sql .= "order by email_primary desc, email_label asc "; -// if (strlen($order_by)> 0) { $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); @@ -98,23 +64,31 @@ require_once "resources/paging.php"; echo "".$text['label-email_address']."\n"; echo "".$text['label-email_description']."\n"; echo ""; - echo "$v_link_label_add"; + if (permission_exists('contact_email_add')) { + echo "$v_link_label_add"; + } echo "\n"; echo "\n"; if ($result_count > 0) { foreach($result as $row) { - $tr_link = "href='contact_email_edit.php?contact_uuid=".$row['contact_uuid']."&id=".$row['contact_email_uuid']."'"; + if (permission_exists('contact_email_edit')) { + $tr_link = "href='contact_email_edit.php?contact_uuid=".$row['contact_uuid']."&id=".$row['contact_email_uuid']."'"; + } echo "\n"; echo " ".$row['email_label']." \n"; echo " ".$row['email_address']." \n"; echo " ".$row['email_description']." \n"; echo " "; - echo "$v_link_label_edit"; - echo "$v_link_label_delete"; + if (permission_exists('contact_email_edit')) { + echo "$v_link_label_edit"; + } + if (permission_exists('contact_email_delete')) { + echo "$v_link_label_delete"; + } echo " \n"; echo "\n"; - if ($c==0) { $c=1; } else { $c=0; } + $c = ($c) ? 0 : 1; } //end foreach unset($sql, $result, $row_count); } //end if results diff --git a/app/contacts/contact_extensions.php b/app/contacts/contact_extensions.php index a4002ffc1e..232a7aef5e 100644 --- a/app/contacts/contact_extensions.php +++ b/app/contacts/contact_extensions.php @@ -26,7 +26,7 @@ require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; -if (permission_exists('contact_view')) { +if (permission_exists('contact_extension_view')) { //access granted } else { @@ -34,15 +34,6 @@ else { exit; } -//require_once "resources/header.php"; -require_once "resources/paging.php"; - -//get variables used to control the order - if (isset($_GET["order_by"])) { - $order_by = check_str($_GET["order_by"]); - $order = check_str($_GET["order"]); - } - //javascript function: send_cmd echo "\n"; //show the content - echo "\n"; echo "\n"; echo "\n"; @@ -67,43 +57,14 @@ require_once "resources/paging.php"; echo "\n"; echo "
".$text['label-contact_extensions']."
\n"; - //prepare to page the results - $sql = "select count(*) as num_rows "; + //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' "; - $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 = 10; - $param = ""; - $page = $_GET['page']; - if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } - list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); - $offset = $rows_per_page * $page; - - //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' "; - - if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } - $sql .= " limit $rows_per_page offset $offset "; + $sql .= "order by e.extension asc "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); @@ -121,7 +82,7 @@ require_once "resources/paging.php"; echo "".$text['label-description']."\n"; echo ""; if (permission_exists('extension_add')) { - echo " $v_link_label_add\n"; + echo "$v_link_label_add\n"; } echo "\n"; echo "\n"; @@ -141,14 +102,14 @@ require_once "resources/paging.php"; echo " ".$row['description']." \n"; echo " "; if (permission_exists('extension_edit')) { - echo "$v_link_label_edit"; + echo "$v_link_label_edit"; } if (permission_exists('extension_delete')) { - echo "$v_link_label_delete"; + echo "$v_link_label_delete"; } echo " \n"; echo "\n"; - if ($c==0) { $c=1; } else { $c=0; } + $c = ($c) ? 0 : 1; } //end foreach unset($sql, $result, $row_count); } //end if results diff --git a/app/contacts/contact_note_delete.php b/app/contacts/contact_note_delete.php index ad2c756b44..3fc3a87bc2 100644 --- a/app/contacts/contact_note_delete.php +++ b/app/contacts/contact_note_delete.php @@ -26,7 +26,7 @@ require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; -if (permission_exists('contact_delete')) { +if (permission_exists('contact_note_delete')) { //access granted } else { diff --git a/app/contacts/contact_note_edit.php b/app/contacts/contact_note_edit.php index 4455d74987..8bb62c9006 100644 --- a/app/contacts/contact_note_edit.php +++ b/app/contacts/contact_note_edit.php @@ -26,7 +26,7 @@ require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; -if (permission_exists('contact_edit')) { +if (permission_exists('contact_note_edit') || permission_exists('contact_note_add')) { //access granted } else { @@ -66,10 +66,6 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { } //check for all required data - //if (strlen($contact_note) == 0) { $msg .= $text['message-required'].$text['label-contact_note']."
\n"; } - //if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']."domain_uuid
\n"; } - //if (strlen($last_mod_date) == 0) { $msg .= $text['message-required']."Last Modified Date
\n"; } - //if (strlen($last_mod_user) == 0) { $msg .= $text['message-required']."Last Modified By
\n"; } if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; diff --git a/app/contacts/contact_notes.php b/app/contacts/contact_notes.php index b2756025f3..5f9f56b7ff 100644 --- a/app/contacts/contact_notes.php +++ b/app/contacts/contact_notes.php @@ -26,7 +26,7 @@ require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; -if (permission_exists('contact_view')) { +if (permission_exists('contact_note_view')) { //access granted } else { @@ -34,19 +34,6 @@ else { exit; } -//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"]; - -//set defaults - if (strlen($order_by) == 0) { - $order_by = 'last_mod_date'; - $order = 'desc'; - } - //show the content echo "\n"; echo "\n"; @@ -59,7 +46,7 @@ require_once "resources/paging.php"; $sql = "select * from v_contact_notes "; $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; $sql .= "and contact_uuid = '$contact_uuid' "; - if (strlen($order_by)> 0) { $sql .= "order by ".$order_by." ".$order." "; } + $sql .= "order by last_mod_date desc "; $prep_statement = $db->prepare(check_sql($sql)); if ($prep_statement) { $prep_statement->execute(); @@ -78,7 +65,9 @@ require_once "resources/paging.php"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
".$text['label-note_content']."".$text['label-note_user'].""; - echo "$v_link_label_add"; + if (permission_exists('contact_note_add')) { + echo "$v_link_label_add"; + } echo "
\n"; @@ -89,15 +78,21 @@ require_once "resources/paging.php"; foreach($result as $row) { $contact_note = $row['contact_note']; $contact_note = str_replace("\n","
",$contact_note); - $tr_link = "href='contact_note_edit.php?contact_uuid=".$row['contact_uuid']."&id=".$row['contact_note_uuid']."'"; + if (permission_exists('contact_note_add')) { + $tr_link = "href='contact_note_edit.php?contact_uuid=".$row['contact_uuid']."&id=".$row['contact_note_uuid']."'"; + } echo "\n"; echo " "; echo "
".$row['last_mod_user'].": ".date("j M Y @ H:i:s", strtotime($row['last_mod_date']))."
"; echo $contact_note." "; echo " \n"; echo " "; - echo "$v_link_label_edit"; - echo "$v_link_label_delete"; + if (permission_exists('contact_note_edit')) { + echo "$v_link_label_edit"; + } + if (permission_exists('contact_note_delete')) { + echo "$v_link_label_delete"; + } echo " \n"; echo "\n"; $c = ($c) ? 0 : 1; diff --git a/app/contacts/contact_phone_delete.php b/app/contacts/contact_phone_delete.php index 8d5d5d68f9..fe17ad4dce 100644 --- a/app/contacts/contact_phone_delete.php +++ b/app/contacts/contact_phone_delete.php @@ -26,7 +26,7 @@ require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; -if (permission_exists('contact_delete')) { +if (permission_exists('contact_phone_delete')) { //access granted } else { diff --git a/app/contacts/contact_phone_edit.php b/app/contacts/contact_phone_edit.php index 90748aefba..4c3c61c844 100644 --- a/app/contacts/contact_phone_edit.php +++ b/app/contacts/contact_phone_edit.php @@ -27,7 +27,7 @@ require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; -if (permission_exists('contact_edit')) { +if (permission_exists('contact_phone_edit') || permission_exists('contact_phone_add')) { //access granted } else { @@ -335,12 +335,12 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { echo " \n"; echo " \n"; - echo "
\n"; - echo " \n"; + echo "
\n"; + echo " \n"; if ($action == "update") { - echo " \n"; + echo " \n"; } - echo " \n"; + echo " \n"; echo " \n"; echo " "; echo ""; diff --git a/app/contacts/contact_phones.php b/app/contacts/contact_phones.php index 63dd616964..9a2d072445 100644 --- a/app/contacts/contact_phones.php +++ b/app/contacts/contact_phones.php @@ -26,7 +26,7 @@ require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; -if (permission_exists('contact_view')) { +if (permission_exists('contact_phone_view')) { //access granted } else { @@ -34,13 +34,6 @@ else { exit; } -//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"]; - //javascript function: send_cmd echo "\n"; //show the content - echo "\n"; echo "\n"; echo "\n"; @@ -65,38 +57,11 @@ require_once "resources/paging.php"; echo "\n"; echo "
".$text['label-phone_numbers']."
\n"; - //prepare to page the results -// $sql = "select count(*) as num_rows from v_contact_phones "; -// $sql .= " where domain_uuid = '$domain_uuid' "; -// $sql .= " and 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 = 10; -// $param = ""; -// $page = $_GET['page']; -// if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } -// list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); -// $offset = $rows_per_page * $page; - //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 "; -// if (strlen($order_by)> 0) { $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); @@ -115,12 +80,16 @@ require_once "resources/paging.php"; echo "".$text['label-phone_tools']."\n"; echo "".$text['label-phone_description']."\n"; echo ""; - echo "$v_link_label_add"; + if (permission_exists('contact_phone_add')) { + echo "$v_link_label_add"; + } echo "\n"; echo "\n"; if ($result_count > 0) { foreach($result as $row) { - $tr_link = "href='contact_phone_edit.php?contact_uuid=".$row['contact_uuid']."&id=".$row['contact_phone_uuid']."'"; + if (permission_exists('contact_phone_edit')) { + $tr_link = "href='contact_phone_edit.php?contact_uuid=".$row['contact_uuid']."&id=".$row['contact_phone_uuid']."'"; + } echo "\n"; echo " ".(($row['phone_label'] == strtolower($row['phone_label'])) ? ucwords($row['phone_label']) : $row['phone_label'])." \n"; echo " \n"; @@ -146,11 +115,15 @@ require_once "resources/paging.php"; echo " \n"; echo " ".$row['phone_description']." \n"; echo " "; - echo "$v_link_label_edit"; - echo "$v_link_label_delete"; + if (permission_exists('contact_phone_edit')) { + echo "$v_link_label_edit"; + } + if (permission_exists('contact_phone_delete')) { + echo "$v_link_label_delete"; + } echo " \n"; echo "\n"; - if ($c==0) { $c=1; } else { $c=0; } + $c = ($c) ? 0 : 1; } //end foreach unset($sql, $result, $row_count); } //end if results diff --git a/app/contacts/contact_relation_delete.php b/app/contacts/contact_relation_delete.php new file mode 100644 index 0000000000..9bb143bcae --- /dev/null +++ b/app/contacts/contact_relation_delete.php @@ -0,0 +1,60 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "resources/require.php"; +require_once "resources/check_auth.php"; +if (permission_exists('contact_relation_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +if (count($_GET)>0) { + $id = check_str($_GET["id"]); //relation + $contact_uuid = check_str($_GET["contact_uuid"]); +} + +if (strlen($id)>0) { + $sql = "delete from v_contact_relations "; + $sql .= "where contact_relation_uuid = '".$id."' "; + $sql .= "and domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and contact_uuid = '".$contact_uuid."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); +} + +$_SESSION["message"] = $text['message-delete']; +header("Location: contact_edit.php?id=".$contact_uuid); +return; + +?> \ No newline at end of file diff --git a/app/contacts/contact_relation_edit.php b/app/contacts/contact_relation_edit.php new file mode 100644 index 0000000000..c7154ab3a0 --- /dev/null +++ b/app/contacts/contact_relation_edit.php @@ -0,0 +1,330 @@ + + 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"; +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 (isset($_REQUEST["id"])) { + $action = "update"; + $contact_relation_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +if (strlen($_GET["contact_uuid"]) > 0) { + $contact_uuid = check_str($_GET["contact_uuid"]); +} + +//get http post variables and set them to php variables + if (count($_POST)>0) { + $relation_label = check_str($_POST["relation_label"]); + $relation_label_custom = check_str($_POST["relation_label_custom"]); + $relation_contact_uuid = check_str($_POST["relation_contact_uuid"]); + $relation_reciprocal = check_str($_POST["relation_reciprocal"]); + $relation_reciprocal_label = check_str($_POST["relation_reciprocal_label"]); + $relation_reciprocal_label_custom = check_str($_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; + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $contact_relation_uuid = check_str($_POST["contact_relation_uuid"]); + } + + //check for all required data + 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") { + + if ($action == "add") { + $contact_relation_uuid = uuid(); + $sql = "insert into v_contact_relations "; + $sql .= "("; + $sql .= "contact_relation_uuid, "; + $sql .= "domain_uuid, "; + $sql .= "contact_uuid, "; + $sql .= "relation_label, "; + $sql .= "relation_contact_uuid "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".$contact_relation_uuid."', "; + $sql .= "'".$_SESSION['domain_uuid']."', "; + $sql .= "'".$contact_uuid."', "; + $sql .= "'".$relation_label."', "; + $sql .= "'".$relation_contact_uuid."' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + if ($relation_reciprocal) { + $contact_relation_uuid = uuid(); + $sql = "insert into v_contact_relations "; + $sql .= "("; + $sql .= "contact_relation_uuid, "; + $sql .= "domain_uuid, "; + $sql .= "contact_uuid, "; + $sql .= "relation_label, "; + $sql .= "relation_contact_uuid "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".$contact_relation_uuid."', "; + $sql .= "'".$_SESSION['domain_uuid']."', "; + $sql .= "'".$relation_contact_uuid."', "; + $sql .= "'".$relation_reciprocal_label."', "; + $sql .= "'".$contact_uuid."' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + + $_SESSION["message"] = $text['message-add']; + header("Location: contact_edit.php?id=".$contact_uuid); + return; + } //if ($action == "add") + + if ($action == "update") { + $sql = "update v_contact_relations set "; + $sql .= "relation_label = '".$relation_label."', "; + $sql .= "relation_contact_uuid = '".$relation_contact_uuid."' "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and contact_relation_uuid = '".$contact_relation_uuid."'"; + $db->exec(check_sql($sql)); + unset($sql); + + $_SESSION["message"] = $text['message-update']; + header("Location: contact_edit.php?id=".$contact_uuid); + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { + $contact_relation_uuid = $_GET["id"]; + $sql = "select * from v_contact_relations "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and contact_relation_uuid = '".$contact_relation_uuid."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $relation_label = $row["relation_label"]; + $relation_contact_uuid = $row["relation_contact_uuid"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//show the header + $document['title'] = $text['title-contact_relation']; + require_once "resources/header.php"; + +//javascript to toggle input/select boxes + echo ""; + +//show the content + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
"; + echo " ".$text['header-contact_relation'].""; + echo ""; + 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"; + + if ($action == 'add') { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo " ".$text['label-contact_relation_label']."\n"; + echo "\n"; + if (is_array($_SESSION["contact"]["relation_label"])) { + sort($_SESSION["contact"]["relation_label"]); + foreach($_SESSION["contact"]["relation_label"] as $row) { + $relation_label_options[] = ""; + } + $relation_label_found = (in_array($relation_label, $_SESSION["contact"]["relation_label"])) ? true : false; + } + else { + $selected[$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[] = ""; + } + $relation_label_found = (in_array($relation_label, $default_labels)) ? true : false; + } + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo $text['description-relation_label']."\n"; + echo "
\n"; + echo " ".$text['label-contact_relation_contact']."\n"; + echo "\n"; + $sql = "select contact_uuid, contact_organization, contact_name_given, contact_name_family from v_contacts "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and contact_uuid <> '".$contact_uuid."' "; + $sql .= "order by contact_organization desc, contact_name_given asc, contact_name_family asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + unset ($prep_statement, $sql); + echo "\n"; +// echo "
\n"; +// echo $text['description-related_contact']."\n"; + echo "
\n"; + echo " ".$text['label-contact_relation_reciprocal']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-contact_relation_reciprocal']."\n"; + echo "
\n"; + + echo "\n"; + + echo "\n"; + } + + echo " \n"; + echo " \n"; + echo " "; + echo "
\n"; + echo "
\n"; + echo " \n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo "

"; + echo "
"; + +//include the footer + require_once "resources/footer.php"; +?> diff --git a/app/contacts/contact_relations.php b/app/contacts/contact_relations.php new file mode 100644 index 0000000000..9158017223 --- /dev/null +++ b/app/contacts/contact_relations.php @@ -0,0 +1,113 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "resources/require.php"; +require_once "resources/check_auth.php"; +if (permission_exists('contact_relation_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//show the content + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
".$text['header-contact_relations']." 
\n"; + + //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 = '".$_SESSION['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 "; + //echo $sql."

"; + $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"; + + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + if ($result_count > 0) { + foreach($result as $row) { + if (permission_exists('contact_relation_edit')) { + $tr_link = "href='contact_relation_edit.php?contact_uuid=".$row['contact_uuid']."&id=".$row['contact_relation_uuid']."' "; + } + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "
".$text['label-contact_relation_label']."".$text['label-contact_relation_organization']."".$text['label-contact_relation_name'].""; + if (permission_exists('contact_relation_add')) { + echo "$v_link_label_add"; + } + echo "
".$row['relation_label']." "; + if (permission_exists('contact_relation_edit')) { + echo "$v_link_label_edit"; + } + if (permission_exists('contact_relation_delete')) { + echo "$v_link_label_delete"; + } + echo "
"; + +?> \ No newline at end of file diff --git a/app/contacts/contact_setting_delete.php b/app/contacts/contact_setting_delete.php index b30148bfb1..306bdac3a3 100644 --- a/app/contacts/contact_setting_delete.php +++ b/app/contacts/contact_setting_delete.php @@ -27,6 +27,13 @@ require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; +if (permission_exists('contact_setting_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} //add multi-lingual support $language = new text; diff --git a/app/contacts/contact_setting_edit.php b/app/contacts/contact_setting_edit.php index db0dc9c9b9..fd98a172d9 100644 --- a/app/contacts/contact_setting_edit.php +++ b/app/contacts/contact_setting_edit.php @@ -27,6 +27,13 @@ require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; +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; diff --git a/app/contacts/contact_settings.php b/app/contacts/contact_settings.php index 427f073932..31af54a6a1 100644 --- a/app/contacts/contact_settings.php +++ b/app/contacts/contact_settings.php @@ -27,50 +27,22 @@ require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; -require_once "resources/paging.php"; - -//get variables used to control the order - $order_by = check_str($_GET["order_by"]); - $order = check_str($_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 = 2; -// $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; +if (permission_exists('contact_setting_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} //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 "; - $sql .= "contact_setting_category asc "; - $sql .= ", contact_setting_subcategory asc "; - $sql .= ", contact_setting_order asc "; - } - else { - $sql .= "order by ".$order_by." ".$order." "; - } -// $sql .= "limit ".$rows_per_page." offset ".$offset." "; + $sql .= "order by "; + $sql .= "contact_setting_category asc "; + $sql .= ", contact_setting_subcategory asc "; + $sql .= ", contact_setting_order asc "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); @@ -103,19 +75,22 @@ require_once "resources/paging.php"; echo "".$text['label-enabled'].""; echo "".$text['label-description'].""; echo ""; - echo "$v_link_label_add"; + if (permission_exists('contact_setting_add')) { + echo "$v_link_label_add"; + } echo "\n"; echo "\n"; if ($result_count > 0) { $previous_category = ''; foreach($result as $row) { - $tr_link = " href='contact_setting_edit.php?contact_uuid=".$contact_uuid."&id=".$row['contact_setting_uuid']."'"; + if (permission_exists('contact_setting_edit')) { + $tr_link = " href='contact_setting_edit.php?contact_uuid=".$contact_uuid."&id=".$row['contact_setting_uuid']."'"; + } echo "\n"; echo " ".$row['contact_setting_category']." \n"; echo " ".$row['contact_setting_subcategory']."\n"; echo " ".$row['contact_setting_name']." \n"; echo " \n"; - $category = $row['contact_setting_category']; $subcategory = $row['contact_setting_subcategory']; $name = $row['contact_setting_name']; @@ -132,18 +107,20 @@ require_once "resources/paging.php"; echo " ".ucwords($row['contact_setting_enabled'])." \n"; echo " ".$row['contact_setting_description']." \n"; echo " "; - echo "$v_link_label_edit"; + if (permission_exists('contact_setting_edit')) { + echo "$v_link_label_edit"; + } + if (permission_exists('contact_setting_delete')) { echo "$v_link_label_delete"; + } echo " \n"; echo "\n"; $previous_category = $row['contact_setting_category']; - if ($c==0) { $c=1; } else { $c=0; } + $c = ($c) ? 0 : 1; } //end foreach unset($sql, $result, $row_count); } //end if results echo ""; -//include the footer - //require_once "resources/footer.php"; ?> \ No newline at end of file diff --git a/app/contacts/contact_url_delete.php b/app/contacts/contact_url_delete.php index 81db89d557..ddf9339bf6 100644 --- a/app/contacts/contact_url_delete.php +++ b/app/contacts/contact_url_delete.php @@ -26,7 +26,7 @@ require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; -if (permission_exists('contact_delete')) { +if (permission_exists('contact_url_delete')) { //access granted } else { diff --git a/app/contacts/contact_url_edit.php b/app/contacts/contact_url_edit.php index ec55e11cd5..ca0686c03a 100644 --- a/app/contacts/contact_url_edit.php +++ b/app/contacts/contact_url_edit.php @@ -27,7 +27,7 @@ require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; -if (permission_exists('contact_edit')) { +if (permission_exists('contact_url_edit') || permission_exists('contact_url_add')) { //access granted } else { diff --git a/app/contacts/contact_urls.php b/app/contacts/contact_urls.php index a92e051c1d..0841579d40 100644 --- a/app/contacts/contact_urls.php +++ b/app/contacts/contact_urls.php @@ -26,7 +26,7 @@ require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; -if (permission_exists('contact_view')) { +if (permission_exists('contact_url_view')) { //access granted } else { @@ -34,15 +34,7 @@ else { exit; } -//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"]; - //show the content - echo "\n"; echo "\n"; echo "\n"; @@ -50,37 +42,11 @@ require_once "resources/paging.php"; echo "\n"; echo "
".$text['label-urls']."
\n"; - //prepare to page the results -// $sql = " select count(*) as num_rows from v_contact_urls "; -// $sql .= " where domain_uuid = '".$_SESSION['domain_uuid']."' "; -// $sql .= " and contact_uuid = '$contact_uuid' "; -// $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 = 10; -// $param = ""; -// $page = $_GET['page']; -// if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } -// list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); -// $offset = $rows_per_page * $page; - //get the contact list $sql = "select * from v_contact_urls "; $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; $sql .= "and contact_uuid = '$contact_uuid' "; $sql .= "order by url_primary desc, url_label asc "; -// if (strlen($order_by)> 0) { $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); @@ -98,23 +64,31 @@ require_once "resources/paging.php"; echo "".$text['label-url_address']."\n"; echo "".$text['label-url_description']."\n"; echo ""; - echo "$v_link_label_add"; + if (permission_exists('contact_url_add')) { + echo "$v_link_label_add"; + } echo "\n"; echo "\n"; if ($result_count > 0) { foreach($result as $row) { - $tr_link = "href='contact_url_edit.php?contact_uuid=".$row['contact_uuid']."&id=".$row['contact_url_uuid']."'"; + if (permission_exists('contact_url_edit')) { + $tr_link = "href='contact_url_edit.php?contact_uuid=".$row['contact_uuid']."&id=".$row['contact_url_uuid']."'"; + } echo "\n"; echo " ".$row['url_label']." \n"; echo " ".str_replace("http://", "", str_replace("https://", "", $row['url_address']))." \n"; echo " ".$row['url_description']." \n"; echo " "; - echo "$v_link_label_edit"; - echo "$v_link_label_delete"; + if (permission_exists('contact_url_edit')) { + echo "$v_link_label_edit"; + } + if (permission_exists('contact_url_delete')) { + echo "$v_link_label_delete"; + } echo " \n"; echo "\n"; - if ($c==0) { $c=1; } else { $c=0; } + $c = ($c) ? 0 : 1; } //end foreach unset($sql, $result, $row_count); } //end if results