diff --git a/app/voicemail_greetings/voicemail_greetings.php b/app/voicemail_greetings/voicemail_greetings.php index 0a1475c19d..0f41614fed 100644 --- a/app/voicemail_greetings/voicemail_greetings.php +++ b/app/voicemail_greetings/voicemail_greetings.php @@ -230,12 +230,15 @@ else { echo "
\n"; echo "\n"; echo " \n"; - echo " "; if (permission_exists('voicemail_greeting_upload')) { - echo " "; - echo " "; - echo " \n"; - echo " \n"; echo "
\n"; - echo " ".$text['title']."
\n"; + echo "
\n"; + echo " ".$text['title']."\n"; + echo "

\n"; + echo " ".$text['description']." ".$voicemail_id."\n"; echo "
\n"; + echo " \n"; + echo "
\n"; echo "      \n"; echo " \n"; echo " \n"; @@ -244,13 +247,7 @@ else { } echo "
\n"; - echo " ".$text['description']." $voicemail_id.
\n"; - echo "
\n"; - echo "
\n"; //get the number of rows in v_voicemail_greetings diff --git a/app/voicemails/app_languages.php b/app/voicemails/app_languages.php index a493f592e9..d8d59b4d6d 100644 --- a/app/voicemails/app_languages.php +++ b/app/voicemails/app_languages.php @@ -286,6 +286,11 @@ $text['message-required']['pt-pt'] = "Por favor indique"; $text['message-required']['fr-fr'] = "Merci d'indiquer: "; + $text['message-mailbox_not_found']['en-us'] = "No mailbox found."; + $text['message-mailbox_not_found']['es-cl'] = "No se encontró buzón de correo."; + $text['message-mailbox_not_found']['pt-pt'] = "Sem caixa de correio encontrado."; + $text['message-mailbox_not_found']['fr-fr'] = "Aucune boîte aux lettres trouvé."; + //Voicemail Messages $text['title-voicemail_messages']['en-us'] = "Voicemail Messages"; $text['title-voicemail_messages']['es-cl'] = "Mensajes de correo de voz"; @@ -387,4 +392,9 @@ $text['description-message_priority']['pt-pt'] = "Prioridade"; $text['description-message_priority']['fr-fr'] = "Priorité"; + $text['message-messages_not_found']['en-us'] = "No messages found."; + $text['message-messages_not_found']['es-cl'] = "No hay mensajes encontrados."; + $text['message-messages_not_found']['pt-pt'] = "Nenhuma mensagem encontrada."; + $text['message-messages_not_found']['fr-fr'] = "Aucun message trouvé."; + ?> diff --git a/app/voicemails/resources/classes/voicemail.php b/app/voicemails/resources/classes/voicemail.php index 01cfd9dbd9..bc1989ec31 100644 --- a/app/voicemails/resources/classes/voicemail.php +++ b/app/voicemails/resources/classes/voicemail.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2014 + Portions created by the Initial Developer are Copyright (C) 2008-2015 the Initial Developer. All Rights Reserved. Contributor(s): @@ -41,13 +41,18 @@ $voicemail_uuid = check_str($_REQUEST["id"]); } - //set the voicemail_id array - foreach ($_SESSION['user']['extension'] as $row) { + //set the voicemail id and voicemail uuid arrays + foreach ($_SESSION['user']['extension'] as $index => $row) { if (strlen($row['number_alias']) > 0) { - $voicemail_ids[]['voicemail_id'] = $row['number_alias']; + $voicemail_ids[$index]['voicemail_id'] = $row['number_alias']; } else { - $voicemail_ids[]['voicemail_id'] = $row['user']; + $voicemail_ids[$index]['voicemail_id'] = $row['user']; + } + } + foreach ($_SESSION['user']['voicemail'] as $row) { + if (strlen($row['voicemail_uuid']) > 0) { + $voicemail_uuids[]['voicemail_uuid'] = $row['voicemail_uuid']; } } @@ -60,18 +65,18 @@ $sql .= "and voicemail_uuid = '".$this->voicemail_uuid."' "; } else { - //ensure that the requested voicemail id is assigned to this user + //ensure that the requested voicemail box is assigned to this user $found = false; - foreach($voicemail_ids as $row) { - if ($voicemail_uuid == $row['voicemail_id']) { - $sql .= "and voicemail_id = '".$row['voicemail_id']."' "; + foreach($voicemail_uuids as $row) { + if ($voicemail_uuid == $row['voicemail_uuid']) { + $sql .= "and voicemail_uuid = '".$row['voicemail_uuid']."' "; $found = true; } $x++; } //id requested is not owned by the user return no results if (!$found) { - $sql .= "and voicemail_uuid = '' "; + $sql .= "and voicemail_uuid is null "; } } } @@ -93,7 +98,7 @@ } else { //no assigned voicemail ids so return no results - $sql .= "and voicemail_uuid = '' "; + $sql .= "and voicemail_uuid is null "; } } $sql .= "order by voicemail_id asc "; diff --git a/app/voicemails/voicemail_messages.php b/app/voicemails/voicemail_messages.php index 522785e473..8cb4baaa99 100644 --- a/app/voicemails/voicemail_messages.php +++ b/app/voicemails/voicemail_messages.php @@ -84,117 +84,108 @@ if (!(check_str($_REQUEST["action"]) == "download" && check_str($_REQUEST["src"] require_once "resources/paging.php"; //show the content - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
"; - echo " ".$text['title-voicemail_messages'].""; - echo "

"; - echo " ".$text['description-voicemail_message']; - echo "

"; - echO "
 
\n"; + echo "".$text['title-voicemail_messages'].""; + echo "

"; + echo $text['description-voicemail_message']; + echo "

"; $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; $row_style["2"] = "row_style2"; - 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;'"); - $table_header .= "\n"; - $table_header .= "\n"; - $table_header .= "\n"; - //loop through the voicemail messages if (count($voicemails) > 0) { + + echo "
"; + echo "
".$text['label-tools']."".$text['label-message_size']."\n"; - $table_header .= "  \n"; - $table_header .= "
\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;'"); + $table_header .= "\n"; + $table_header .= ""; + $table_header .= "\n"; + $previous_voicemail_id = ''; foreach($voicemails as $field) { if ($previous_voicemail_id != $field['voicemail_id']) { - echo "\n"; - echo " \n"; } + echo "\n"; + echo " \n"; echo " \n"; echo " \n"; echo "\n"; - echo $table_header; + if (count($field['messages']) > 0) { + echo $table_header; + } } - foreach($field['messages'] as &$row) { - if ($row['message_status'] == '') { $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"; - echo " \n"; - echo " \n"; + echo "\n"; + $c = ($c) ? 0 : 1; } - echo " \n"; - echo "\n"; - if ($c==0) { $c=1; } else { $c=0; } - } //end foreach + } + else { + echo ""; + }//end foreach unset($row); $previous_voicemail_id = $field['voicemail_id']; unset($sql, $result, $result_count); + } - } //end if results - echo "\n"; - echo "\n"; - echo "\n"; + echo "
".$text['label-tools']."".$text['label-message_size']." 
\n"; - echo "
"; if ($previous_voicemail_id != '') { - echo "


