Portions created by the Initial Developer are Copyright (C) 2008-2020 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ //includes require_once "root.php"; require_once "resources/require.php"; require_once "resources/paging.php"; //download the message if ( $_REQUEST["action"] == "download" && is_numeric($_REQUEST["id"]) && is_uuid($_REQUEST["uuid"]) && is_uuid($_REQUEST["voicemail_uuid"]) ) { $voicemail = new voicemail; $voicemail->domain_uuid = $_SESSION['domain_uuid']; $voicemail->type = $_REQUEST['t']; $voicemail->voicemail_id = $_REQUEST['id']; $voicemail->voicemail_uuid = $_REQUEST['voicemail_uuid']; $voicemail->voicemail_message_uuid = $_REQUEST['uuid']; $result = $voicemail->message_download(); unset($voicemail); exit; } //include after download function require_once "resources/check_auth.php"; //check permissions if (permission_exists('voicemail_message_view')) { //access granted } else { echo "access denied"; exit; } //set the voicemail_uuid if (is_uuid($_REQUEST['id'])) { $voicemail_uuid = $_REQUEST['id']; } else if (is_numeric($_REQUEST['id'])) { $voicemail_id = $_REQUEST['id']; } //get the http post data if (is_array($_POST['voicemail_messages'])) { $action = $_POST['action']; $voicemail_messages = $_POST['voicemail_messages']; } //process the http post data by action if ($action != '' && is_array($voicemail_messages) && @sizeof($voicemail_messages) != 0) { //set the referrer $http_referer = parse_url($_SERVER["HTTP_REFERER"]); $referer_path = $http_referer['path']; $referer_query = $http_referer['query']; //validate the token $token = new token; if (!$token->validate($_SERVER['PHP_SELF'])) { message::add($text['message-invalid_token'],'negative'); if ($referer_path == PROJECT_PATH."/app/voicemails/voicemail_messages.php") { header('Location: voicemail_messages.php?'.$referer_query); } else { header('Location: voicemails.php'); } exit; } //handle action switch ($action) { case 'toggle': if (is_array($voicemail_messages) && @sizeof($voicemail_messages) != 0) { $messages_toggled = 0; foreach ($voicemail_messages as $voicemail_message) { if ($voicemail_message['checked'] == 'true' && is_uuid($voicemail_message['uuid']) && is_uuid($voicemail_message['voicemail_uuid'])) { //delete voicemail message $voicemail = new voicemail; $voicemail->db = $db; $voicemail->domain_uuid = $_SESSION['domain_uuid']; $voicemail->voicemail_uuid = $voicemail_message['voicemail_uuid']; $voicemail->voicemail_message_uuid = $voicemail_message['uuid']; $voicemail->message_toggle(); unset($voicemail); //increment counter $messages_toggled++; } } //set message if ($messages_toggled != 0) { message::add($text['message-toggle'].': '.$messages_toggled); } } break; case 'delete': if (permission_exists('voicemail_message_delete')) { if (is_array($voicemail_messages) && @sizeof($voicemail_messages) != 0) { $messages_deleted = 0; foreach ($voicemail_messages as $voicemail_message) { if ($voicemail_message['checked'] == 'true' && is_uuid($voicemail_message['uuid']) && is_uuid($voicemail_message['voicemail_uuid'])) { //delete voicemail message $voicemail = new voicemail; $voicemail->db = $db; $voicemail->domain_uuid = $_SESSION['domain_uuid']; $voicemail->voicemail_uuid = $voicemail_message['voicemail_uuid']; $voicemail->voicemail_message_uuid = $voicemail_message['uuid']; $voicemail->message_delete(); unset($voicemail); //increment counter $messages_deleted++; } } //set message if ($messages_deleted != 0) { message::add($text['message-delete'].': '.$messages_deleted); } } } break; } //redirect the user if ($referer_path == PROJECT_PATH."/app/voicemails/voicemail_messages.php") { header('Location: voicemail_messages.php?'.$referer_query); } else { header('Location: voicemails.php'); } exit; } //add multi-lingual support $language = new text; $text = $language->get(); //get the html values and set them as variables $order_by = $_GET["order_by"]; $order = $_GET["order"]; //get the voicemail $vm = new voicemail; $vm->domain_uuid = $_SESSION['domain_uuid']; if (is_uuid($voicemail_uuid)) { $vm->voicemail_uuid = $voicemail_uuid; } else if (is_numeric($voicemail_id)) { $vm->voicemail_id = $voicemail_id; } $vm->order_by = $order_by; $vm->order = $order; $voicemails = $vm->messages(); //count messages $new_messages = $num_rows = 0; if (is_array($voicemails) && @sizeof($voicemails) != 0) { foreach ($voicemails as $voicemail) { if (is_array($voicemail['messages'])) { $num_rows += sizeof($voicemail['messages']); foreach ($voicemail['messages'] as $message) { if ($message['message_status'] != 'saved') { $new_messages++; } } } } } //create token $object = new token; $token = $object->create($_SERVER['PHP_SELF']); //additional includes $document['title'] = $text['title-voicemail_messages']; require_once "resources/header.php"; //show the content echo "
\n"; echo "
".$text['title-voicemail_messages']." (".$num_rows.")
\n"; echo "
\n"; if ($num_rows) { echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$_SESSION['theme']['button_icon_toggle'],'name'=>'btn_toggle','collapse'=>'hide-xs','onclick'=>"modal_open('modal-toggle','btn_toggle');"]); } if (permission_exists('voicemail_message_delete') && $num_rows) { echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'name'=>'btn_delete','collapse'=>'hide-xs','onclick'=>"modal_open('modal-delete','btn_delete');"]); } echo "
\n"; echo "
\n"; echo "
\n"; if ($num_rows) { echo modal::create(['id'=>'modal-toggle','type'=>'toggle','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_toggle','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('toggle'); list_form_submit('form_list');"])]); } if (permission_exists('voicemail_message_delete') && $num_rows) { echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]); } echo $text['description-voicemail_message']."\n"; echo "

