Update destination_edit.php
- Use one database connection - Use the settings class - Use setting call_recordings record_extension this fixes a problem where the recording extension may not be set.
This commit is contained in:
parent
31ec917c64
commit
ce114a4bb2
|
|
@ -41,10 +41,13 @@
|
||||||
$language = new text;
|
$language = new text;
|
||||||
$text = $language->get();
|
$text = $language->get();
|
||||||
|
|
||||||
//initialize the database
|
//initialize the database object
|
||||||
$database = new database;
|
$database = database::new();
|
||||||
|
|
||||||
//initialize the destinations object
|
//initialize the settings object
|
||||||
|
$settings = new settings(['database' => $database, 'domain_uuid' => $domain_uuid]);
|
||||||
|
|
||||||
|
//initialize the destination object
|
||||||
$destination = new destinations;
|
$destination = new destinations;
|
||||||
|
|
||||||
//initialize the ringbacks object
|
//initialize the ringbacks object
|
||||||
|
|
@ -68,17 +71,20 @@
|
||||||
default: $destination_type = 'inbound';
|
default: $destination_type = 'inbound';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//get the call recording extension
|
||||||
|
$record_extension = $settings->get('call_recordings', 'record_extension', 'mp3');
|
||||||
|
|
||||||
//get total destination count from the database, check limit, if defined
|
//get total destination count from the database, check limit, if defined
|
||||||
if (!permission_exists('destination_domain')) {
|
if (!permission_exists('destination_domain')) {
|
||||||
if ($action == 'add') {
|
if ($action == 'add') {
|
||||||
if (!empty($_SESSION['limit']['destinations']['numeric'])) {
|
if (!empty($settings->get('limit', 'destinations', ''))) {
|
||||||
$sql = "select count(*) from v_destinations where domain_uuid = :domain_uuid ";
|
$sql = "select count(*) from v_destinations where domain_uuid = :domain_uuid ";
|
||||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||||
$total_destinations = $database->select($sql, $parameters, 'column');
|
$total_destinations = $database->select($sql, $parameters, 'column');
|
||||||
unset($sql, $parameters);
|
unset($sql, $parameters);
|
||||||
|
|
||||||
if ($total_destinations >= $_SESSION['limit']['destinations']['numeric']) {
|
if ($total_destinations >= $settings->get('limit', 'destinations', '')) {
|
||||||
message::add($text['message-maximum_destinations'].' '.$_SESSION['limit']['destinations']['numeric'], 'negative');
|
message::add($text['message-maximum_destinations'].' '.$settings->get('limit', 'destinations', ''), 'negative');
|
||||||
header('Location: destinations.php');
|
header('Location: destinations.php');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
@ -198,7 +204,7 @@
|
||||||
if (empty($destination_enabled)) { $msg .= $text['message-required']." ".$text['label-destination_enabled']."<br>\n"; }
|
if (empty($destination_enabled)) { $msg .= $text['message-required']." ".$text['label-destination_enabled']."<br>\n"; }
|
||||||
|
|
||||||
//check for duplicates
|
//check for duplicates
|
||||||
if ($destination_type == 'inbound' && $destination_number != $db_destination_number && $_SESSION['destinations']['unique']['boolean'] == 'true') {
|
if ($destination_type == 'inbound' && $destination_number != $db_destination_number && $settings->get('destinations', 'unique', '')) {
|
||||||
$sql = "select count(*) from v_destinations ";
|
$sql = "select count(*) from v_destinations ";
|
||||||
$sql .= "where (destination_number = :destination_number or destination_prefix || destination_number = :destination_number) ";
|
$sql .= "where (destination_number = :destination_number or destination_prefix || destination_number = :destination_number) ";
|
||||||
$sql .= "and destination_type = 'inbound' ";
|
$sql .= "and destination_type = 'inbound' ";
|
||||||
|
|
@ -444,15 +450,15 @@
|
||||||
if (!empty($destination_condition_field)) {
|
if (!empty($destination_condition_field)) {
|
||||||
$dialplan_detail_type = $destination_condition_field;
|
$dialplan_detail_type = $destination_condition_field;
|
||||||
}
|
}
|
||||||
elseif (!empty($_SESSION['dialplan']['destination']['text'])) {
|
elseif (!empty($settings->get('dialplan', 'destination', ''))) {
|
||||||
$dialplan_detail_type = $_SESSION['dialplan']['destination']['text'];
|
$dialplan_detail_type = $settings->get('dialplan', 'destination', '');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$dialplan_detail_type = "destination_number";
|
$dialplan_detail_type = "destination_number";
|
||||||
}
|
}
|
||||||
|
|
||||||
//authorized specific dialplan_detail_type that are safe, sanitize all other values
|
//authorized specific dialplan_detail_type that are safe, sanitize all other values
|
||||||
$dialplan_detail_type = $_SESSION['dialplan']['destination']['text'];
|
$dialplan_detail_type = $settings->get('dialplan', 'destination', '');
|
||||||
switch ($dialplan_detail_type) {
|
switch ($dialplan_detail_type) {
|
||||||
case 'destination_number':
|
case 'destination_number':
|
||||||
break;
|
break;
|
||||||
|
|
@ -530,10 +536,11 @@
|
||||||
}
|
}
|
||||||
if (!empty($destination_record) && $destination_record == 'true') {
|
if (!empty($destination_record) && $destination_record == 'true') {
|
||||||
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"record_path=\${recordings_dir}/\${domain_name}/archive/\${strftime(%Y)}/\${strftime(%b)}/\${strftime(%d)}\" inline=\"true\"/>\n";
|
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"record_path=\${recordings_dir}/\${domain_name}/archive/\${strftime(%Y)}/\${strftime(%b)}/\${strftime(%d)}\" inline=\"true\"/>\n";
|
||||||
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"record_name=\${uuid}.\${record_ext}\" inline=\"true\"/>\n";
|
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"record_name=\${uuid}.".$record_extension."\" inline=\"true\"/>\n";
|
||||||
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"record_append=true\" inline=\"true\"/>\n";
|
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"record_append=true\" inline=\"true\"/>\n";
|
||||||
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"record_in_progress=true\" inline=\"true\"/>\n";
|
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"record_in_progress=true\" inline=\"true\"/>\n";
|
||||||
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"recording_follow_transfer=true\" inline=\"true\"/>\n";
|
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"recording_follow_transfer=true\" inline=\"true\"/>\n";
|
||||||
|
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"record_stereo_swap=true\" inline=\"true\"/>\n";
|
||||||
$dialplan["dialplan_xml"] .= " <action application=\"record_session\" data=\"\${record_path}/\${record_name}\" inline=\"false\"/>\n";
|
$dialplan["dialplan_xml"] .= " <action application=\"record_session\" data=\"\${record_path}/\${record_name}\" inline=\"false\"/>\n";
|
||||||
}
|
}
|
||||||
if (!empty($destination_hold_music)) {
|
if (!empty($destination_hold_music)) {
|
||||||
|
|
@ -592,7 +599,7 @@
|
||||||
$dialplan["dialplan_xml"] .= "</extension>\n";
|
$dialplan["dialplan_xml"] .= "</extension>\n";
|
||||||
|
|
||||||
//dialplan details
|
//dialplan details
|
||||||
if ($_SESSION['destinations']['dialplan_details']['boolean'] == "true") {
|
if ($settings->get('destinations', 'dialplan_details', '')) {
|
||||||
|
|
||||||
//set initial value of the row id
|
//set initial value of the row id
|
||||||
$y=0;
|
$y=0;
|
||||||
|
|
@ -633,8 +640,8 @@
|
||||||
if (!empty($destination_condition_field)) {
|
if (!empty($destination_condition_field)) {
|
||||||
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $destination_condition_field;
|
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $destination_condition_field;
|
||||||
}
|
}
|
||||||
elseif (!empty($_SESSION['dialplan']['destination']['text'])) {
|
elseif (!empty($settings->get('dialplan', 'destination', ''))) {
|
||||||
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $_SESSION['dialplan']['destination']['text'];
|
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $settings->get('dialplan', 'destination', '');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "regex";
|
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "regex";
|
||||||
|
|
@ -693,8 +700,8 @@
|
||||||
if (!empty($destination_condition_field)) {
|
if (!empty($destination_condition_field)) {
|
||||||
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $destination_condition_field;
|
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $destination_condition_field;
|
||||||
}
|
}
|
||||||
elseif (!empty($_SESSION['dialplan']['destination']['text'])) {
|
elseif (!empty($settings->get('dialplan', 'destination', ''))) {
|
||||||
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $_SESSION['dialplan']['destination']['text'];
|
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $settings->get('dialplan', 'destination', '');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "destination_number";
|
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "destination_number";
|
||||||
|
|
@ -942,7 +949,7 @@
|
||||||
$dialplan["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid;
|
$dialplan["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid;
|
||||||
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
|
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
|
||||||
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set";
|
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set";
|
||||||
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "record_name=\${uuid}.\${record_ext}";
|
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "record_name=\${uuid}.".$record_extension;
|
||||||
$dialplan["dialplan_details"][$y]["dialplan_detail_inline"] = "true";
|
$dialplan["dialplan_details"][$y]["dialplan_detail_inline"] = "true";
|
||||||
$dialplan["dialplan_details"][$y]["dialplan_detail_group"] = $dialplan_detail_group;
|
$dialplan["dialplan_details"][$y]["dialplan_detail_group"] = $dialplan_detail_group;
|
||||||
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
|
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
|
||||||
|
|
@ -979,6 +986,20 @@
|
||||||
//increment the dialplan detail order
|
//increment the dialplan detail order
|
||||||
$dialplan_detail_order = $dialplan_detail_order + 10;
|
$dialplan_detail_order = $dialplan_detail_order + 10;
|
||||||
|
|
||||||
|
//add a variable
|
||||||
|
$dialplan["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
|
||||||
|
$dialplan["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid;
|
||||||
|
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
|
||||||
|
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set";
|
||||||
|
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "record_stereo_swap=true";
|
||||||
|
$dialplan["dialplan_details"][$y]["dialplan_detail_inline"] = "true";
|
||||||
|
$dialplan["dialplan_details"][$y]["dialplan_detail_group"] = $dialplan_detail_group;
|
||||||
|
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
|
||||||
|
$y++;
|
||||||
|
|
||||||
|
//increment the dialplan detail order
|
||||||
|
$dialplan_detail_order = $dialplan_detail_order + 10;
|
||||||
|
|
||||||
//add a variable
|
//add a variable
|
||||||
$dialplan["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
|
$dialplan["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
|
||||||
$dialplan["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid;
|
$dialplan["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid;
|
||||||
|
|
@ -1159,10 +1180,10 @@
|
||||||
|
|
||||||
//clear the cache
|
//clear the cache
|
||||||
$cache = new cache;
|
$cache = new cache;
|
||||||
if ($_SESSION['destinations']['dialplan_mode']['text'] == 'multiple') {
|
if ($settings->get('destinations', 'dialplan_mode', '') == 'multiple') {
|
||||||
$cache->delete("dialplan:".$destination_context);
|
$cache->delete("dialplan:".$destination_context);
|
||||||
}
|
}
|
||||||
if ($_SESSION['destinations']['dialplan_mode']['text'] == 'single') {
|
if ($settings->get('destinations', 'dialplan_mode', '') == 'single') {
|
||||||
if (isset($destination_prefix) && is_numeric($destination_prefix) && isset($destination_number) && is_numeric($destination_number)) {
|
if (isset($destination_prefix) && is_numeric($destination_prefix) && isset($destination_number) && is_numeric($destination_number)) {
|
||||||
$cache->delete("dialplan:".$destination_context.":".$destination_prefix.$destination_number);
|
$cache->delete("dialplan:".$destination_context.":".$destination_prefix.$destination_number);
|
||||||
$cache->delete("dialplan:".$destination_context.":+".$destination_prefix.$destination_number);
|
$cache->delete("dialplan:".$destination_context.":+".$destination_prefix.$destination_number);
|
||||||
|
|
@ -2046,7 +2067,7 @@
|
||||||
echo " ".$text['label-destination_enabled']."\n";
|
echo " ".$text['label-destination_enabled']."\n";
|
||||||
echo "</td>\n";
|
echo "</td>\n";
|
||||||
echo "<td class='vtable' align='left'>\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 " <label class='switch'>\n";
|
||||||
echo " <input type='checkbox' id='destination_enabled' name='destination_enabled' value='true' ".($destination_enabled == 'true' ? "checked='checked'" : null).">\n";
|
echo " <input type='checkbox' id='destination_enabled' name='destination_enabled' value='true' ".($destination_enabled == 'true' ? "checked='checked'" : null).">\n";
|
||||||
echo " <span class='slider'></span>\n";
|
echo " <span class='slider'></span>\n";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue