diff --git a/core/domain_settings/app_config.php b/core/domain_settings/app_config.php index c0f504d709..e3898efd6f 100644 --- a/core/domain_settings/app_config.php +++ b/core/domain_settings/app_config.php @@ -68,10 +68,22 @@ $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_parent_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_domains"; + $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "domain_uuid"; + $z++; $apps[$x]['db'][$y]['fields'][$z]['name'] = "domain_name"; $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Enter the domain name."; $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = "domain_enabled"; + $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; + $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Set the status of the domain."; + $z++; $apps[$x]['db'][$y]['fields'][$z]['name'] = "domain_description"; $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Enter the description."; @@ -90,6 +102,8 @@ $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_domains"; + $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "domain_uuid"; $z++; $apps[$x]['db'][$y]['fields'][$z]['name'] = "domain_setting_uuid"; $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid"; diff --git a/core/domain_settings/app_defaults.php b/core/domain_settings/app_defaults.php index bddc363f9c..95633206c5 100644 --- a/core/domain_settings/app_defaults.php +++ b/core/domain_settings/app_defaults.php @@ -34,4 +34,14 @@ //unset($sql); } +//proccess this only one time +if ($domains_processed == 1) { + + //set domains with enabled status of empty or null to true + $sql = "update v_domains set domain_enabled = 'true' where domain_enabled = '' or domain_enabled is null"; + $db->exec(check_sql($sql)); + unset($sql); + +} + ?> \ No newline at end of file diff --git a/core/domain_settings/app_languages.php b/core/domain_settings/app_languages.php index 9f993570cc..4432e5d3e9 100644 --- a/core/domain_settings/app_languages.php +++ b/core/domain_settings/app_languages.php @@ -170,10 +170,10 @@ $text['label-enabled']['pt-pt'] = "Habilitado"; $text['label-enabled']['fr-fr'] = "Actif"; - $text['description-enabled']['en-us'] = "Set the status of this default setting."; - $text['description-enabled']['es-cl'] = "Configure el estado de esta configuración predeterminada."; - $text['description-enabled']['pt-pt'] = "Escolha o estado desta definição por omissão."; - $text['description-enabled']['fr-fr'] = "Choisir l'état de ce paramètre"; + $text['description-setting_enabled']['en-us'] = "Set the status of this default setting."; + $text['description-setting_enabled']['es-cl'] = "Configure el estado de esta configuración predeterminada."; + $text['description-setting_enabled']['pt-pt'] = "Escolha o estado desta definição por omissão."; + $text['description-setting_enabled']['fr-fr'] = "Choisir l'état de ce paramètre"; $text['label-description']['en-us'] = "Description"; $text['label-description']['es-cl'] = "Descripción"; @@ -270,4 +270,24 @@ $text['message-required']['pt-pt'] = "Por favor indique: "; $text['message-required']['fr-fr'] = "Merci d'indiquer: "; + $text['description-domain_enabled']['en-us'] = "Set the status of the domain."; + $text['description-domain_enabled']['es-cl'] = "Ajuste el estado del dominio."; + $text['description-domain_enabled']['pt-pt'] = "Definir o estado do domínio."; + $text['description-domain_enabled']['fr-fr'] = "Régler le statut du domaine."; + + $text['label-parent_domain']['en-us'] = "Parent Domain"; + $text['label-parent_domain']['es-cl'] = "Dominio de los Padres"; + $text['label-parent_domain']['pt-pt'] = "Domínio Parent"; + $text['label-parent_domain']['fr-fr'] = "Domaine Parent"; + + $text['description-parent_domain']['en-us'] = "Set the parent domain."; + $text['description-parent_domain']['es-cl'] = "Establecer el dominio principal."; + $text['description-parent_domain']['pt-pt'] = "Defina o domínio pai."; + $text['description-parent_domain']['fr-fr'] = "Réglez le domaine parent."; + + $text['label-disabled']['en-us'] = "Disabled"; + $text['label-disabled']['es-cl'] = "Discapacitado"; + $text['label-disabled']['pt-pt'] = "Inválido"; + $text['label-disabled']['fr-fr'] = "Non Permis"; + ?> \ No newline at end of file diff --git a/core/domain_settings/domain_edit.php b/core/domain_settings/domain_edit.php index ec6d903bd1..838da35567 100644 --- a/core/domain_settings/domain_edit.php +++ b/core/domain_settings/domain_edit.php @@ -50,7 +50,11 @@ else { //get http post variables and set them to php variables if (count($_POST) > 0) { $domain_name = strtolower(check_str($_POST["domain_name"])); + $domain_parent_uuid = check_str($_POST["domain_parent_uuid"]); + $domain_enabled = check_str($_POST["domain_enabled"]); $domain_description = check_str($_POST["domain_description"]); + + $domain_parent_uuid = ($domain_parent_uuid == '') ? 'null' : "'".$domain_parent_uuid."'"; // fix null } if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { @@ -80,7 +84,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { if ($_POST["persistformvar"] != "true") { if ($action == "add" && permission_exists('domain_add')) { $sql = "select count(*) as num_rows from v_domains "; - $sql .= "where domain_name = '$domain_name' "; + $sql .= "where domain_name = '".$domain_name."' "; $prep_statement = $db->prepare($sql); if ($prep_statement) { $prep_statement->execute(); @@ -90,13 +94,17 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $sql .= "("; $sql .= "domain_uuid, "; $sql .= "domain_name, "; + $sql .= "domain_parent_uuid, "; + $sql .= "domain_enabled, "; $sql .= "domain_description "; $sql .= ")"; $sql .= "values "; $sql .= "("; $sql .= "'".uuid()."', "; - $sql .= "'$domain_name', "; - $sql .= "'$domain_description' "; + $sql .= "'".$domain_name."', "; + $sql .= $domain_parent_uuid.", "; + $sql .= "'".$domain_enabled."', "; + $sql .= "'".$domain_description."' "; $sql .= ")"; $db->exec(check_sql($sql)); unset($sql); @@ -120,6 +128,8 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { // update domain name, description $sql = "update v_domains set "; $sql .= "domain_name = '".$domain_name."', "; + $sql .= "domain_parent_uuid = ".$domain_parent_uuid.", "; + $sql .= "domain_enabled = '".$domain_enabled."', "; $sql .= "domain_description = '".$domain_description."' "; $sql .= "where domain_uuid = '".$domain_uuid."' "; $db->exec(check_sql($sql)); @@ -550,6 +560,8 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); foreach ($result as &$row) { $domain_name = strtolower($row["domain_name"]); + $domain_parent_uuid = $row["domain_parent_uuid"]; + $domain_enabled = $row["domain_enabled"]; $domain_description = $row["domain_description"]; } unset ($prep_statement); @@ -565,16 +577,10 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { } //show the content - 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"; @@ -615,33 +621,83 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { 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 "
"; + echo ""; if ($action == "update") { echo $text['header-domain-edit']; } @@ -582,7 +588,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo $text['header-domain-add']; } echo "\n"; + echo "\n"; echo " \n"; if (permission_exists('domain_export')) { echo " \n"; @@ -604,10 +610,10 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo "
\n"; - echo " ".$text['label-name'].":\n"; + echo " ".$text['label-name']."\n"; echo "\n"; - echo " \n"; + echo " \n"; echo "
\n"; echo $text['description-name']."\n"; echo "
\n"; - echo " ".$text['label-description'].":\n"; + echo " ".$text['label-parent_domain']."\n"; echo "\n"; - echo " \n"; + echo " \n"; + echo "
\n"; + echo $text['description-parent_domain']."\n"; + echo "
\n"; + echo " ".$text['label-enabled']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-domain_enabled']."\n"; + echo "
\n"; + echo " ".$text['label-description']."\n"; + echo "\n"; + echo " \n"; echo "
\n"; echo $text['description-description']."\n"; echo "
\n"; if ($action == "update") { - echo " \n"; + echo " \n"; } - echo " \n"; + echo "
"; + echo " \n"; echo "
"; - echo "
"; echo "
"; if ($action == "update") { + echo "

