mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
Update domains all and session methods
Updated to improve and simplify it
This commit is contained in:
@@ -721,27 +721,20 @@
|
||||
/**
|
||||
* get a domain list
|
||||
*/
|
||||
public function all() {
|
||||
//get the domains from the database
|
||||
if ($this->database->table_exists('v_domains')) {
|
||||
$sql = "select * from v_domains order by domain_name asc;";
|
||||
$result = $this->database->select($sql, null, 'all');
|
||||
foreach($result as $row) {
|
||||
$domain_names[] = $row['domain_name'];
|
||||
}
|
||||
unset($prep_statement);
|
||||
}
|
||||
public function all(bool $domain_enabled = true) {
|
||||
|
||||
//build the domains array in the correct order
|
||||
if (is_array($domain_names)) {
|
||||
foreach ($domain_names as $dn) {
|
||||
foreach ($result as $row) {
|
||||
if ($row['domain_name'] == $dn) {
|
||||
$domains[] = $row;
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($result);
|
||||
//define default return value
|
||||
$domains = [];
|
||||
|
||||
//get the domains from the database
|
||||
$sql = "select * from v_domains ";
|
||||
if ($domain_enabled) {
|
||||
$sql .= "where domain_enabled = true ";
|
||||
}
|
||||
$sql .= "order by domain_name asc; ";
|
||||
$result = $this->database->select($sql, null, 'all');
|
||||
if (!empty($result)) {
|
||||
$domains = $result;
|
||||
}
|
||||
|
||||
//return the domains array
|
||||
@@ -759,25 +752,20 @@
|
||||
$domain_array = explode(":", $_SERVER["HTTP_HOST"] ?? '');
|
||||
|
||||
//set domain_name and domain_uuid and update domains array with domain_uuid as the key
|
||||
if (!empty($domains) && is_array($domains)) {
|
||||
foreach($domains as $row) {
|
||||
if (!isset($_SESSION['username'])) {
|
||||
if (!empty($domains) && count($domains) == 1) {
|
||||
$domain_uuid = $row["domain_uuid"];
|
||||
$domain_name = $row['domain_name'];
|
||||
foreach($domains as $row) {
|
||||
if (!isset($_SESSION['username'])) {
|
||||
if (!empty($domains) && count($domains) == 1) {
|
||||
$_SESSION["domain_uuid"] = $row["domain_uuid"];
|
||||
$_SESSION["domain_name"] = $row['domain_name'];
|
||||
}
|
||||
else {
|
||||
if ($row['domain_name'] == $domain_array[0] || $row['domain_name'] == 'www.'.$domain_array[0]) {
|
||||
$_SESSION["domain_uuid"] = $row["domain_uuid"];
|
||||
$_SESSION["domain_name"] = $row['domain_name'];
|
||||
}
|
||||
else {
|
||||
if ($row['domain_name'] == $domain_array[0] || $row['domain_name'] == 'www.'.$domain_array[0]) {
|
||||
$_SESSION["domain_uuid"] = $row["domain_uuid"];
|
||||
$_SESSION["domain_name"] = $row["domain_name"];
|
||||
}
|
||||
$_SESSION["domain_name"] = $row["domain_name"];
|
||||
}
|
||||
}
|
||||
$_SESSION['domains'][$row['domain_uuid']] = $row;
|
||||
}
|
||||
unset($domains, $prep_statement);
|
||||
$_SESSION['domains'][$row['domain_uuid']] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user