Update default and domain setting session array

In the "domains" class upgrade method, only set the value when either "default_setting_enabled" is true or "domain_setting_enabled" is equal to true.
This commit is contained in:
FusionPBX 2023-08-28 14:45:39 -06:00 committed by GitHub
parent 401a914726
commit 4eb7fdf007
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 54 additions and 47 deletions

View File

@ -513,8 +513,10 @@ if (!class_exists('domains')) {
unset($_SESSION[$category][$subcategory]);
}
}
//set the enabled settings as a session
foreach ($result as $row) {
if ($row['domain_setting_enabled'] == 'true') {
$name = $row['domain_setting_name'];
$category = $row['domain_setting_category'];
$subcategory = $row['domain_setting_subcategory'];
@ -538,6 +540,7 @@ if (!class_exists('domains')) {
}
}
}
}
//get the user settings
if (array_key_exists("domain_uuid",$_SESSION) && array_key_exists("user_uuid",$_SESSION) && is_uuid($_SESSION["domain_uuid"])) {
@ -676,13 +679,11 @@ if (!class_exists('domains')) {
//get the default settings - this needs to be done to reset the session values back to the defaults for each domain in the loop
foreach($database_default_settings as $row) {
if ($row['default_setting_enabled'] == 'true') {
$name = $row['default_setting_name'];
$category = $row['default_setting_category'];
$subcategory = $row['default_setting_subcategory'];
if (empty($subcategory)) {
if (!isset($_SESSION[$category])) {
$_SESSION[$category] = [];
}
if ($name == "array") {
$_SESSION[$category][] = $row['default_setting_value'];
}
@ -691,12 +692,6 @@ if (!class_exists('domains')) {
}
}
else {
if (!isset($_SESSION[$category])) {
$_SESSION[$category] = [];
}
if (!isset($_SESSION[$category][$subcategory])) {
$_SESSION[$category][$subcategory] = [];
}
if ($name == "array") {
$_SESSION[$category][$subcategory][] = $row['default_setting_value'];
}
@ -706,23 +701,35 @@ if (!class_exists('domains')) {
}
}
}
}
//get the domains settings for the current domain
foreach($domain_settings as $row) {
if ($row['domain_uuid'] == $domain_uuid) {
//set the enabled settings as a session
foreach ($domain_settings as $row) {
if ($row['domain_setting_enabled'] == 'true') {
$name = $row['domain_setting_name'];
$category = $row['domain_setting_category'];
$subcategory = $row['domain_setting_subcategory'];
if (empty($subcategory)) {
//$$category[$name] = $row['domain_setting_value'];
if ($name == "array") {
$_SESSION[$category][] = $row['domain_setting_value'];
}
else {
$_SESSION[$category][$name] = $row['domain_setting_value'];
}
}
else {
//$$category[$subcategory][$name] = $row['domain_setting_value'];
if ($name == "array") {
$_SESSION[$category][$subcategory][] = $row['domain_setting_value'];
}
else {
$_SESSION[$category][$subcategory][$name] = $row['domain_setting_value'];
}
}
}
}
//get the list of installed apps from the core and mod directories and execute the php code in app_defaults.php
$default_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_defaults.php");