"; require "domain_settings.php"; } - echo "


"; - echo "
"; + //include the footer require_once "resources/footer.php"; diff --git a/core/domain_settings/domain_setting_edit.php b/core/domain_settings/domain_setting_edit.php index 9160cd1386..b02e1515a3 100644 --- a/core/domain_settings/domain_setting_edit.php +++ b/core/domain_settings/domain_setting_edit.php @@ -267,17 +267,10 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { } //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"; @@ -547,7 +540,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { } echo " \n"; echo "
\n"; - echo $text['description-enabled']."\n"; + echo $text['description-setting_enabled']."\n"; echo "\n"; echo "\n"; @@ -564,21 +557,18 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo " \n"; echo " \n"; echo " "; echo "
"; + echo ""; if ($action == "update") { echo $text['header-domain_setting-edit']; } @@ -285,7 +278,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo $text['header-domain_setting-add']; } echo ""; + echo ""; echo " "; echo " \n"; echo "
\n"; - echo " \n"; + echo " \n"; if ($action == "update") { - echo " \n"; + echo " \n"; } - echo " \n"; + echo "
"; + echo " \n"; echo "
"; + echo "
"; echo ""; - echo "
"; - echo "
"; - //include the footer require_once "resources/footer.php"; ?> \ No newline at end of file diff --git a/core/domain_settings/domain_settings.php b/core/domain_settings/domain_settings.php index 561dcf4d67..5bfc09fbcc 100644 --- a/core/domain_settings/domain_settings.php +++ b/core/domain_settings/domain_settings.php @@ -98,11 +98,6 @@ if (sizeof($_REQUEST) > 1) { echo ""; echo ""; - echo "
"; - echo "\n"; - echo "\n"; - echo " "; - echo ""; - echo "
\n"; - //prepare to page the results $sql = "select count(*) as num_rows from v_domain_settings "; $sql .= "where domain_uuid = '$domain_uuid' "; @@ -148,7 +143,6 @@ if (sizeof($_REQUEST) > 1) { $row_style["1"] = "row_style1"; //show the content - echo "
\n"; echo "\n"; if ($result_count > 0) { @@ -158,8 +152,9 @@ if (sizeof($_REQUEST) > 1) { $c = 0; echo "\n"; echo " \n"; echo "
\n"; - echo "
\n"; - echo "
\n"; + if ($previous_category != '') { + echo "

\n"; + } echo " \n"; if (strtolower($row['domain_setting_category']) == "cdr") { echo " CDR"; @@ -290,15 +285,6 @@ if (sizeof($_REQUEST) > 1) { echo "
"; - echo "
"; - echo "

"; - echo "

"; - - echo "
"; - echo "
"; - echo ""; echo "

"; diff --git a/core/domain_settings/domains.php b/core/domain_settings/domains.php index 0816fac096..e7de1175df 100644 --- a/core/domain_settings/domains.php +++ b/core/domain_settings/domains.php @@ -103,26 +103,19 @@ else { $order = check_str($_GET["order"]); } -//show the content - echo "
"; - echo "\n"; - echo "\n"; - echo " "; - echo ""; - echo "
\n"; - echo "
"; - //show the header and the search - echo "\n"; + echo "
\n"; echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; + echo " \n"; - echo " \n"; echo " \n"; echo " \n"; - echo " \n"; echo " \n"; @@ -136,7 +129,6 @@ else { $sql .= " or domain_description like '%".$search."%' "; $sql .= ") "; } - if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } $prep_statement = $db->prepare($sql); if ($prep_statement) { $prep_statement->execute(); @@ -169,20 +161,25 @@ else { $sql .= "order by domain_name asc "; } else { - $sql .= "order by $order_by $order "; + $sql .= "order by ".$order_by." ".$order." "; } - $sql .= " limit $rows_per_page offset $offset "; + $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); + foreach ($result as $domain) { + $domains[$domain['domain_uuid']]['name'] = $domain['domain_name']; + $domains[$domain['domain_uuid']]['parent_uuid'] = $domain['domain_parent_uuid']; + $domains[$domain['domain_uuid']]['enabled'] = $domain['domain_enabled']; + $domains[$domain['domain_uuid']]['description'] = $domain['domain_description']; + } + $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; - echo "
\n"; echo "
".$text['header-domains']."
\n"; + echo " ".$text['header-domains']."\n"; + echo " \n"; echo " "; echo " "; + echo " \n"; echo "
\n"; + echo " \n"; echo " ".$text['description-domains']."

\n"; echo "
\n"; echo "\n"; echo th_order_by('domain_name', $text['label-domain'], $order_by, $order); @@ -195,36 +192,54 @@ else { echo "\n"; echo "\n"; - if ($result_count > 0) { - foreach($result as $row) { - $tr_link = (permission_exists('domain_edit')) ? "href='domain_edit.php?id=".$row['domain_uuid']."'" : null; - echo "\n"; - echo " \n"; - echo " "; - echo " \n"; - echo " \n"; + echo " \n"; + echo " "; + echo " \n"; + echo " \n"; + echo "\n"; + $c = ($c == 0) ? 1 : 0; + + $indent++; + get_child_domains($domain_uuid); + $indent--; } } - echo " \n"; - echo "\n"; - if ($c==0) { $c=1; } else { $c=0; } - } //end foreach - unset($sql, $result, $row_count); + } + + $indent = 0; + get_child_domains(); + } //end if results echo "\n"; @@ -244,14 +259,6 @@ else { echo "\n"; echo "
"; - echo " ".$row['domain_name'].""; - echo " "; - if (permission_exists('domain_edit')) { - echo "".$text['label-manage'].""; - } - echo " ".$row['domain_description']." "; - if (permission_exists('domain_edit')) { - echo "$v_link_label_edit"; - } - if (permission_exists('domain_delete')) { - if ($_SESSION["groups"][0]["domain_uuid"] != $row['domain_uuid'] && $result_count > 1) { - echo "$v_link_label_delete"; - } - else { - echo "".$v_link_label_delete.""; + if (count($domains) > 0) { + + function get_child_domains($domain_parent_uuid) { + global $domains, $indent; + global $c, $row_style, $text, $v_link_label_edit, $v_link_label_delete; + foreach ($domains as $domain_uuid => $domain) { + if ($domain['parent_uuid'] == $domain_parent_uuid) { + + $tr_link = (permission_exists('domain_edit')) ? "href='domain_edit.php?id=".$domain_uuid."'" : null; + echo "
"; + echo " ".$domain['name'].""; + if ($domain['enabled'] != '' && $domain['enabled'] != 'true') { + echo "   (".$text['label-disabled'].")"; + } + echo " "; + if (permission_exists('domain_edit')) { + echo "".$text['label-manage'].""; + } + echo " ".$domain['description']." "; + if (permission_exists('domain_edit')) { + echo "".$v_link_label_edit.""; + } + if (permission_exists('domain_delete')) { + if ($_SESSION["groups"][0]["domain_uuid"] != $domain_uuid && count($domains) > 1) { + echo "".$v_link_label_delete.""; + } + else { + echo "".$v_link_label_delete.""; + } + } + echo "
"; - echo ""; - echo "

"; - echo "

"; - - echo "
"; - echo "
"; echo "

"; //include the footer