Use the settings class

This commit is contained in:
FusionPBX 2024-12-16 18:48:44 -07:00 committed by GitHub
parent 38b02f11d5
commit d9f401f577
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 28 additions and 24 deletions

View File

@ -74,6 +74,10 @@
$total_ring_groups = $database->select($sql, $parameters ?? null, 'column');
unset($sql, $parameters);
//get the domain_uuid
$domain_uuid = $_SESSION['domain_uuid'];
$domain_name = $_SESSION['domain_name'];
//action add or update
if (!empty($_REQUEST["id"]) || !empty($_REQUEST["ring_group_uuid"])) {
$action = "update";
@ -86,19 +90,19 @@
//get the domain_uuid
if (is_uuid($ring_group_uuid) && permission_exists('ring_group_all')) {
$sql = "select domain_uuid from v_ring_groups ";
$sql = "select r.domain_uuid, d.domain_name ";
$sql .= "from v_ring_groups as r, v_domains as d ";
$sql .= "where ring_group_uuid = :ring_group_uuid ";
$sql .= "and r.domain_uuid = d.domain_uuid ";
$parameters['ring_group_uuid'] = $ring_group_uuid;
$domain_uuid = $database->select($sql, $parameters, 'column');
$row = $database->select($sql, $parameters, 'row');
$domain_uuid = $row['domain_uuid'];
$domain_name = $row['domain_name'];
unset($sql, $parameters);
}
else {
$domain_uuid = $_SESSION['domain_uuid'];
}
}
else {
$action = "add";
$domain_uuid = $_SESSION['domain_uuid'];
}
//delete the user from the ring group
@ -135,15 +139,15 @@
}
//get total ring group count from the database, check limit, if defined
if ($action == 'add' && $_SESSION['limit']['ring_groups']['numeric'] ?? '') {
if ($action == 'add' && $settings->get('limit', 'ring_groups', '') ?? '') {
$sql = "select count(*) from v_ring_groups ";
$sql .= "where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
$total_ring_groups = $database->select($sql, $parameters, 'column');
unset($sql, $parameters);
if (is_numeric($_SESSION['limit']['ring_groups']['numeric']) && $total_ring_groups >= $_SESSION['limit']['ring_groups']['numeric']) {
message::add($text['message-maximum_ring_groups'].' '.$_SESSION['limit']['ring_groups']['numeric'], 'negative');
if (is_numeric($settings->get('limit', 'ring_groups', '')) && $total_ring_groups >= $settings->get('limit', 'ring_groups', '')) {
message::add($text['message-maximum_ring_groups'].' '.$settings->get('limit', 'ring_groups', ''), 'negative');
header('Location: ring_groups.php');
exit;
}
@ -217,7 +221,7 @@
$ring_group_context = $_POST["ring_group_context"];
}
else if ($action == 'add') {
$ring_group_context = $_SESSION['domain_name'];
$ring_group_context = $domain_name;
}
//if the user doesn't have the correct permission then
@ -413,7 +417,7 @@
else {
$ring_group_destination_uuid = uuid();
}
if (!empty($row['destination_number']) && $_SESSION['ring_group']['destination_range_enabled']['boolean']) {
if (!empty($row['destination_number']) && $settings->get('ring_group', 'destination_range_enabled', false)) {
// check the range
$output_array = array();
preg_match('/[0-9]{1,}-[0-9]{1,}/', $row['destination_number'], $output_array);
@ -586,8 +590,8 @@
}
//set the defaults
$destination_delay_max = $_SESSION['ring_group']['destination_delay_max']['numeric'];
$destination_timeout_max = $_SESSION['ring_group']['destination_timeout_max']['numeric'];
$destination_delay_max = $settings->get('ring_group', 'destination_delay_max', '');
$destination_timeout_max = $settings->get('ring_group', 'destination_timeout_max', '');;
if (empty($ring_group_call_timeout)) {
$ring_group_call_timeout = '30';
}
@ -611,12 +615,12 @@
//add an empty row to the options array
if (!isset($ring_group_destinations) || count($ring_group_destinations) == 0) {
$rows = $_SESSION['ring_group']['destination_add_rows']['numeric'];
$rows = $settings->get('ring_group', 'destination_add_rows', 5);
$id = 0;
$show_destination_delete = false;
}
if (isset($ring_group_destinations) && count($ring_group_destinations) > 0) {
$rows = $_SESSION['ring_group']['destination_edit_rows']['numeric'];
$rows = $settings->get('ring_group', 'destination_edit_rows', 1);
$id = count($ring_group_destinations)+1;
$show_destination_delete = true;
}
@ -657,7 +661,7 @@
//set the default ring group context
if (empty($ring_group_context)) {
$ring_group_context = $_SESSION['domain_name'];
$ring_group_context = $domain_name;
}
//get the ring backs
@ -752,7 +756,7 @@
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','link'=>'ring_groups.php']);
if ($action == 'update') {
$button_margin = 'margin-left: 15px;';
if (permission_exists('ring_group_add') && (!isset($_SESSION['limit']['ring_groups']['numeric']) || ($total_ring_groups < $_SESSION['limit']['ring_groups']['numeric']))) {
if (permission_exists('ring_group_add') && (empty($settings->get('limit', 'ring_groups', '')) || ($total_ring_groups < $settings->get('limit', 'ring_groups', '')))) {
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'name'=>'btn_copy','style'=>$button_margin,'onclick'=>"modal_open('modal-copy','btn_copy');"]);
unset($button_margin);
}
@ -767,7 +771,7 @@
echo "</div>\n";
if ($action == "update") {
if (permission_exists('ring_group_add') && (!isset($_SESSION['limit']['ring_groups']['numeric']) || ($total_ring_groups < $_SESSION['limit']['ring_groups']['numeric']))) {
if (permission_exists('ring_group_add') && (empty($settings->get('limit', 'ring_groups', '')) || ($total_ring_groups < $settings->get('limit', 'ring_groups', '')))) {
echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'copy','onclick'=>"modal_close();"])]);
}
if (permission_exists('ring_group_delete') || permission_exists('ring_group_destination_delete')) {
@ -797,7 +801,7 @@
echo " ".$text['label-extension']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='ring_group_extension' maxlength='255' value=\"".escape($ring_group_extension)."\" required='required' placeholder=\"".($_SESSION['ring_group']['extension_range']['text'] ?? '')."\">\n";
echo " <input class='formfld' type='text' name='ring_group_extension' maxlength='255' value=\"".escape($ring_group_extension)."\" required='required' placeholder=\"".($settings->get('ring_group', 'extension_range', '') ?? '')."\">\n";
echo "<br />\n";
echo $text['description-extension']."\n";
echo "</td>\n";
@ -824,8 +828,8 @@
if ($key == 'recordings') {
if (
!empty($instance_value) &&
($instance_value == $row["value"] || $instance_value == $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.$row["value"]) &&
file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.pathinfo($row["value"], PATHINFO_BASENAME))
($instance_value == $row["value"] || $instance_value == $settings->get('switch', 'recordings', '')."/".$domain_name.'/'.$row["value"]) &&
file_exists($settings->get('switch', 'recordings', '')."/".$domain_name.'/'.pathinfo($row["value"], PATHINFO_BASENAME))
) {
$selected = "selected='selected'";
$playable = '../recordings/recordings.php?action=download&type=rec&filename='.pathinfo($row["value"], PATHINFO_BASENAME);
@ -930,7 +934,7 @@
echo " <tr>\n";
echo " <td class='formfld'>\n";
if (!isset($row['ring_group_destination_uuid'])) { // new record
if (substr($_SESSION['theme']['input_toggle_style']['text'], 0, 6) == 'switch') {
if (substr($settings->get('theme', 'input_toggle_style', ''), 0, 6) == 'switch') {
$onkeyup = "onkeyup=\"document.getElementById('ring_group_destinations_".$x."_destination_enabled').checked = (this.value != '' ? true : false);\""; // switch
}
else {
@ -982,7 +986,7 @@
echo " </td>\n";
echo " <td class='formfld'>\n";
// switch
if (substr($_SESSION['theme']['input_toggle_style']['text'], 0, 6) == 'switch') {
if (substr($settings->get('theme', 'input_toggle_style', ''), 0, 6) == 'switch') {
echo " <label class='switch'>\n";
echo " <input type='checkbox' id='ring_group_destinations_".$x."_destination_enabled' name='ring_group_destinations[".$x."][destination_enabled]' value='true' ".(!empty($row['destination_enabled']) && $row['destination_enabled'] == 'true' ? "checked='checked'" : null).">\n";
echo " <span class='slider'></span>\n";
@ -1293,7 +1297,7 @@
echo " ".$text['label-enabled']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
if (substr($_SESSION['theme']['input_toggle_style']['text'], 0, 6) == 'switch') {
if (substr($settings->get('theme', 'input_toggle_style', ''), 0, 6) == 'switch') {
echo " <label class='switch'>\n";
echo " <input type='checkbox' id='ring_group_enabled' name='ring_group_enabled' value='true' ".($ring_group_enabled == 'true' ? "checked='checked'" : null).">\n";
echo " <span class='slider'></span>\n";