From 51275443c5017d38629a12a089c5b328a3a8ffb2 Mon Sep 17 00:00:00 2001 From: reliberate Date: Sat, 19 Mar 2016 13:54:24 -0600 Subject: [PATCH] Voicemail: Add bulk delete ability for Messages, instant saved indication when playing/downloading, and table row click to play. Dashboard: Minor code cleanup. --- .../resources/classes/voicemail.php | 13 +-- app/voicemails/voicemail_message_delete.php | 49 ++++---- app/voicemails/voicemail_messages.php | 105 +++++++++++++----- app/voicemails/voicemails.php | 2 +- core/user_settings/user_dashboard.php | 3 +- 5 files changed, 111 insertions(+), 61 deletions(-) diff --git a/app/voicemails/resources/classes/voicemail.php b/app/voicemails/resources/classes/voicemail.php index cd1cf99388..cf58435c80 100644 --- a/app/voicemails/resources/classes/voicemail.php +++ b/app/voicemails/resources/classes/voicemail.php @@ -307,21 +307,16 @@ $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); + $prep_statement = $this->db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql, $prep_statement); + //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 app.lua voicemail mwi ".$this->voicemail_id."@".$_SESSION['domain_name']; - $switch_result = event_socket_request($fp, 'api '.$switch_cmd); - } - //change the message status $this->message_saved(); diff --git a/app/voicemails/voicemail_message_delete.php b/app/voicemails/voicemail_message_delete.php index 31e063704d..04d5fa8e1f 100644 --- a/app/voicemails/voicemail_message_delete.php +++ b/app/voicemails/voicemail_message_delete.php @@ -34,14 +34,36 @@ else { exit; } +/* +echo "
".print_r($_REQUEST, true)."
"; +exit; +*/ + //add multi-lingual support $language = new text; $text = $language->get(); -//get the HTTP values and set them as variables - if (count($_GET)>0) { - $id = check_str($_GET["id"]); - $voicemail_uuid = check_str($_GET["voicemail_uuid"]); +//get submitted variables + if (count($_REQUEST)>0) { + $voicemail_messages = $_REQUEST["voicemail_messages"]; + } + +//delete the voicemail message + $deleted = 0; + if (is_array($voicemail_messages) && sizeof($voicemail_messages) > 0) { + require_once "resources/classes/voicemail.php"; + foreach ($voicemail_messages as $voicemail_uuid => $voicemail_message_uuids) { + foreach ($voicemail_message_uuids as $voicemail_message_uuid) { + $voicemail = new voicemail; + $voicemail->db = $db; + $voicemail->domain_uuid = $_SESSION['domain_uuid']; + $voicemail->voicemail_uuid = check_str($voicemail_uuid); + $voicemail->voicemail_message_uuid = check_str($voicemail_message_uuid); + $result = $voicemail->message_delete(); + unset($voicemail); + $deleted++; + } + } } //set the referrer @@ -49,26 +71,15 @@ else { $referer_path = $http_referer['path']; $referer_query = $http_referer['query']; -//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_message_uuid = $id; - $result = $voicemail->message_delete(); - unset($voicemail); - } - //redirect the user - $_SESSION["message"] = $text['message-delete']; - if ($referer_path == "/app/voicemails/voicemail_messages.php") { + if ($deleted > 0) { + $_SESSION["message"] = $text['message-delete'].': '.$deleted; + } + if ($referer_path == PROJECT_PATH."/app/voicemails/voicemail_messages.php") { header("Location: voicemail_messages.php?".$referer_query); } else { header("Location: voicemails.php"); } - return; ?> \ No newline at end of file diff --git a/app/voicemails/voicemail_messages.php b/app/voicemails/voicemail_messages.php index 0d27347945..d07d86d41c 100644 --- a/app/voicemails/voicemail_messages.php +++ b/app/voicemails/voicemail_messages.php @@ -62,7 +62,6 @@ if (!(check_str($_REQUEST["action"]) == "download" && check_str($_REQUEST["src"] $voicemail->voicemail_message_uuid = $voicemail_message_uuid; $result = $voicemail->message_download(); unset($voicemail); - header("Location: voicemail_edit.php?id=".$voicemail_uuid); } exit; } @@ -99,21 +98,10 @@ if (!(check_str($_REQUEST["action"]) == "download" && check_str($_REQUEST["src"] //loop through the voicemail messages if (count($voicemails) > 0) { - echo "
"; - echo "\n"; + echo "\n"; - //set the table header - $table_header = "\n"; - $table_header .= th_order_by('created_epoch', $text['label-created_epoch'], $order_by, $order); - $table_header .= th_order_by('caller_id_name', $text['label-caller_id_name'], $order_by, $order); - $table_header .= th_order_by('caller_id_number', $text['label-caller_id_number'], $order_by, $order); - $table_header .= "\n"; - $table_header .= th_order_by('message_length', $text['label-message_length'], $order_by, $order, null, "style='text-align: right;'"); - if ($_SESSION['voicemail']['storage_type']['text'] != 'base64') { - $table_header .= "\n"; - } - $table_header .= ""; - $table_header .= "\n"; + echo "
"; + echo "
".$text['label-tools']."".$text['label-message_size']." 
\n"; $previous_voicemail_id = ''; foreach($voicemails as $field) { @@ -121,38 +109,62 @@ if (!(check_str($_REQUEST["action"]) == "download" && check_str($_REQUEST["src"] if ($previous_voicemail_id != '') { echo "\n"; } - echo "\n"; - echo " \n"; echo " \n"; echo " \n"; echo "\n"; + if (count($field['messages']) > 0) { - echo $table_header; + echo "\n"; + if (permission_exists('voicemail_message_delete')) { + echo ""; + } + echo th_order_by('created_epoch', $text['label-created_epoch'], $order_by, $order); + echo th_order_by('caller_id_name', $text['label-caller_id_name'], $order_by, $order); + echo th_order_by('caller_id_number', $text['label-caller_id_number'], $order_by, $order); + echo "\n"; + echo th_order_by('message_length', $text['label-message_length'], $order_by, $order, null, "style='text-align: right;'"); + if ($_SESSION['voicemail']['storage_type']['text'] != 'base64') { + echo "\n"; + } + if (permission_exists('voicemail_message_delete')) { + echo ""; + } + echo "\n"; } } if (count($field['messages']) > 0) { foreach($field['messages'] as &$row) { - $style = ($row['message_status'] == '') ? "font-weight: bold;" : null; + $style = ($row['message_status'] == '' && $_REQUEST["uuid"] != $row['voicemail_message_uuid']) ? "font-weight: bold;" : null; //playback progress bar - echo "\n"; + echo "\n"; - echo "\n"; + $tr_link = "href=\"javascript:recording_play('".$row['voicemail_message_uuid']."');\""; + echo "\n"; + if (permission_exists('voicemail_message_delete')) { + echo " "; + $vm_msg_ids[$row['voicemail_id']][] = 'checkbox_'.$row['voicemail_message_uuid']; + } echo " \n"; echo " \n"; echo " \n"; - echo " \n"; echo " \n"; if ($_SESSION['voicemail']['storage_type']['text'] != 'base64') { echo " \n"; } - echo " \n"; } - echo " \n"; echo "\n"; $c = ($c) ? 0 : 1; } @@ -188,6 +200,9 @@ if (!(check_str($_REQUEST["action"]) == "download" && check_str($_REQUEST["src"] } echo "



\n"; + echo " \n"; echo " ".$text['label-mailbox'].": ".$field['voicemail_id']."
 \n"; echo "
\n"; if (permission_exists('voicemail_greeting_view')) { - echo " \n"; + echo " \n"; } if (permission_exists('voicemail_edit')) { - echo " \n"; + echo " \n"; } echo "

"; echo "
 
".$text['label-tools']."".$text['label-message_size'].""; + echo "".$v_link_label_delete.""; + echo "
".$row['created_date']."".$row['caller_id_name']." ".$row['caller_id_number']." ".$row['message_length_label']." ".$row['file_size_label'].""; if (permission_exists('voicemail_message_delete')) { - echo "$v_link_label_delete"; + echo " "; + echo "".$v_link_label_delete.""; + echo "
"; echo "

"; + + echo ""; + } else { echo "
".$text['message-messages_not_found']."

"; @@ -199,6 +214,36 @@ if (!(check_str($_REQUEST["action"]) == "download" && check_str($_REQUEST["src"] echo ""; } +//check or uncheck all voicemail checkboxes + if (sizeof($vm_msg_ids) > 0) { + echo "\n"; + } + +//$(this).children('td:not(.tr_link_void)').css('font-weight','normal'); +?> + + + + \ No newline at end of file diff --git a/app/voicemails/voicemails.php b/app/voicemails/voicemails.php index 1f5996f0ba..349a391743 100644 --- a/app/voicemails/voicemails.php +++ b/app/voicemails/voicemails.php @@ -160,7 +160,7 @@ else { if (permission_exists('voicemail_add') || permission_exists('voicemail_edit')) { echo "".$v_link_label_add.""; } - if (permission_exists('voicemail_delete') && $num_rows > 0) { + if (permission_exists('voicemail_delete')) { echo "".$v_link_label_delete.""; } echo "\n"; diff --git a/core/user_settings/user_dashboard.php b/core/user_settings/user_dashboard.php index d5a8d86a68..ac35674d6f 100644 --- a/core/user_settings/user_dashboard.php +++ b/core/user_settings/user_dashboard.php @@ -273,7 +273,6 @@ $vm = new voicemail; $vm->db = $db; $vm->domain_uuid = $_SESSION['domain_uuid']; - $vm->voicemail_uuid = $voicemail_uuid; $vm->order_by = $order_by; $vm->order = $order; $voicemails = $vm->messages(); @@ -296,7 +295,7 @@ } } - $hud[$n]['html'] .= " ".$messages['total']."".$messages['new']."\n"; + $hud[$n]['html'] .= " ".$messages['total']."".$messages['new']."\n"; $hud[$n]['html'] .= "

"; if (sizeof($voicemails) > 0) {