diff --git a/app/voicemails/app_languages.php b/app/voicemails/app_languages.php index c4a9d0daf1..d0a3fed32d 100644 --- a/app/voicemails/app_languages.php +++ b/app/voicemails/app_languages.php @@ -76,15 +76,21 @@ $text['label-view']['en-us'] = 'View'; $text['label-view']['pt-pt'] = ''; - $text['label-greetings']['en-us'] = 'Greetings'; - $text['label-greetings']['pt-pt'] = ''; - $text['label-true']['en-us'] = 'true'; $text['label-true']['pt-pt'] = ''; $text['label-false']['en-us'] = 'false'; $text['label-false']['pt-pt'] = 'falso'; + $text['label-greetings']['en-us'] = 'Greetings'; + $text['label-greetings']['pt-pt'] = ''; + + $text['button-greetings']['en-us'] = 'Greetings'; + $text['button-greetings']['pt-pt'] = ''; + + $text['button-settings']['en-us'] = 'Settings'; + $text['button-settings']['pt-pt'] = ''; + $text['button-add']['en-us'] = 'Add'; $text['button-add']['pt-pt'] = ''; @@ -125,9 +131,12 @@ $text['title-voicemail_message']['en-us'] = 'Voicemail Message'; $text['title-voicemail_message']['pt-pt'] = ''; - $text['description-voicemail_message']['en-us'] = 'Voicemail Messages.'; + $text['description-voicemail_message']['en-us'] = 'A list of recorded voice messages which shows when the message was created, caller ID information, length, file size and download or delete the message.'; $text['description-voicemail_message']['pt-pt'] = ''; + $text['label-mailbox']['en-us'] = 'Mailbox'; + $text['label-mailbox']['pt-pt'] = ''; + $text['label-voicemail_uuid']['en-us'] = 'Voicemail UUID'; $text['label-voicemail_uuid']['pt-pt'] = ''; diff --git a/app/voicemails/resources/classes/voicemail.php b/app/voicemails/resources/classes/voicemail.php new file mode 100644 index 0000000000..0c1a17ba22 --- /dev/null +++ b/app/voicemails/resources/classes/voicemail.php @@ -0,0 +1,215 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2013 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//define the voicemail class + class voicemail { + public $db; + public $domain_uuid; + public $domain_name; + public $voicemail_uuid; + public $voicemail_id; + public $voicemail_message_uuid; + public $order_by; + public $order; + + public function messages() { + + $sql = "select * from v_voicemail_messages as m, v_voicemails as v "; + $sql .= "where m.domain_uuid = '$this->domain_uuid' "; + $sql .= "and m.voicemail_uuid = v.voicemail_uuid "; + if (is_array($this->voicemail_id)) { + $sql .= "and ("; + $x = 0; + foreach($this->voicemail_id as $row) { + if ($x > 0) { + $sql .= "or "; + } + $sql .= "v.voicemail_id = '".$row['voicemail_id']."' "; + $x++; + } + $sql .= ") "; + } + else { + $sql .= "and v.voicemail_id = '$this->voicemail_id' "; + } + if (strlen($this->order_by) == 0) { + $sql .= "order by v.voicemail_id, m.created_epoch desc "; + } + else { + $sql .= "order by v.voicemail_id, m.$this->order_by $this->order "; + } + //$sql .= "limit $this->rows_per_page offset $this->offset "; + $prep_statement = $this->db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(); + $result_count = count($result); + unset ($prep_statement, $sql); + if ($result_count > 0) { + foreach($result as &$row) { + //set the greeting directory + $row['file_path'] = $_SESSION['switch']['storage']['dir'].'/voicemail/default/'.$_SESSION['domain_name'].'/'.$row['voicemail_id'].'/msg_'.$row['voicemail_message_uuid'].'.wav'; + $row['file_size'] = filesize($row['file_path']); + $row['file_size_label'] = byte_convert($row['file_size']); + $row['file_ext'] = substr($row['file_path'], -3); + + $message_length = $row['message_length']; + if ($message_length < 60 ) { + $message_length = $message_length. " sec"; + } + else { + $message_length = round(($message_length/60), 2). " min"; + } + $row['message_length_label'] = $message_length; + $row['created_date'] = date("j M Y g:i a",$row['created_epoch']); + } + } + return $result; + } + + public function message_count() { + $sql = "select count(*) as num_rows from v_voicemail_messages "; + $sql .= "where domain_uuid = '$this->domain_uuid' "; + $sql .= "and voicemail_uuid = '$this->voicemail_uuid' "; + $prep_statement = $this->db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } + } + return $num_rows; + } + + public function download() { + //get the voicemail_id + $sql = "select * from v_voicemails "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and voicemail_uuid = '$this->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); + + //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)) { + $fd = fopen($file_path, "rb"); + if ($_GET['t'] == "bin") { + header("Content-Type: application/force-download"); + header("Content-Type: application/octet-stream"); + header("Content-Type: application/download"); + header("Content-Description: File Transfer"); + $file_ext = substr($file_path, -3); + if ($file_ext == "wav") { + header('Content-Disposition: attachment; filename="voicemail.wav"'); + } + if ($file_ext == "mp3") { + header('Content-Disposition: attachment; filename="voicemail.mp3"'); + } + } + else { + $file_ext = substr($file_path, -3); + if ($file_ext == "wav") { + header("Content-Type: audio/x-wav"); + } + if ($file_ext == "mp3") { + header("Content-Type: audio/mp3"); + } + } + header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 + header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // date in the past + header("Content-Length: " . filesize($file_path)); + fpassthru($fd); + } + } // download + + } + +//example voicemail messages + //require_once "app/voicemails/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->order_by = $order_by; + //$voicemail->order = $order; + //$result = $voicemail->messages(); + //$result_count = count($result); + +/* +Array +( + [user] => 1002 + [extension_uuid] => e163fc03-f180-459b-aa12-7ed87fcb6e2c + [outbound_caller_id_name] => FusionPBX + [outbound_caller_id_number] => 12084024632 +) +Array +( + [user] => 1020 + [extension_uuid] => ecfb23df-7c59-4286-891e-2abdc48856ac + [outbound_caller_id_name] => Mark J Crane + [outbound_caller_id_number] => 12084024632 +) + +foreach ($_SESSION['user']['extension'] as $value) { + if (strlen($value['user']) > 0) { + + } +} +*/ + +?> \ No newline at end of file diff --git a/app/voicemails/voicemail_edit.php b/app/voicemails/voicemail_edit.php index c6b9eb91e0..639466ca98 100644 --- a/app/voicemails/voicemail_edit.php +++ b/app/voicemails/voicemail_edit.php @@ -49,7 +49,9 @@ else { $action = "add"; } -//get http post variables and set them to php variables +//get http variables and set them to php variables + $referer_path = check_str($_REQUEST["referer_path"]); + $referer_query = check_str($_REQUEST["referer_query"]); if (count($_POST)>0) { $voicemail_id = check_str($_POST["voicemail_id"]); $voicemail_password = check_str($_POST["voicemail_password"]); @@ -158,7 +160,12 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { unset($sql); require_once "includes/header.php"; - echo "\n"; + if ($referer_path == "/app/voicemails/voicemail_messages.php") { + echo "\n"; + } + else { + echo "\n"; + } echo "
\n"; echo " ".$text['message-update']."\n"; echo "
\n"; @@ -343,6 +350,9 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { if ($action == "update") { echo " \n"; } + $http_referer = parse_url($_SERVER["HTTP_REFERER"]); + echo " \n"; + echo " \n"; echo " \n"; echo " \n"; echo " "; diff --git a/app/voicemails/voicemail_messages.php b/app/voicemails/voicemail_messages.php index 9720dbe09f..d1b563c502 100644 --- a/app/voicemails/voicemail_messages.php +++ b/app/voicemails/voicemail_messages.php @@ -40,86 +40,31 @@ else { $text[$key] = $value[$_SESSION['domain']['language']['code']]; } -//get the uuid - $voicemail_uuid = check_str($_REQUEST["id"]); - -//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); - -//download the voicemail - if ($_GET['a'] == "download") { - - session_cache_limiter('public'); - $voicemail_message_uuid = check_str($_GET["uuid"]); - - $sql = "select * from v_voicemail_messages "; +//get the uuid and voicemail_id + if (strlen($_REQUEST["id"]) > 0) { + $voicemail_uuid = check_str($_REQUEST["id"]); + $sql = "select * from v_voicemails "; $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; - $sql .= "and voicemail_message_uuid = '$voicemail_message_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_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"]; + $voicemail_id = $row["voicemail_id"]; } unset ($prep_statement); + } - if ($_GET['type'] = "vm") { - $file_path = $_SESSION['switch']['storage']['dir']."/voicemail/default/".$_SESSION['domain_name']."/".$voicemail_id."/msg_".$voicemail_message_uuid.".wav"; - if (file_exists($file_path)) { - $fd = fopen($file_path, "rb"); - if ($_GET['t'] == "bin") { - header("Content-Type: application/force-download"); - header("Content-Type: application/octet-stream"); - header("Content-Type: application/download"); - header("Content-Description: File Transfer"); - $file_ext = substr($file_path, -3); - if ($file_ext == "wav") { - header('Content-Disposition: attachment; filename="voicemail.wav"'); - } - if ($file_ext == "mp3") { - header('Content-Disposition: attachment; filename="voicemail.mp3"'); - } - } - else { - $file_ext = substr($file_path, -3); - if ($file_ext == "wav") { - header("Content-Type: audio/x-wav"); - } - if ($file_ext == "mp3") { - header("Content-Type: audio/mp3"); - } - } - header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 - header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // date in the past - header("Content-Length: " . filesize($file_path)); - fpassthru($fd); - } - return; +//set the voicemail_id array + if (strlen($_REQUEST["id"]) == 0) { + foreach ($_SESSION['user']['extension'] as $value) { + $voicemail_id[]['voicemail_id'] = $value['user']; } } //get the html values and set them as variables $order_by = check_str($_GET["order_by"]); $order = check_str($_GET["order"]); - if (strlen($_GET["id"]) > 0) { - $voicemail_uuid = check_str($_GET["id"]); - } //additional includes require_once "includes/header.php"; @@ -139,104 +84,73 @@ else { echo " \n"; echo " \n"; echo " \n"; - echo " ".$text['description-voicemail_message']."

