Fix a situation where call recording was not showing up in Call Detail Records.

Make sure the record_path is set to the default path if that value doesn't exist in the xml.
This commit is contained in:
FusionPBX 2020-12-10 20:03:53 -07:00 committed by GitHub
parent 2eb83e45b8
commit 53cbf8c9b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 36 additions and 36 deletions

View File

@ -187,48 +187,36 @@ if (!class_exists('xml_cdr')) {
$this->fields(); $this->fields();
$field_count = sizeof($this->fields); $field_count = sizeof($this->fields);
//$field_count = sizeof($this->fields); //$field_count = sizeof($this->fields);
$i = 0;
if (isset($this->array)) { if (isset($this->array)) {
foreach ($this->array as $row) { foreach ($this->array as $row) {
$sql = "insert into v_xml_cdr ("; //build the array
$f = 1;
if (isset($this->fields)) {
foreach ($this->fields as $field) {
$field = preg_replace('#[^a-zA-Z0-9_\-]#', '', $field);
if ($field_count == $f) {
$sql .= "$field ";
}
else {
$sql .= "$field, ";
}
$f++;
}
}
$sql .= ")\n";
$sql .= "values \n";
$sql .= "(";
$f = 1;
if (isset($this->fields)) { if (isset($this->fields)) {
foreach ($this->fields as $field) { foreach ($this->fields as $field) {
$field = preg_replace('#[^a-zA-Z0-9_\-]#', '', $field); $field = preg_replace('#[^a-zA-Z0-9_\-]#', '', $field);
if (isset($row[$field]) && strlen($row[$field]) > 0) { if (isset($row[$field]) && strlen($row[$field]) > 0) {
$sql .= ":".$field." \n"; $array['xml_cdr'][0][$field] = $row[$field];
$parameters[$field] = $row[$field];
} }
else {
$sql .= "null\n";
}
if ($field_count != $f) {
$sql .= ",";
}
$f++;
} }
} }
$sql .= ")";
//add the temporary permission
$p = new permissions;
$p->add("xml_cdr_add", "temp");
$p->add("xml_cdr_edit", "temp");
//save the call details record to the database
$database = new database; $database = new database;
$database->execute($sql, $parameters); $database->app_name = 'xml_cdr';
unset($sql, $parameters); $database->app_uuid = '4a085c51-7635-ff03-f67b-86e834422848';
$i++; $database->domain_uuid = $domain_uuid;
$database->save($array, false);
//$message = $database->message;
//print_r($message);
//remove the temporary permission
$p->delete("xml_cdr_add", "temp");
$p->delete("xml_cdr_edit", "temp");
unset($array);
} }
} }
@ -509,7 +497,12 @@ if (!class_exists('xml_cdr')) {
$record_length = urldecode($xml->variables->record_seconds); $record_length = urldecode($xml->variables->record_seconds);
} }
elseif (strlen($xml->variables->record_name) > 0) { elseif (strlen($xml->variables->record_name) > 0) {
$record_path = urldecode($xml->variables->record_path); if (isset($xml->variables->record_path)) {
$record_path = urldecode($xml->variables->record_path);
}
else {
$record_path = $_SESSION['switch']['recordings']['dir'].'/'.$domain_name.'/archive/'.$start_year.'/'.$start_month.'/'.$start_day;
}
$record_name = urldecode($xml->variables->record_name); $record_name = urldecode($xml->variables->record_name);
$record_length = urldecode($xml->variables->duration); $record_length = urldecode($xml->variables->duration);
} }
@ -576,7 +569,7 @@ if (!class_exists('xml_cdr')) {
} }
} }
// Last check //last check
if (!isset($record_name) || is_null ($record_name) || (strlen($record_name) == 0)) { if (!isset($record_name) || is_null ($record_name) || (strlen($record_name) == 0)) {
$bridge_uuid = urldecode($xml->variables->bridge_uuid); $bridge_uuid = urldecode($xml->variables->bridge_uuid);
$path = $_SESSION['switch']['recordings']['dir'].'/'.$domain_name.'/archive/'.$start_year.'/'.$start_month.'/'.$start_day; $path = $_SESSION['switch']['recordings']['dir'].'/'.$domain_name.'/archive/'.$start_year.'/'.$start_month.'/'.$start_day;
@ -599,6 +592,13 @@ if (!class_exists('xml_cdr')) {
} }
} }
//debug information
//echo "line: ".__line__;
//echo "record_path: ".$record_path."\n";
//echo "record_name: ".$record_name."\n";
//echo "record_length: ".$record_length."\n";
//exit;
//add the call recording //add the call recording
if (isset($record_path) && isset($record_name) && file_exists($record_path.'/'.$record_name) && $record_length > 0) { if (isset($record_path) && isset($record_name) && file_exists($record_path.'/'.$record_name) && $record_length > 0) {
//add to the xml cdr table //add to the xml cdr table
@ -627,8 +627,8 @@ if (!class_exists('xml_cdr')) {
$database->app_name = 'call_recordings'; $database->app_name = 'call_recordings';
$database->app_uuid = '56165644-598d-4ed8-be01-d960bcb8ffed'; $database->app_uuid = '56165644-598d-4ed8-be01-d960bcb8ffed';
$database->domain_uuid = $domain_uuid; $database->domain_uuid = $domain_uuid;
$database->save($array); $database->save($array, false);
$message = $database->message; //$message = $database->message;
//remove the temporary permission //remove the temporary permission
$p->delete("call_recording_add", "temp"); $p->delete("call_recording_add", "temp");