\n"; + echo "



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

 
"; - echo " ".$row['created_date']; - echo "".$row['caller_id_name']." ".$row['caller_id_number']." 
".$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_play.""; - echo "".$v_link_label_download.""; - echo " ".$row['message_length_label']." ".$row['file_size_label']."\n"; - if (permission_exists('voicemail_message_delete')) { - echo " $v_link_label_delete\n"; + echo "
".$text['message-messages_not_found']."
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
  \n"; - echo "  \n"; - echo "
\n"; - echo "
"; + echo "

"; - echo ""; - echo "

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

"; + } + + echo "
"; //autoplay message if (check_str($_REQUEST["action"]) == "autoplay" && check_str($_REQUEST["uuid"]) != '') { diff --git a/app/voicemails/voicemails.php b/app/voicemails/voicemails.php index 79f087ca9c..59621234c8 100644 --- a/app/voicemails/voicemails.php +++ b/app/voicemails/voicemails.php @@ -38,19 +38,20 @@ else { $language = new text; $text = $language->get(); -//set the voicemail_id array - foreach ($_SESSION['user']['extension'] as $row) { +//set the voicemail id and voicemail uuid arrays + foreach ($_SESSION['user']['extension'] as $index => $row) { if (strlen($row['number_alias']) > 0) { - $voicemail_ids[]['voicemail_id'] = $row['number_alias']; + $voicemail_ids[$index]['voicemail_id'] = $row['number_alias']; } else { - $voicemail_ids[]['voicemail_id'] = $row['user']; + $voicemail_ids[$index]['voicemail_id'] = $row['user']; + } + } + foreach ($_SESSION['user']['voicemail'] as $row) { + if (strlen($row['voicemail_uuid']) > 0) { + $voicemail_uuids[]['voicemail_uuid'] = $row['voicemail_uuid']; } } - -//add multi-lingual support - $language = new text; - $text = $language->get(); //additional includes require_once "resources/header.php"; @@ -88,21 +89,23 @@ else { } if (!permission_exists('voicemail_delete')) { $x = 0; - if (count($voicemail_ids) > 0) { + if (count($voicemail_uuids) > 0) { $sql .= "and ("; - foreach($voicemail_ids as $row) { + foreach($voicemail_uuids as $row) { if ($x == 0) { - $sql .= "voicemail_id = '".$row['voicemail_id']."' "; + $sql .= "voicemail_uuid = '".$row['voicemail_uuid']."' "; } else { - $sql .= " or voicemail_id = '".$row['voicemail_id']."'"; + $sql .= " or voicemail_uuid = '".$row['voicemail_uuid']."'"; } $x++; } $sql .= ")"; } + else { + $sql .= "and voicemail_uuid is null "; + } } - if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } $prep_statement = $db->prepare($sql); if ($prep_statement) { $prep_statement->execute(); @@ -118,46 +121,17 @@ else { //prepare to page the results $rows_per_page = 150; $param = ""; + if ($search != '') { $param .= "&search=".$search; } + if ($order_by != '') { $param .= "&order_by=".$order_by."&order=".$order; } $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_voicemails "; - $sql .= "where domain_uuid = '$domain_uuid' "; - if (strlen($search) > 0) { - $sql .= "and ("; - $sql .= " voicemail_id like '%".$search."%' "; - $sql .= " or voicemail_mail_to like '%".$search."%' "; - $sql .= " or voicemail_local_after_email like '%".$search."%' "; - $sql .= " or voicemail_enabled like '%".$search."%' "; - $sql .= " or voicemail_description like '%".$search."%' "; - $sql .= ") "; - } - if (!permission_exists('voicemail_delete')) { - $x = 0; - if (count($voicemail_ids) > 0) { - $sql .= "and ("; - foreach($voicemail_ids as $row) { - if ($x == 0) { - $sql .= "voicemail_id = '".$row['voicemail_id']."' "; - } - else { - $sql .= " or voicemail_id = '".$row['voicemail_id']."'"; - } - $x++; - } - $sql .= ")"; - } - } - if (strlen($order_by) == 0) { - $sql .= "order by voicemail_id asc "; - } - else { - $sql .= "order by $order_by $order "; - } - $sql .= "limit $rows_per_page offset $offset "; + $sql = str_replace('count(*) as num_rows', '*', $sql); + $sql .= ($order_by != '') ? "order by ".$order_by." ".$order." " : "order by voicemail_id asc "; + $sql .= "limit ".$rows_per_page." offset ".$offset." "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); @@ -168,23 +142,29 @@ else { $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; - echo "\n"; - echo "\n"; - echo th_order_by('voicemail_id', $text['label-voicemail_id'], $order_by, $order); - echo th_order_by('voicemail_mail_to', $text['label-voicemail_mail_to'], $order_by, $order); - echo th_order_by('voicemail_file', $text['label-voicemail_file_attached'], $order_by, $order); - echo th_order_by('voicemail_local_after_email', $text['label-voicemail_local_after_email'], $order_by, $order); - echo "\n"; - echo th_order_by('voicemail_enabled', $text['label-voicemail_enabled'], $order_by, $order); - echo th_order_by('voicemail_description', $text['label-voicemail_description'], $order_by, $order); - echo "\n"; - echo "\n"; - if ($result_count > 0) { + + echo "
".$text['label-tools'].""; - if (permission_exists('voicemail_add')) { - echo "$v_link_label_add"; - } - echo "
\n"; + echo "\n"; + echo th_order_by('voicemail_id', $text['label-voicemail_id'], $order_by, $order); + echo th_order_by('voicemail_mail_to', $text['label-voicemail_mail_to'], $order_by, $order); + echo th_order_by('voicemail_file', $text['label-voicemail_file_attached'], $order_by, $order); + echo th_order_by('voicemail_local_after_email', $text['label-voicemail_local_after_email'], $order_by, $order); + echo "\n"; + echo th_order_by('voicemail_enabled', $text['label-voicemail_enabled'], $order_by, $order); + echo th_order_by('voicemail_description', $text['label-voicemail_description'], $order_by, $order); + if (permission_exists('voicemail_add') || permission_exists('voicemail_edit') || permission_exists('voicemail_delete')) { + echo "\n"; + echo "\n"; + foreach($result as $row) { $tr_link = (permission_exists('voicemail_edit')) ? "href='voicemail_edit.php?id=".$row['voicemail_uuid']."'" : null; echo "\n"; @@ -200,42 +180,54 @@ else { echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; - echo " \n"; } - if (permission_exists('voicemail_delete')) { - echo "$v_link_label_delete"; - } - echo " \n"; echo "\n"; if ($c==0) { $c=1; } else { $c=0; } } //end foreach unset($sql, $result, $row_count); - } //end if results - echo "\n"; - echo "\n"; - echo " \n"; - echo "
".$text['label-tools'].""; + if (permission_exists('voicemail_add')) { + echo "$v_link_label_add"; + } + else { + echo " "; + } + } + echo "
".(($row['voicemail_file'] == 'attach') ? $text['label-true'] : $text['label-false'])."".ucwords($row['voicemail_local_after_email'])." \n"; - echo " ".$text['label-view']."  \n"; - echo " ".$text['label-greetings']."\n"; + if (permission_exists('voicemail_message_view')) { + echo " ".$text['label-view']."  \n"; + } + if (permission_exists('voicemail_greeting_view')) { + echo " ".$text['label-greetings']."\n"; + } echo " ".ucwords($row['voicemail_enabled'])." ".$row['voicemail_description']." "; - if (permission_exists('voicemail_edit')) { - echo "$v_link_label_edit"; + if (permission_exists('voicemail_edit') || permission_exists('voicemail_delete')) { + echo " "; + if (permission_exists('voicemail_edit')) { + echo "$v_link_label_edit"; + } + if (permission_exists('voicemail_delete')) { + echo "$v_link_label_delete"; + } + echo "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; + echo "\n"; + echo "\n"; + + echo "
 $paging_controls"; - if (permission_exists('voicemail_add')) { - echo "$v_link_label_add"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls"; + if (permission_exists('voicemail_add')) { + echo "$v_link_label_add"; + } + echo "
\n"; + echo "
"; + + } + else { + echo "
"; + echo $text['message-mailbox_not_found']; } - echo "
\n"; - echo "\n"; - echo "\n"; - echo ""; echo "

"; //include the footer diff --git a/resources/switch.php b/resources/switch.php index 2ff66c9903..1e9eb697d6 100644 --- a/resources/switch.php +++ b/resources/switch.php @@ -167,12 +167,32 @@ function load_extensions() { if (strlen($_SESSION["domain_uuid"]) > 0 && strlen($_SESSION["user_uuid"]) > 0 && count($_SESSION['user']['extension']) == 0) { //get the user extension list unset($_SESSION['user']['extension']); - $sql = "select e.extension, e.number_alias, e.user_context, e.extension_uuid, e.outbound_caller_id_name, e.outbound_caller_id_number from v_extensions as e, v_extension_users as u "; - $sql .= "where e.domain_uuid = '".$_SESSION['domain_uuid']."' "; - $sql .= "and e.extension_uuid = u.extension_uuid "; - $sql .= "and u.user_uuid = '".$_SESSION['user_uuid']."' "; - $sql .= "and e.enabled = 'true' "; - $sql .= "order by e.extension asc "; + $sql = "select "; + $sql .= " e.extension, "; + $sql .= " e.number_alias, "; + $sql .= " e.user_context, "; + $sql .= " e.extension_uuid, "; + $sql .= " e.outbound_caller_id_name, "; + $sql .= " e.outbound_caller_id_number, "; + $sql .= " v.voicemail_uuid "; + $sql .= "from "; + $sql .= " v_extension_users as u, "; + $sql .= " v_extensions as e "; + $sql .= " left outer join v_voicemails as v on ( "; + $sql .= " e.domain_uuid = v.domain_uuid "; + $sql .= " and v.voicemail_enabled = 'true' "; + $sql .= " and ( "; + $sql .= " e.extension = v.voicemail_id "; + $sql .= " or e.number_alias = v.voicemail_id "; + $sql .= " ) "; + $sql .= " ) "; + $sql .= "where "; + $sql .= " e.domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= " and e.extension_uuid = u.extension_uuid "; + $sql .= " and u.user_uuid = '".$_SESSION['user_uuid']."' "; + $sql .= " and e.enabled = 'true' "; + $sql .= "order by "; + $sql .= " e.extension asc "; $result = $db->query($sql)->fetchAll(PDO::FETCH_ASSOC); if (count($result) > 0) { $x = 0; @@ -182,6 +202,9 @@ function load_extensions() { $_SESSION['user']['extension'][$x]['extension_uuid'] = $row['extension_uuid']; $_SESSION['user']['extension'][$x]['outbound_caller_id_name'] = $row['outbound_caller_id_name']; $_SESSION['user']['extension'][$x]['outbound_caller_id_number'] = $row['outbound_caller_id_number']; + if ($row['voicemail_uuid'] != '') { + $_SESSION['user']['voicemail'][]['voicemail_uuid'] = $row['voicemail_uuid']; + } $_SESSION['user_context'] = $row["user_context"]; $x++; }