\n"; + echo " ".$text['description-voicemail_message']."
\n"; echo " \n"; echo " \n"; echo "\n"; - //prepare to page the results - $sql = "select count(*) as num_rows from v_voicemail_messages "; - $sql .= "where domain_uuid = '$domain_uuid' "; - $sql .= "and voicemail_uuid = '$voicemail_uuid' "; - if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } - $prep_statement = $db->prepare($sql); - if ($prep_statement) { - $prep_statement->execute(); - $row = $prep_statement->fetch(PDO::FETCH_ASSOC); - if ($row['num_rows'] > 0) { - $num_rows = $row['num_rows']; - } - else { - $num_rows = '0'; - } - } - - //prepare to page the results - $rows_per_page = 150; - $param = ""; - $page = $_GET['page']; - if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } - list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); - $offset = $rows_per_page * $page; - - //get the list - $sql = "select * from v_voicemail_messages "; - $sql .= "where domain_uuid = '$domain_uuid' "; - $sql .= "and voicemail_uuid = '$voicemail_uuid' "; - if (strlen($order_by) == 0) { - $sql .= "order by created_epoch desc "; - } - else { - $sql .= "order by $order_by $order "; - } - $sql .= "limit $rows_per_page offset $offset "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $result = $prep_statement->fetchAll(); - $result_count = count($result); - unset ($prep_statement, $sql); - $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; echo "
\n"; echo "\n"; - echo "\n"; - //echo th_order_by('voicemail_uuid', $text['label-voicemail_uuid'], $order_by, $order); - echo th_order_by('created_epoch', $text['label-created_epoch'], $order_by, $order); - //echo th_order_by('read_epoch', $text['label-read_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 th_order_by('message_length', $text['label-message_length'], $order_by, $order); - echo "\n"; - echo "\n"; - //echo th_order_by('message_priority', $text['label-message_priority'], $order_by, $order); - echo "\n"; - echo "\n"; + $table_header = "\n"; + $table_header .= th_order_by('created_epoch', $text['label-created_epoch'], $order_by, $order); + //$table_header .= th_order_by('read_epoch', $text['label-read_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 .= th_order_by('message_length', $text['label-message_length'], $order_by, $order); + $table_header .= "\n"; + $table_header .= "\n"; + //$table_header .= th_order_by('message_priority', $text['label-message_priority'], $order_by, $order); + $table_header .= "\n"; + $table_header .= "\n"; + + //get the voicemail messages + require_once "app/voicemails/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->order_by = $order_by; + $voicemail->order = $order; + $result = $voicemail->messages(); + $result_count = count($result); + + //loop throug the voicemail messages if ($result_count > 0) { + $previous_voicemail_id = ''; foreach($result as $row) { - - //set the greeting directory - $file_path = $_SESSION['switch']['storage']['dir'].'/voicemail/default/'.$_SESSION['domain_name'].'/'.$voicemail_id.'/msg_'.$row['voicemail_message_uuid'].'.wav'; - $file_size = filesize($file_path); - $file_size = byte_convert($file_size); - $file_ext = substr($row['file_path'], -3); - - $message_length = $row['message_length']; - if ($message_length < 60 ) { - $message_length = $message_length. " sec"; + if ($previous_voicemail_id != $row['voicemail_id']) { + echo "\n"; + echo "\n"; + echo "\n"; + echo $table_header; } - else { - $message_length = round(($message_length/60), 2). " min"; - } - if ($row['message_status'] == '') { $style = "style=\"font-weight:bold;\""; } else { $style = ''; } - //echo " \n"; echo "\n"; //echo " \n"; echo " \n"; echo " \n"; - echo " \n"; + echo " \n"; //echo " \n"; - echo " \n"; + echo " \n"; echo " \n"; echo "\n"; + + $previous_voicemail_id = $row['voicemail_id']; if ($c==0) { $c=1; } else { $c=0; } } //end foreach - unset($sql, $result, $row_count); + unset($sql, $result, $result_count); } //end if results echo "\n"; @@ -261,7 +177,7 @@ else { echo "
".$text['label-message_size']."".$text['label-tools']."\n"; - echo "  \n"; - echo "
".$text['label-message_size']."".$text['label-tools']."\n"; + $table_header .= "  \n"; + $table_header .= "
\n"; + echo "

