CDR: List view updates.

This commit is contained in:
Nate
2019-10-22 01:43:55 -06:00
parent 18a23e4c24
commit 0ebddaf2fa
4 changed files with 257 additions and 140 deletions

View File

@@ -50,6 +50,16 @@ if (!class_exists('xml_cdr')) {
public $include_internal;
public $extensions;
/**
* delete method
*/
private $app_name;
private $app_uuid;
private $permission_prefix;
private $list_page;
private $table;
private $uuid_prefix;
/**
* Called when the object is created
*/
@@ -61,6 +71,14 @@ if (!class_exists('xml_cdr')) {
$database->connect();
$this->db = $database->db;
}
//assign private variables (for delete method)
$this->app_name = 'xml_cdr';
$this->app_uuid = '4a085c51-7635-ff03-f67b-86e834422848';
$this->permission_prefix = 'xml_cdr_';
$this->list_page = 'xml_cdr.php';
$this->table = 'xml_cdr';
$this->uuid_prefix = 'xml_cdr_';
}
/**
@@ -1104,6 +1122,82 @@ if (!class_exists('xml_cdr')) {
}
} //end download method
/**
* delete records
*/
public function delete($records) {
if (permission_exists($this->permission_prefix.'delete')) {
//add multi-lingual support
$language = new text;
$text = $language->get();
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->list_page);
exit;
}
//delete multiple records
if (is_array($records) && @sizeof($records) != 0) {
$records_deleted = 0;
//loop through records
foreach($records as $x => $record) {
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
//get the call recordings
$sql = "select * from v_call_recordings ";
$sql .= "where call_recording_uuid = :xml_cdr_uuid ";
$parameters['xml_cdr_uuid'] = $record['uuid'];
$database = new database;
$row = $database->select($sql, $parameters, 'row');
unset($sql, $parameters);
//delete the call recording (file)
$call_recording_path = realpath($row['call_recording_path']);
$call_recording_name = $row['call_recording_name'];
if (file_exists($call_recording_path.'/'.$call_recording_name)) {
@unlink($call_recording_path.'/'.$call_recording_name);
}
//build the delete array
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
$array['call_recordings'][$x]['call_recording_uuid'] = $record['uuid'];
//increment counter
$records_deleted++;
}
}
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p->add('call_recording_delete', 'temp');
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
unset($array);
//revoke temporary permissions
$p->delete('call_recording_delete', 'temp');
//set message
message::add($text['message-delete'].": ".$records_deleted);
}
unset($records);
}
}
}
} //end the class
}
/*