Add a new Domain Profile featue

Used to set domain wide settings like the language, time zone, and time format in an easy way.
This commit is contained in:
markjcrane
2026-05-26 16:55:06 +00:00
parent fbfc3b7099
commit 72db3b914e
4 changed files with 667 additions and 4 deletions
+4
View File
@@ -51,6 +51,10 @@
$apps[$x]['permissions'][$y]['name'] = "domain_select";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "domain_profile";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$y++;
//default settings
$y=0;
+188 -1
View File
@@ -27,6 +27,33 @@ $text['title-domains']['zh-cn'] = "域";
$text['title-domains']['ja-jp'] = "ドメイン";
$text['title-domains']['ko-kr'] = "도메인";
$text['title-domain_profile']['en-us'] = "Domain Profile";
$text['title-domain_profile']['en-gb'] = "Domain Profile";
$text['title-domain_profile']['ar-eg'] = "ملف المجال";
$text['title-domain_profile']['de-at'] = "Domänenprofil";
$text['title-domain_profile']['de-ch'] = "Domänenprofil";
$text['title-domain_profile']['de-de'] = "Domänenprofil";
$text['title-domain_profile']['el-gr'] = "Προφίλ Δομήν";
$text['title-domain_profile']['es-cl'] = "Perfil de Dominio";
$text['title-domain_profile']['es-mx'] = "Perfil de Dominio";
$text['title-domain_profile']['fr-ca'] = "Profil de domaine";
$text['title-domain_profile']['fr-fr'] = "Profil de domaine";
$text['title-domain_profile']['he-il'] = "פרופיל תחום";
$text['title-domain_profile']['it-it'] = "Profilo Dominio";
$text['title-domain_profile']['ka-ge'] = "დომენის პროფილი";
$text['title-domain_profile']['nl-nl'] = "Domeinprofiel";
$text['title-domain_profile']['pl-pl'] = "Profil Domeny";
$text['title-domain_profile']['pt-br'] = "Perfil de Domínio";
$text['title-domain_profile']['pt-pt'] = "Perfil de Domínio";
$text['title-domain_profile']['ro-ro'] = "Profil Domeniu";
$text['title-domain_profile']['ru-ru'] = "Профиль домена";
$text['title-domain_profile']['sv-se'] = "Domänprofil";
$text['title-domain_profile']['uk-ua'] = "Профіль домену";
$text['title-domain_profile']['tr-tr'] = "Alan Profili";
$text['title-domain_profile']['zh-cn'] = "域名档案";
$text['title-domain_profile']['ja-jp'] = "ドメインプロフィール";
$text['title-domain_profile']['ko-kr'] = "도메인 프로필";
$text['title-domain_setting-edit']['en-us'] = "Domain Setting";
$text['title-domain_setting-edit']['en-gb'] = "Domain Setting";
$text['title-domain_setting-edit']['ar-eg'] = "إعداد المجال";
@@ -1028,6 +1055,33 @@ $text['label-default_settings']['zh-cn'] = "默认设置";
$text['label-default_settings']['ja-jp'] = "デフォルトの設定";
$text['label-default_settings']['ko-kr'] = "기본 설정";
$text['label-time_zone']['en-us'] = "Time Zone";
$text['label-time_zone']['en-gb'] = "Time Zone";
$text['label-time_zone']['ar-eg'] = "المنطقة الزمنية";
$text['label-time_zone']['de-at'] = "Zeitzone";
$text['label-time_zone']['de-ch'] = "Zeitzone";
$text['label-time_zone']['de-de'] = "Zeitzone";
$text['label-time_zone']['el-gr'] = "Ζώνη ώρας";
$text['label-time_zone']['es-cl'] = "Zona Horaria";
$text['label-time_zone']['es-mx'] = "Zona Horaria";
$text['label-time_zone']['fr-ca'] = "Fuseau Horaire";
$text['label-time_zone']['fr-fr'] = "Fuseau Horaire";
$text['label-time_zone']['he-il'] = "אזור זמן";
$text['label-time_zone']['it-it'] = "Time Zone";
$text['label-time_zone']['ka-ge'] = "დროის სარტყელი";
$text['label-time_zone']['nl-nl'] = "Tijdzone";
$text['label-time_zone']['pl-pl'] = "Strefa czasowa";
$text['label-time_zone']['pt-br'] = "Fuso Horário";
$text['label-time_zone']['pt-pt'] = "Fuso Horário";
$text['label-time_zone']['ro-ro'] = "Fus orar";
$text['label-time_zone']['ru-ru'] = "Часовой пояс";
$text['label-time_zone']['sv-se'] = "Tidszon";
$text['label-time_zone']['uk-ua'] = "Часовий пояс";
$text['label-time_zone']['tr-tr'] = "Saat dilimi";
$text['label-time_zone']['zh-cn'] = "时间区";
$text['label-time_zone']['ja-jp'] = "タイムゾーン";
$text['label-time_zone']['ko-kr'] = "시간대";
$text['header-settings']['en-us'] = "Settings";
$text['header-settings']['en-gb'] = "Settings";
$text['header-settings']['ar-eg'] = "إعدادات";
@@ -1352,6 +1406,33 @@ $text['description-domains']['zh-cn'] = "控制要管理的域列表。";
$text['description-domains']['ja-jp'] = "管理するドメインのリストを制御します。";
$text['description-domains']['ko-kr'] = "관리할 도메인 목록을 제어합니다.";
$text['description-domain_profile']['en-us'] = "Centralized management of domain wide settings, including the Time Zone, Language, and other domain settings.";
$text['description-domain_profile']['en-gb'] = "Centralized management of domain wide settings, including the Time Zone, Language, and other domain settings.";
$text['description-domain_profile']['ar-eg'] = "مركزية إدارة الإعدادات الواسعة النطاق، بما في ذلك منطقة الزمن، اللغة، والإعدادات الأخرى للنطاق.";
$text['description-domain_profile']['de-at'] = "Zentralisierte Verwaltung von domänenweiten Einstellungen, darunter Zeitzone, Sprache und andere Domäneneinstellungen.";
$text['description-domain_profile']['de-ch'] = "Zentralisierte Verwaltung von domänenweiten Einstellungen, darunter Zeitzone, Sprache und andere Domäneneinstellungen.";
$text['description-domain_profile']['de-de'] = "Zentralisierte Verwaltung von domänenweiten Einstellungen, darunter Zeitzone, Sprache und andere Domäneneinstellungen.";
$text['description-domain_profile']['el-gr'] = "Κεντρική διαχείριση ρυθμίσεων σε όλο το πεδίο, συμπεριλαμβανομένης της Ζώνης Ώρας, της Γλώσσας και άλλων ρυθμίσεων πεδίου.";
$text['description-domain_profile']['es-cl'] = "Gestión centralizada de configuraciones a nivel de dominio, incluyendo Zona Horaria, Idioma y otras configuraciones del dominio.";
$text['description-domain_profile']['es-mx'] = "Administración centralizada de configuraciones a nivel de dominio, incluyendo Zona Horaria, Idioma y otras configuraciones del dominio.";
$text['description-domain_profile']['fr-ca'] = "Gestion centralisée des paramètres de domaine, y compris la zone horaire, la langue et autres paramètres de domaine.";
$text['description-domain_profile']['fr-fr'] = "Gestion centralisée des paramètres de domaine, y compris la zone horaire, la langue et autres paramètres de domaine.";
$text['description-domain_profile']['he-il'] = "ניהול מרכזי של הגדרות רחבות הנחלה, כולל אזור זמן, שפה והגדרות נחלה אחרות.";
$text['description-domain_profile']['it-it'] = "Gestione centralizzata delle impostazioni a livello di dominio, inclusi Fuso Orario, Lingua e altre impostazioni di dominio.";
$text['description-domain_profile']['ka-ge'] = "დომენის მასშტაბით პარამეტრების ცენტრალიზებული მართვა, მათ შორის დროის ზონა, ენა და სხვა დომენის პარამეტრები.";
$text['description-domain_profile']['nl-nl'] = "Gecentraliseerd beheer van domeinbrede instellingen, waaronder tijdzone, taal en andere domeininstellingen.";
$text['description-domain_profile']['pl-pl'] = "Centralne zarządzanie ustawieniami domeny, w tym strefą czasową, językiem i innymi ustawieniami domeny.";
$text['description-domain_profile']['pt-br'] = "Gerenciamento centralizado de configurações do domínio, incluindo Fuso Horário, Idioma e outras configurações do domínio.";
$text['description-domain_profile']['pt-pt'] = "Gestão centralizada de configurações do domínio, incluindo Fuso Horário, Idioma e outras configurações do domínio.";
$text['description-domain_profile']['ro-ro'] = "Gestionare centralizată a setărilor la nivel de domeniu, inclusiv fusul orar, limba și alte setări ale domeniului.";
$text['description-domain_profile']['ru-ru'] = "Централизованное управление настройками домена, включая часовой пояс, язык и другие настройки домена.";
$text['description-domain_profile']['sv-se'] = "Centraliserad hantering av domänövergripande inställningar, inklusive tidszon, språk och andra domäninställningar.";
$text['description-domain_profile']['uk-ua'] = "Централізоване управління налаштуваннями домену, включаючи часову зону, мову та інші налаштування домену.";
$text['description-domain_profile']['tr-tr'] = "Alan genelinde zaman dilimi, dil ve diğer alan ayarları gibi alan genelinde ayarların merkezi yönetimi.";
$text['description-domain_profile']['zh-cn'] = "域级别设置的集中管理,包括时区、语言和其他域设置。";
$text['description-domain_profile']['ja-jp'] = "ドメイン全体の設定の集中管理、タイムゾーン、言語、およびその他のドメイン設定を含む。";
$text['description-domain_profile']['ko-kr'] = "도메인 전체 설정의 중앙 관리, 시간대, 언어 및 기타 도메인 설정 포함.";
$text['description-domain_setting-edit']['en-us'] = "Edit a setting for this domain.";
$text['description-domain_setting-edit']['en-gb'] = "Edit a setting for this domain.";
$text['description-domain_setting-edit']['ar-eg'] = "تحرير إعداد لهذا المجال.";
@@ -1487,4 +1568,110 @@ $text['description-domain-add']['zh-cn'] = "在下面输入域详细信息。";
$text['description-domain-add']['ja-jp'] = "以下にドメインの詳細を入力します。";
$text['description-domain-add']['ko-kr'] = "아래에 도메인 세부 정보를 입력하십시오.";
?>
$text['description-domain_language']['en-us'] = "Select the language.";
$text['description-domain_language']['en-gb'] = "Select the language.";
$text['description-domain_language']['ar-eg'] = "اختيار اللغة.";
$text['description-domain_language']['de-at'] = "Sprache auswählen";
$text['description-domain_language']['de-ch'] = "Sprache auswählen";
$text['description-domain_language']['de-de'] = "Sprache auswählen";
$text['description-domain_language']['el-gr'] = "Επιλέξτε τη γλώσσα.";
$text['description-domain_language']['es-cl'] = "Seleccione el idioma.";
$text['description-domain_language']['es-mx'] = "Seleccione el idioma.";
$text['description-domain_language']['fr-ca'] = "Sélectionnez la langue.";
$text['description-domain_language']['fr-fr'] = "Sélectionnez la langue.";
$text['description-domain_language']['he-il'] = "בחר שפה";
$text['description-domain_language']['it-it'] = "Seleziona il linguaggio.";
$text['description-domain_language']['ka-ge'] = "აირჩიეთ ენა.";
$text['description-domain_language']['nl-nl'] = "Verkoop de taal.";
$text['description-domain_language']['pl-pl'] = "Wybierz język";
$text['description-domain_language']['pt-br'] = "Selecione o idioma.";
$text['description-domain_language']['pt-pt'] = "Selecione o idioma.";
$text['description-domain_language']['ro-ro'] = "Selecție limbă";
$text['description-domain_language']['ru-ru'] = "Выберите язык.";
$text['description-domain_language']['sv-se'] = "Välj Språk";
$text['description-domain_language']['uk-ua'] = "Виберіть мову";
$text['description-domain_language']['tr-tr'] = "Dili seçin.";
$text['description-domain_language']['zh-cn'] = "选择语言。";
$text['description-domain_language']['ja-jp'] = "言語を選択します。";
$text['description-domain_language']['ko-kr'] = "언어 선택";
$text['description-time_zone']['en-us'] = "Select the default time zone.";
$text['description-time_zone']['en-gb'] = "Select the default time zone.";
$text['description-time_zone']['ar-eg'] = "إختار المنطقة الزمنية الافتراضية";
$text['description-time_zone']['de-at'] = "Wählen Sie die Standard-Zeitzone";
$text['description-time_zone']['de-ch'] = "Wählen Sie die Standard-Zeitzone";
$text['description-time_zone']['de-de'] = "Wählen Sie die Standard-Zeitzone";
$text['description-time_zone']['el-gr'] = "Επιλέξτε την προεπιλεγμένη ζώνη ώρας.";
$text['description-time_zone']['es-cl'] = "Seleccione la zona horaria por defecto.";
$text['description-time_zone']['es-mx'] = "Seleccione la zona horaria por defecto.";
$text['description-time_zone']['fr-ca'] = "Sélectionnez le fuseau horaire par défaut.";
$text['description-time_zone']['fr-fr'] = "Sélectionnez le fuseau horaire par défaut.";
$text['description-time_zone']['he-il'] = "הגדר אזור זמן";
$text['description-time_zone']['it-it'] = "Seleziona la Time Zone di default.";
$text['description-time_zone']['ka-ge'] = "აირჩიეთ ნაგულისხმევი დროის სარტყელი.";
$text['description-time_zone']['nl-nl'] = "Verkoop de tijdzone.";
$text['description-time_zone']['pl-pl'] = "Wybierz domyślną strefę czasową";
$text['description-time_zone']['pt-br'] = "Escolha o fuso horário por omissão.";
$text['description-time_zone']['pt-pt'] = "Escolha o fuso horário por omissão.";
$text['description-time_zone']['ro-ro'] = "Selectați fusul orar implicit.";
$text['description-time_zone']['ru-ru'] = "Выберите часовой пояс по умолчанию.";
$text['description-time_zone']['sv-se'] = "Välj standard tidszon";
$text['description-time_zone']['uk-ua'] = "Виберіть часовий пояс за замовчуванням.";
$text['description-time_zone']['tr-tr'] = "Varsayılan saat dilimini seçin.";
$text['description-time_zone']['zh-cn'] = "选择默认时区。";
$text['description-time_zone']['ja-jp'] = "デフォルトのタイムゾーンを選択します。";
$text['description-time_zone']['ko-kr'] = "기본 시간대를 선택하십시오.";
$text['label-time_format']['en-us'] = "Time Format";
$text['label-time_format']['en-gb'] = "Time Format";
$text['label-time_format']['ar-eg'] = "تنسيق الوقت";
$text['label-time_format']['de-at'] = "Zeitformat";
$text['label-time_format']['de-ch'] = "Zeitformat";
$text['label-time_format']['de-de'] = "Zeitformat";
$text['label-time_format']['el-gr'] = "Μορφή ώρας";
$text['label-time_format']['es-cl'] = "Formato de hora";
$text['label-time_format']['es-mx'] = "Formato de hora";
$text['label-time_format']['fr-ca'] = "Format d'heure";
$text['label-time_format']['fr-fr'] = "Format d'heure";
$text['label-time_format']['he-il'] = "פורמט זמן";
$text['label-time_format']['it-it'] = "Formato ora";
$text['label-time_format']['ka-ge'] = "დროის ფორმატი";
$text['label-time_format']['nl-nl'] = "Tijdsindeling";
$text['label-time_format']['pl-pl'] = "Format czasu";
$text['label-time_format']['pt-br'] = "Formato de hora";
$text['label-time_format']['pt-pt'] = "Formato de hora";
$text['label-time_format']['ro-ro'] = "Format oră";
$text['label-time_format']['ru-ru'] = "Формат времени";
$text['label-time_format']['sv-se'] = "Tidsformat";
$text['label-time_format']['uk-ua'] = "Формат часу";
$text['label-time_format']['tr-tr'] = "Zaman formatı";
$text['label-time_format']['zh-cn'] = "时间格式";
$text['label-time_format']['ja-jp'] = "時間形式";
$text['label-time_format']['ko-kr'] = "시간 형식";
$text['description-time_format']['en-us'] = "Select the time format.";
$text['description-time_format']['en-gb'] = "Select the time format.";
$text['description-time_format']['ar-eg'] = "اختر تنسيق الوقت.";
$text['description-time_format']['de-at'] = "Wählen Sie das Zeitformat.";
$text['description-time_format']['de-ch'] = "Wählen Sie das Zeitformat.";
$text['description-time_format']['de-de'] = "Wählen Sie das Zeitformat.";
$text['description-time_format']['el-gr'] = "Επιλέξτε το μορφοποιημένο χρόνο.";
$text['description-time_format']['es-cl'] = "Seleccione el formato de hora.";
$text['description-time_format']['es-mx'] = "Seleccione el formato de hora.";
$text['description-time_format']['fr-ca'] = "Sélectionnez le format d'heure.";
$text['description-time_format']['fr-fr'] = "Sélectionnez le format d'heure.";
$text['description-time_format']['he-il'] = "בחר את פורמט השעה.";
$text['description-time_format']['it-it'] = "Seleziona il formato dell'ora.";
$text['description-time_format']['ka-ge'] = "თქვენ უნდა აირჩიოთ დროის ფორმატი.";
$text['description-time_format']['nl-nl'] = "Selecteer het tijdsformaat.";
$text['description-time_format']['pl-pl'] = "Wybierz format czasu.";
$text['description-time_format']['pt-br'] = "Selecione o formato de hora.";
$text['description-time_format']['pt-pt'] = "Selecione o formato de hora.";
$text['description-time_format']['ro-ro'] = "Selectați formatul orei.";
$text['description-time_format']['ru-ru'] = "Выберите формат времени.";
$text['description-time_format']['sv-se'] = "Välj tidsformat.";
$text['description-time_format']['uk-ua'] = "Оберіть формат часу.";
$text['description-time_format']['tr-tr'] = "Zaman formatını seçin.";
$text['description-time_format']['zh-cn'] = "选择时间格式.";
$text['description-time_format']['ja-jp'] = "時間の形式を選択してください.";
$text['description-time_format']['ko-kr'] = "시간 형식을 선택하세요.";
+31 -2
View File
@@ -32,5 +32,34 @@
$apps[$x]['menu'][$y]['order'] = "";
$apps[$x]['menu'][$y]['groups'][] = "superadmin";
$y++;
?>
$apps[$x]['menu'][$y]['title']['en-us'] = "Domain Profile";
$apps[$x]['menu'][$y]['title']['en-gb'] = "Domain Profile";
$apps[$x]['menu'][$y]['title']['ar-eg'] = "ملف تعريف النطاق";
$apps[$x]['menu'][$y]['title']['de-at'] = "Bereichsprofil";
$apps[$x]['menu'][$y]['title']['de-de'] = "Bereichsprofil";
$apps[$x]['menu'][$y]['title']['es-cl'] = "Perfil de Dominio";
$apps[$x]['menu'][$y]['title']['es-mx'] = "Perfil de Dominio";
$apps[$x]['menu'][$y]['title']['fr-ca'] = "Profil de domaine";
$apps[$x]['menu'][$y]['title']['fr-fr'] = "Profil de domaine";
$apps[$x]['menu'][$y]['title']['he-il'] = "פרופיל דומיין";
$apps[$x]['menu'][$y]['title']['it-it'] = "Profilo Dominio";
$apps[$x]['menu'][$y]['title']['ka-ge'] = "დომენის პროფილი";
$apps[$x]['menu'][$y]['title']['nl-nl'] = "Domeinprofiel";
$apps[$x]['menu'][$y]['title']['pl-pl'] = "Profil Domeny";
$apps[$x]['menu'][$y]['title']['pt-br'] = "Perfil de Domínio";
$apps[$x]['menu'][$y]['title']['pt-pt'] = "Perfil de Domínio";
$apps[$x]['menu'][$y]['title']['ro-ro'] = "Profil Domeniu";
$apps[$x]['menu'][$y]['title']['ru-ru'] = "Профиль домена";
$apps[$x]['menu'][$y]['title']['sv-se'] = "Domänprofil";
$apps[$x]['menu'][$y]['title']['uk-ua'] = "Профіль домену";
$apps[$x]['menu'][$y]['title']['zh-cn'] = "域名配置文件";
$apps[$x]['menu'][$y]['title']['ja-jp'] = "ドメインプロフィール";
$apps[$x]['menu'][$y]['title']['ko-kr'] = "도메인 프로필";
$apps[$x]['menu'][$y]['uuid'] = "84d72d69-0fc8-4414-a36a-a03b1255ff91";
$apps[$x]['menu'][$y]['parent_uuid'] = "02194288-6d56-6d3e-0b1a-d53a2bc10788";
$apps[$x]['menu'][$y]['category'] = "internal";
$apps[$x]['menu'][$y]['icon'] = "";
$apps[$x]['menu'][$y]['path'] = "/core/domains/domain_profile.php";
$apps[$x]['menu'][$y]['order'] = "";
$apps[$x]['menu'][$y]['groups'][] = "superadmin";
$apps[$x]['menu'][$y]['groups'][] = "admin";
+443
View File
@@ -0,0 +1,443 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2026
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (!permission_exists('domain_profile')) {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//get the domain details
$domain_name = $_SESSION['domain_name'];
$domain_uuid = $_SESSION['domain_uuid'];
//get all language codes from database
$sql = "select * from v_languages order by language asc ";
$languages = $database->select($sql, null, 'all');
//get domain settings
$sql = "select * from v_domain_settings ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and domain_setting_enabled = true ";
$parameters['domain_uuid'] = $domain_uuid;
$result = $database->select($sql, $parameters, 'all');
$domain_settings = [];
if (is_array($result)) {
foreach($result as $row) {
$category = $row['domain_setting_category'];
$subcategory = $row['domain_setting_subcategory'];
if (empty($subcategory)) {
//$$category[$name] = $row['domain_setting_value'];
$domain_settings[$category] = $row;
}
else {
$domain_settings[$category][$subcategory] = $row;
}
}
}
unset($sql, $parameters, $result, $row);
//process the http post
if (!empty($_POST)) {
//get the HTTP values and set as variables
$domain_language = $_POST["domain_language"];
$domain_time_zone = $_POST["domain_time_zone"];
$domain_time_format = $_POST["domain_time_format"];
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: users.php');
exit;
}
//check to see if domain language is set
$row = $domain_settings['domain']['language'] ?? [];
if (!empty($domain_language) && (empty($row) || (!empty($row['domain_setting_uuid']) && !is_uuid($row['domain_setting_uuid'])))) {
//add user setting to array for insert
$array['domain_settings'][$i]['domain_setting_uuid'] = uuid();
$array['domain_settings'][$i]['domain_uuid'] = $domain_uuid;
$array['domain_settings'][$i]['domain_setting_category'] = 'domain';
$array['domain_settings'][$i]['domain_setting_subcategory'] = 'language';
$array['domain_settings'][$i]['domain_setting_name'] = 'code';
$array['domain_settings'][$i]['domain_setting_value'] = $domain_language;
$array['domain_settings'][$i]['domain_setting_enabled'] = 'true';
$i++;
}
else {
if (empty($row['domain_setting_value']) || empty($domain_language)) {
$array_delete['domain_settings'][0]['domain_setting_category'] = 'domain';
$array_delete['domain_settings'][0]['domain_setting_subcategory'] = 'language';
$array_delete['domain_settings'][0]['domain_uuid'] = $domain_uuid;
$p = permissions::new();
$p->add('domain_setting_delete', 'temp');
$database->delete($array_delete);
unset($array_delete);
$p->delete('domain_setting_delete', 'temp');
}
if (!empty($domain_language)) {
//add user setting to array for update
$array['domain_settings'][$i]['domain_setting_uuid'] = $row['domain_setting_uuid'];
$array['domain_settings'][$i]['domain_uuid'] = $domain_uuid;
$array['domain_settings'][$i]['domain_uuid'] = $domain_uuid;
$array['domain_settings'][$i]['domain_setting_category'] = 'domain';
$array['domain_settings'][$i]['domain_setting_subcategory'] = 'language';
$array['domain_settings'][$i]['domain_setting_name'] = 'code';
$array['domain_settings'][$i]['domain_setting_value'] = $domain_language;
$array['domain_settings'][$i]['domain_setting_enabled'] = 'true';
$i++;
}
}
unset($sql, $parameters, $row);
//update switch timezone variables
if (permission_exists('dialplan_view')) {
//get the dialplan_uuid
$sql = "select dialplan_uuid from v_dialplans ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and app_uuid = '9f356fe7-8cf8-4c14-8fe2-6daf89304458' ";
$parameters['domain_uuid'] = $domain_uuid;
$dialplan_uuid = $database->select($sql, $parameters, 'column');
unset($sql, $parameters);
//get the action
$sql = "select dialplan_detail_uuid from v_dialplan_details ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and dialplan_uuid = :dialplan_uuid ";
$sql .= "and dialplan_detail_tag = 'action' ";
$sql .= "and dialplan_detail_type = 'set' ";
$sql .= "and dialplan_detail_data like 'timezone=%' ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['dialplan_uuid'] = $dialplan_uuid;
$dialplan_detail_uuid = $database->select($sql, $parameters, 'column');
$detail_action = is_uuid($dialplan_detail_uuid) ? 'update' : 'add';
unset($sql, $parameters);
//update the timezone
$p = permissions::new();
if ($detail_action == "update") {
$array['dialplan_details'][0]['dialplan_detail_uuid'] = $dialplan_detail_uuid;
$array['dialplan_details'][0]['dialplan_detail_data'] = 'timezone='.$domain_time_zone;
$array['dialplan_details'][0]['dialplan_detail_enabled'] = 'true';
$p->add('dialplan_detail_edit', 'temp');
}
else {
$array['dialplan_details'][0]['dialplan_detail_uuid'] = uuid();
$array['dialplan_details'][0]['domain_uuid'] = $domain_uuid;
$array['dialplan_details'][0]['dialplan_uuid'] = $dialplan_uuid;
$array['dialplan_details'][0]['dialplan_detail_tag'] = 'action';
$array['dialplan_details'][0]['dialplan_detail_type'] = 'set';
$array['dialplan_details'][0]['dialplan_detail_data'] = 'timezone='.$domain_time_zone;
$array['dialplan_details'][0]['dialplan_detail_inline'] = 'true';
$array['dialplan_details'][0]['dialplan_detail_group'] = '0';
$array['dialplan_details'][0]['dialplan_detail_order'] = '20';
$array['dialplan_details'][0]['dialplan_detail_enabled'] = 'true';
$p->add('dialplan_detail_add', 'temp');
}
//get the dialplan uuid
$sql = "select domain_name from v_domains ";
$sql .= "where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
$domain_name = $database->select($sql, $parameters, 'column');
unset($sql, $parameters);
//update the dialplan xml
$dialplans = new dialplan;
$dialplans->source = "details";
$dialplans->destination = "database";
$dialplans->uuid = $dialplan_uuid;
$dialplans->xml();
//clear the cache
$cache = new cache;
$cache->delete("dialplan:".$domain_name);
}
//check to see if domain time zone is set
$row = $domain_settings['domain']['time_zone'];
if (!empty($domain_time_zone) && (empty($row) || (!empty($row['domain_setting_uuid']) && !is_uuid($row['domain_setting_uuid'])))) {
//add user setting to array for insert
$array['domain_settings'][$i]['domain_setting_uuid'] = uuid();
$array['domain_settings'][$i]['domain_uuid'] = $domain_uuid;
$array['domain_settings'][$i]['domain_setting_category'] = 'domain';
$array['domain_settings'][$i]['domain_setting_subcategory'] = 'time_zone';
$array['domain_settings'][$i]['domain_setting_name'] = 'name';
$array['domain_settings'][$i]['domain_setting_value'] = $domain_time_zone;
$array['domain_settings'][$i]['domain_setting_enabled'] = 'true';
$i++;
}
else {
if (empty($row['domain_setting_value']) || empty($domain_time_zone)) {
$array_delete['domain_settings'][0]['domain_setting_category'] = 'domain';
$array_delete['domain_settings'][0]['domain_setting_subcategory'] = 'time_zone';
$array_delete['domain_settings'][0]['domain_uuid'] = $domain_uuid;
$p = permissions::new();
$p->add('domain_setting_delete', 'temp');
$database->delete($array_delete);
unset($array_delete);
$p->delete('domain_setting_delete', 'temp');
}
if (!empty($domain_time_zone)) {
//add user setting to array for update
$array['domain_settings'][$i]['domain_setting_uuid'] = $row['domain_setting_uuid'];
$array['domain_settings'][$i]['domain_uuid'] = $domain_uuid;
$array['domain_settings'][$i]['domain_setting_category'] = 'domain';
$array['domain_settings'][$i]['domain_setting_subcategory'] = 'time_zone';
$array['domain_settings'][$i]['domain_setting_name'] = 'name';
$array['domain_settings'][$i]['domain_setting_value'] = $domain_time_zone;
$array['domain_settings'][$i]['domain_setting_enabled'] = 'true';
$i++;
}
}
unset($sql, $parameters, $row);
//check to see if domain time_format is set
$row = $domain_settings['domain']['time_format'] ?? [];
if (!empty($domain_language) && (empty($row) || (!empty($row['domain_setting_uuid']) && !is_uuid($row['domain_setting_uuid'])))) {
//add user setting to array for insert
$array['domain_settings'][$i]['domain_setting_uuid'] = uuid();
$array['domain_settings'][$i]['domain_uuid'] = $domain_uuid;
$array['domain_settings'][$i]['domain_setting_category'] = 'domain';
$array['domain_settings'][$i]['domain_setting_subcategory'] = 'time_format';
$array['domain_settings'][$i]['domain_setting_name'] = 'text';
$array['domain_settings'][$i]['domain_setting_value'] = $domain_time_format;
$array['domain_settings'][$i]['domain_setting_enabled'] = 'true';
$i++;
}
else {
if (empty($row['domain_setting_value']) || empty($domain_time_format)) {
$array_delete['domain_settings'][0]['domain_setting_category'] = 'domain';
$array_delete['domain_settings'][0]['domain_setting_subcategory'] = 'time_format';
$array_delete['domain_settings'][0]['domain_uuid'] = $domain_uuid;
$p = permissions::new();
$p->add('domain_setting_delete', 'temp');
$database->delete($array_delete);
unset($array_delete);
$p->delete('domain_setting_delete', 'temp');
}
if (!empty($domain_time_format)) {
//add user setting to array for update
$array['domain_settings'][$i]['domain_setting_uuid'] = $row['domain_setting_uuid'];
$array['domain_settings'][$i]['domain_uuid'] = $domain_uuid;
$array['domain_settings'][$i]['domain_uuid'] = $domain_uuid;
$array['domain_settings'][$i]['domain_setting_category'] = 'domain';
$array['domain_settings'][$i]['domain_setting_subcategory'] = 'time_format';
$array['domain_settings'][$i]['domain_setting_name'] = 'text';
$array['domain_settings'][$i]['domain_setting_value'] = $domain_time_format;
$array['domain_settings'][$i]['domain_setting_enabled'] = 'true';
$i++;
}
}
unset($sql, $parameters, $row);
//initialize the permissing object
$p = permissions::new();
//add temporary permissions
$p->add("domain_setting_add", "temp");
$p->add("domain_setting_edit", "temp");
//save the data
if (!empty($array)) {
$database->save($array);
//$message = $database->message;
}
//remove the temporary permissions
$p->delete("domain_setting_add", "temp");
$p->delete("domain_setting_edit", "temp");
//clear the menu
unset($_SESSION["menu"]);
//get settings based on the user
$settings = new settings(['database' => $database, 'domain_uuid' => $_SESSION['domain_uuid']]);
settings::clear_cache();
//response message
message::add($text['message-update'],'positive');
//redirect
header('Location: domain_profile.php');
exit;
}
//populate form
if (persistent_form_values('exists')) {
//populate the form with values from session variable
persistent_form_values('load');
//clear, set $unsaved flag
persistent_form_values('clear');
}
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//include the header
require_once "resources/header.php";
$document['title'] = $text['title-domain_profile'];
//show the content
echo "<form name='frm' id='frm' method='post' enctype='multipart/form-data'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-domain_profile']."</b></div>\n";
echo " <div class='actions'>\n";
if (!empty($unsaved)) {
echo "<div class='unsaved'>".$text['message-unsaved_changes']." <i class='fas fa-exclamation-triangle'></i></div>";
}
$button_margin = 'margin-left: 15px;';
echo button::create(['type'=>'button','label'=>$text['button-save'],'icon'=>$settings->get('theme', 'button_icon_save'),'id'=>'btn_save','style'=>'margin-left: 15px;','onclick'=>'submit_form();']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['description-domain_profile']."\n";
echo "<br /><br />\n";
echo "<div class='card'>\n";
echo "<table cellpadding='0' cellspacing='0' border='0' width='100%' class='mb-4'>";
// echo "<table cellpadding='0' cellspacing='0' border='0' width='100%'>";
// echo " <tr>";
// echo " <td class='vncellreq'>".$text['label-email']."</td>";
// echo " <td class='vtable'><input type='text' class='formfld' name='user_email' value='".escape($user_email ?? '')."' required='required'></td>";
// echo " </tr>";
echo " <tr>\n";
echo " <td width='20%' class=\"vncell\" valign='top'>\n";
echo " ".$text['label-language']."\n";
echo " </td>\n";
echo " <td class=\"vtable\" align='left'>\n";
echo " <select id='domain_language' name='domain_language' class='formfld' style=''>\n";
echo " <option value=''></option>\n";
if (!empty($languages) && is_array($languages) && sizeof($languages) != 0) {
foreach ($languages as $row) {
$language_codes[$row["code"]] = $row["language"];
}
}
unset($sql, $languages, $row);
if (is_array($_SESSION['app']['languages']) && sizeof($_SESSION['app']['languages']) != 0) {
foreach ($_SESSION['app']['languages'] as $code) {
$selected = (isset($domain_language) && $code == $domain_language) || (isset($domain_settings['domain']['language']['domain_setting_value']) && $code == $domain_settings['domain']['language']['domain_setting_value']) ? "selected='selected'" : null;
echo " <option value='".$code."' ".$selected.">".escape($language_codes[$code] ?? $language_codes[explode('-', $code)[0]] ?? null)." [".escape($code ?? null)."]</option>\n";
}
}
echo " </select>\n";
echo " <br />\n";
echo " ".$text['description-domain_language']."<br />\n";
echo " </td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td width='20%' class=\"vncell\" valign='top'>\n";
echo " ".$text['label-time_zone']."\n";
echo " </td>\n";
echo " <td class=\"vtable\" align='left'>\n";
echo " <select id='domain_time_zone' name='domain_time_zone' class='formfld' style=''>\n";
echo " <option value=''></option>\n";
//$list = DateTimeZone::listAbbreviations();
$time_zone_identifiers = DateTimeZone::listIdentifiers();
$previous_category = '';
$x = 0;
foreach ($time_zone_identifiers as $key => $row) {
$time_zone = explode("/", $row);
$category = $time_zone[0];
if ($category != $previous_category) {
if ($x > 0) {
echo " </optgroup>\n";
}
echo " <optgroup label='".$category."'>\n";
}
$selected = (isset($domain_time_zone) && $row == $domain_time_zone) || (!empty($domain_settings['domain']['time_zone']['domain_setting_value']) && $row == $domain_settings['domain']['time_zone']['domain_setting_value']) ? "selected='selected'" : null;
echo " <option value='".escape($row)."' ".$selected.">".escape($row)."</option>\n";
$previous_category = $category;
$x++;
}
echo " </select>\n";
echo " <br />\n";
echo " ".$text['description-time_zone']."<br />\n";
echo " </td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td width='20%' class=\"vncell\" valign='top'>\n";
echo " ".$text['label-time_format']."\n";
echo " </td>\n";
echo " <td class=\"vtable\" align='left'>\n";
echo " <select class='formfld' id='domain_time_format' name='domain_time_format'>\n";
echo " <option value=''></option>\n";
echo " <option value='12h' ".(($domain_settings['domain']['time_format']['domain_setting_value'] == "12h") ? "selected='selected'" : null).">".$text['label-12-hour']."</option>\n";
echo " <option value='24h' ".(($domain_settings['domain']['time_format']['domain_setting_value'] == "24h") ? "selected='selected'" : null).">".$text['label-24-hour']."</option>\n";
echo " </select>\n";
echo " <br />\n";
echo " ".$text['description-time_format']."<br />\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>";
echo "</div>\n";
echo "<br /><br />";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>";
//hide password fields before submit
echo "<script>\n";
echo " function submit_form() {\n";
echo " hide_password_fields();\n";
echo " $('form#frm').submit();\n";
echo " }\n";
echo "</script>\n";
//include the footer
require_once "resources/footer.php";
?>