\n"; //loop through the voicemail messages if (is_array($voicemails) && @sizeof($voicemails) != 0) { echo "
\n"; echo "\n"; echo "\n"; echo "\n"; // dummy row to adjust the alternating background color $x = 0; $previous_voicemail_id = ''; foreach ($voicemails as $field) { if ($previous_voicemail_id != $field['voicemail_id']) { if ($previous_voicemail_id != '') { echo "\n"; } echo "\n"; echo " \n"; echo "\n"; echo "\n"; $col_count = 0; if (permission_exists('voicemail_message_delete')) { echo " \n"; $col_count++; } echo th_order_by('created_epoch', $text['label-received'], $order_by, $order, null, "class='pct-30'"); $col_count++; echo th_order_by('caller_id_name', $text['label-caller_id_name'], $order_by, $order, null, "class='pct-20'"); $col_count++; echo th_order_by('caller_id_number', $text['label-caller_id_number'], $order_by, $order, null, "class='hide-xs pct-15'"); $col_count++; echo "\n"; $col_count++; echo th_order_by('message_length', $text['label-message_length'], $order_by, $order, null, "class='hide-xs right pct-15'"); $col_count++; if ($_SESSION['voicemail']['storage_type']['text'] != 'base64') { echo "\n"; $col_count++; } echo "\n"; } if (is_array($field['messages']) && @sizeof($field['messages']) > 0) { foreach ($field['messages'] as $row) { //responsive date $array = explode(' ', $row['created_date']); if ($array[0].' '.$array[1].' '.$array[2] == date('j M Y')) { //today $created_date = escape($array[3].' '.$array[4]); //only show time } else { $created_date = escape($array[0].' '.$array[1].' '.$array[2])." ".escape($array[3].' '.$array[4]).""; } //playback progress bar echo "\n"; echo "\n"; // dummy row to maintain alternating background color $bold = ($row['message_status'] == '' && $_REQUEST["uuid"] != $row['voicemail_message_uuid']) ? 'font-weight: bold;' : null; $list_row_url = "javascript:recording_play('".escape($row['voicemail_message_uuid'])."');"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; if ($_SESSION['voicemail']['storage_type']['text'] != 'base64') { echo " \n"; } echo "\n"; if ($_SESSION['voicemail']['transcribe_enabled']['boolean'] == 'true' && $row['message_transcription'] != '') { echo "\n"; // dummy row to maintain same background color for transcription row echo "\n"; echo " \n"; echo "\n"; } $x++; } unset($row); } else { echo ""; } $previous_voicemail_id = $field['voicemail_id']; } echo "
\n"; echo " 0 ?: "style='visibility: hidden;'").">\n"; echo " ".$text['label-tools']."".$text['label-message_size']."
\n"; echo " \n"; echo " \n"; echo " \n"; echo " ".$created_date."".escape($row['caller_id_name'])." ".escape($row['caller_id_number'])." ".escape($row['message_length_label'])."".escape($row['file_size_label'])."
".$text['message-messages_not_found']."
\n"; echo "
\n"; echo "\n"; echo "
\n"; } else { echo "
".$text['message-messages_not_found']."

"; } echo "
"; //autoplay message if ($_REQUEST["action"] == "autoplay" && is_uuid($_REQUEST["uuid"])) { echo ""; } //unbold new message rows when clicked/played/downloaded echo "\n"; //include the footer require_once "resources/footer.php"; ?>