\n"; + echo " ".$text['label-mailbox'].": ".$row['voicemail_id']." \n"; + echo " \n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo "
".$row['voicemail_uuid']." "; - echo " ".date("j M Y g:i a",$row['created_epoch']); + echo " ".$row['created_date']; echo "".$row['read_epoch']." ".$row['caller_id_name']." ".$row['caller_id_number']." ".$message_length." ".$row['message_length_label']." ".$row['message_status']." ".$file_size."".$row['file_size_label']."\n"; - //echo " \n"; + //echo " \n"; //echo " ".$text['label-play']."\n"; //echo " \n"; echo "   \n"; @@ -251,9 +165,11 @@ else { } echo "
\n"; echo " \n"; echo " \n"; - echo " \n"; + echo " \n"; echo " \n"; diff --git a/app/voicemails/voicemails.php b/app/voicemails/voicemails.php index ced670489e..37626f416d 100644 --- a/app/voicemails/voicemails.php +++ b/app/voicemails/voicemails.php @@ -145,7 +145,7 @@ else { //echo " \n"; echo " \n"; echo " \n"; echo " \n";
 $paging_controls \n"; echo "  \n"; echo "  \n"; echo " ".$text['label-view']."  \n"; - echo " ".$text['label-greetings']."\n"; + echo " ".$text['label-greetings']."\n"; echo " ".$row['voicemail_enabled']." ".$row['voicemail_description']."