Fix the voicemail download from the gui. Add message delete to the voicemail PHP class.
This commit is contained in:
parent
abb71e45e8
commit
cad5927150
|
|
@ -107,41 +107,77 @@
|
|||
return $num_rows;
|
||||
}
|
||||
|
||||
public function download() {
|
||||
//get the voicemail_id
|
||||
$sql = "select * from v_voicemails ";
|
||||
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
||||
public function message_waiting() {
|
||||
//send the message waiting status
|
||||
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
||||
if ($fp) {
|
||||
$switch_cmd .= "luarun voicemail.lua mwi ".$this->voicemail_id."@".$_SESSION['domain_name'];
|
||||
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
|
||||
}
|
||||
}
|
||||
|
||||
public function message_delete() {
|
||||
|
||||
//delete voicemail_message
|
||||
$sql = "delete from v_voicemail_messages ";
|
||||
$sql .= "where domain_uuid = '$this->domain_uuid' ";
|
||||
$sql .= "and voicemail_uuid = '$this->voicemail_uuid' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$sql .= "and voicemail_message_uuid = '$this->voicemail_message_uuid' ";
|
||||
$prep_statement = $this->db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as &$row) {
|
||||
$voicemail_id = $row["voicemail_id"];
|
||||
unset($sql);
|
||||
|
||||
//get the voicemail_id
|
||||
if (!isset($this->voicemail_id)) {
|
||||
$sql = "select * from v_voicemails ";
|
||||
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
||||
$sql .= "and voicemail_uuid = '$this->voicemail_uuid' ";
|
||||
$prep_statement = $this->db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as &$row) {
|
||||
$this->voicemail_id = $row["voicemail_id"];
|
||||
}
|
||||
unset ($prep_statement);
|
||||
}
|
||||
unset ($prep_statement);
|
||||
|
||||
//delete the recording
|
||||
$file_path = $_SESSION['switch']['storage']['dir']."/voicemail/default/".$_SESSION['domain_name']."/".$this->voicemail_id."/msg_".$this->voicemail_message_uuid.".wav";
|
||||
unlink($file_path);
|
||||
|
||||
//check the message waiting status
|
||||
$this->message_waiting();
|
||||
|
||||
}
|
||||
|
||||
public function message_saved() {
|
||||
//set the voicemail status to saved
|
||||
$sql = "update v_voicemail_messages set ";
|
||||
$sql .= "message_status = 'saved' ";
|
||||
$sql .= "where domain_uuid = '$this->domain_uuid' ";
|
||||
$sql .= "and voicemail_uuid = '$this->voicemail_uuid' ";
|
||||
$sql .= "and voicemail_message_uuid = '$this->voicemail_message_uuid'";
|
||||
$this->db->exec($sql);
|
||||
unset($sql);
|
||||
//check the message waiting status
|
||||
$this->message_waiting();
|
||||
}
|
||||
|
||||
public function message_download() {
|
||||
|
||||
//check the message waiting status
|
||||
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
||||
if ($fp) {
|
||||
$switch_cmd .= "luarun voicemail.lua mwi ".$this->voicemail_id."@".$_SESSION['domain_name'];
|
||||
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
|
||||
}
|
||||
|
||||
//change the message status
|
||||
$this->message_saved();
|
||||
|
||||
//clear the cache
|
||||
session_cache_limiter('public');
|
||||
|
||||
//get the voicemail message meta data
|
||||
$sql = "select * from v_voicemail_messages ";
|
||||
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
||||
$sql .= "and voicemail_message_uuid = '$this->voicemail_message_uuid' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as &$row) {
|
||||
$voicemail_uuid = $row["voicemail_uuid"];
|
||||
$created_epoch = $row["created_epoch"];
|
||||
$read_epoch = $row["read_epoch"];
|
||||
$caller_id_name = $row["caller_id_name"];
|
||||
$caller_id_number = $row["caller_id_number"];
|
||||
$message_length = $row["message_length"];
|
||||
$message_status = $row["message_status"];
|
||||
$message_priority = $row["message_priority"];
|
||||
}
|
||||
unset ($prep_statement);
|
||||
|
||||
//prepare and stream the file
|
||||
$file_path = $_SESSION['switch']['storage']['dir']."/voicemail/default/".$_SESSION['domain_name']."/".$this->voicemail_id."/msg_".$this->voicemail_message_uuid.".wav";
|
||||
if (file_exists($file_path)) {
|
||||
|
|
@ -174,7 +210,6 @@
|
|||
fpassthru($fd);
|
||||
}
|
||||
} // download
|
||||
|
||||
}
|
||||
|
||||
//example voicemail messages
|
||||
|
|
|
|||
|
|
@ -271,7 +271,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
|||
echo "</td>\n";
|
||||
echo "<td class='vtable' align='left'>\n";
|
||||
echo " <select class='formfld' name='voicemail_attach_file'>\n";
|
||||
//echo " <option value=''></option>\n";
|
||||
echo " <option value=''></option>\n";
|
||||
if ($voicemail_attach_file == "true") {
|
||||
echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
|
||||
}
|
||||
|
|
@ -296,7 +296,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
|||
echo "</td>\n";
|
||||
echo "<td class='vtable' align='left'>\n";
|
||||
echo " <select class='formfld' name='voicemail_local_after_email'>\n";
|
||||
//echo " <option value=''></option>\n";
|
||||
echo " <option value=''></option>\n";
|
||||
if ($voicemail_local_after_email == "true") {
|
||||
echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
|
||||
}
|
||||
|
|
@ -321,7 +321,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
|||
echo "</td>\n";
|
||||
echo "<td class='vtable' align='left'>\n";
|
||||
echo " <select class='formfld' name='voicemail_enabled'>\n";
|
||||
//echo " <option value=''></option>\n";
|
||||
echo " <option value=''></option>\n";
|
||||
if ($voicemail_enabled == "true") {
|
||||
echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,31 +46,18 @@ else {
|
|||
$voicemail_uuid = check_str($_GET["voicemail_uuid"]);
|
||||
}
|
||||
|
||||
if (strlen($id)>0) {
|
||||
//delete voicemail_message
|
||||
$sql = "delete from v_voicemail_messages ";
|
||||
$sql .= "where domain_uuid = '$domain_uuid' ";
|
||||
$sql .= "and voicemail_message_uuid = '$id' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
unset($sql);
|
||||
|
||||
//get the voicemail_id
|
||||
$sql = "select * from v_voicemails ";
|
||||
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
||||
$sql .= "and voicemail_uuid = '$voicemail_uuid' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as &$row) {
|
||||
$voicemail_id = $row["voicemail_id"];
|
||||
}
|
||||
unset ($prep_statement);
|
||||
|
||||
//delete the recording
|
||||
$file_path = $_SESSION['switch']['storage']['dir']."/voicemail/default/".$_SESSION['domain_name']."/".$voicemail_id."/msg_".$id.".wav";
|
||||
unlink($file_path);
|
||||
}
|
||||
//delete the voicemail message
|
||||
if (strlen($id)>0) {
|
||||
require_once "resources/classes/voicemail.php";
|
||||
$voicemail = new voicemail;
|
||||
$voicemail->db = $db;
|
||||
$voicemail->domain_uuid = $_SESSION['domain_uuid'];
|
||||
$voicemail->voicemail_uuid = $voicemail_uuid;
|
||||
$voicemail->voicemail_id = $voicemail_id;
|
||||
$voicemail->voicemail_message_uuid = $id;
|
||||
$result = $voicemail->message_delete();
|
||||
unset($voicemail);
|
||||
}
|
||||
|
||||
//redirect the user
|
||||
require_once "includes/header.php";
|
||||
|
|
|
|||
|
|
@ -63,6 +63,21 @@ else {
|
|||
}
|
||||
}
|
||||
|
||||
//download the message
|
||||
if (check_str($_REQUEST["action"]) == "download") {
|
||||
$voicemail_message_uuid = check_str($_REQUEST["uuid"]);
|
||||
require_once "resources/classes/voicemail.php";
|
||||
$voicemail = new voicemail;
|
||||
$voicemail->db = $db;
|
||||
$voicemail->domain_uuid = $_SESSION['domain_uuid'];
|
||||
$voicemail->voicemail_uuid = $voicemail_uuid;
|
||||
$voicemail->voicemail_id = $voicemail_id;
|
||||
$voicemail->voicemail_message_uuid = $voicemail_message_uuid;
|
||||
$result = $voicemail->message_download();
|
||||
unset($voicemail);
|
||||
exit;
|
||||
}
|
||||
|
||||
//get the html values and set them as variables
|
||||
$order_by = check_str($_GET["order_by"]);
|
||||
$order = check_str($_GET["order"]);
|
||||
|
|
@ -164,11 +179,11 @@ else {
|
|||
//echo " <td valign='top' class='".$row_style[$c]."' $style>".$row['message_status']." </td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."' $style>".$row['file_size_label']."</td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."' $style>\n";
|
||||
//echo " <a href=\"javascript:void(0);\" onclick=\"window.open('voicemail_msgs_play.php?a=download&type=vm&uuid=".$row['voicemail_message_uuid']."&id=".$row['voicemail_id']."&ext=".$row['file_ext']."&desc=".urlencode($row['cid_name']." ".$row['cid_number'])."', 'play',' width=420,height=40,menubar=no,status=no,toolbar=no')\">\n";
|
||||
//echo " <a href=\"javascript:void(0);\" onclick=\"window.open('voicemail_msgs_play.php?action=download&type=vm&uuid=".$row['voicemail_message_uuid']."&id=".$row['voicemail_id']."&ext=".$row['file_ext']."&desc=".urlencode($row['cid_name']." ".$row['cid_number'])."', 'play',' width=420,height=40,menubar=no,status=no,toolbar=no')\">\n";
|
||||
//echo " ".$text['label-play']."\n";
|
||||
//echo " </a>\n";
|
||||
echo " \n";
|
||||
echo " <a href=\"voicemail_messages.php?a=download&type=vm&t=bin&id=".$row['voicemail_uuid']."&uuid=".$row['voicemail_message_uuid']."\">\n";
|
||||
echo " <a href=\"voicemail_messages.php?action=download&type=vm&t=bin&id=".$row['voicemail_uuid']."&uuid=".$row['voicemail_message_uuid']."\">\n";
|
||||
echo " ".$text['label-download']."\n";
|
||||
echo " </a>\n";
|
||||
echo " </td>\n";
|
||||
|
|
|
|||
Loading…
Reference in New Issue