voicemail.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <?php
  2. /*
  3. FusionPBX
  4. Version: MPL 1.1
  5. The contents of this file are subject to the Mozilla Public License Version
  6. 1.1 (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.mozilla.org/MPL/
  9. Software distributed under the License is distributed on an "AS IS" basis,
  10. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. for the specific language governing rights and limitations under the
  12. License.
  13. The Original Code is FusionPBX
  14. The Initial Developer of the Original Code is
  15. Mark J Crane <[email protected]>
  16. Portions created by the Initial Developer are Copyright (C) 2008-2012
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. */
  21. include "root.php";
  22. require "resources/require.php";
  23. require_once "resources/check_auth.php";
  24. if (permission_exists('voicemail_status_view')) {
  25. //access granted
  26. }
  27. else {
  28. echo "access denied";
  29. exit;
  30. }
  31. require_once "resources/header.php";
  32. require_once "resources/paging.php";
  33. //add multi-lingual support
  34. $language = new text;
  35. $text = $language->get();
  36. //get the http values and set as variables
  37. $order_by = $_GET["order_by"];
  38. $order = $_GET["order"];
  39. //show the content
  40. echo "<div align='center'>";
  41. echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
  42. echo "<tr class='border'>\n";
  43. echo " <td align=\"center\">\n";
  44. echo " <br>";
  45. echo "<table width=\"100%\" border=\"0\" cellpadding=\"6\" cellspacing=\"0\">\n";
  46. echo " <tr>\n";
  47. echo " <td align='left'><b>".$text['title-voicemail']."</b><br>\n";
  48. echo " ".$text['description-voicemail']."\n";
  49. echo " </td>\n";
  50. echo " </tr>\n";
  51. echo "</table>\n";
  52. echo "<br />";
  53. $c = 0;
  54. $row_style["0"] = "row_style0";
  55. $row_style["1"] = "row_style1";
  56. echo "<div align='center'>\n";
  57. echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
  58. echo "<tr>\n";
  59. echo th_order_by('extension', $text['label-extension'], $order_by, $order);
  60. echo th_order_by('vm_mailto', $text['label-voicemail'], $order_by, $order);
  61. echo "<th>".$text['label-messages']."</th>\n";
  62. echo th_order_by('enabled', $text['label-enabled'], $order_by, $order);
  63. echo th_order_by('description', $text['label-description'], $order_by, $order);
  64. echo "<tr>\n";
  65. $sql = "select * from v_extensions ";
  66. $sql .= "where domain_uuid = '$domain_uuid' ";
  67. if (!(if_group("admin") || if_group("superadmin"))) {
  68. if (count($_SESSION['user']['extension']) > 0) {
  69. $sql .= "and (";
  70. $x = 0;
  71. foreach($_SESSION['user']['extension'] as $row) {
  72. if ($x > 0) { $sql .= "or "; }
  73. $sql .= "extension = '".$row['user']."' ";
  74. $x++;
  75. }
  76. $sql .= ")";
  77. }
  78. else {
  79. //hide any results when a user has not been assigned an extension
  80. $sql .= "and extension = 'disabled' ";
  81. }
  82. }
  83. if (strlen($order_by)> 0) {
  84. $sql .= "order by $order_by $order ";
  85. }
  86. else {
  87. $sql .= "order by extension asc ";
  88. }
  89. $prep_statement = $db->prepare(check_sql($sql));
  90. $prep_statement->execute();
  91. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  92. $num_rows = count($result);
  93. unset ($prep_statement, $result, $sql);
  94. $rows_per_page = 100;
  95. $param = "";
  96. $page = $_GET['page'];
  97. if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
  98. list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page);
  99. $offset = $rows_per_page * $page;
  100. $sql = "select * from v_extensions ";
  101. $sql .= "where domain_uuid = '$domain_uuid' ";
  102. if (!(if_group("admin") || if_group("superadmin"))) {
  103. if (count($_SESSION['user']['extension']) > 0) {
  104. $sql .= "and (";
  105. $x = 0;
  106. foreach($_SESSION['user']['extension'] as $row) {
  107. if ($x > 0) { $sql .= "or "; }
  108. $sql .= "extension = '".$row['user']."' ";
  109. $x++;
  110. }
  111. $sql .= ")";
  112. }
  113. else {
  114. //hide any results when a user has not been assigned an extension
  115. $sql .= "and extension = 'disabled' ";
  116. }
  117. }
  118. if (strlen($order_by)> 0) {
  119. $sql .= "order by $order_by $order ";
  120. }
  121. else {
  122. $sql .= "order by extension asc ";
  123. }
  124. $sql .= " limit $rows_per_page offset $offset ";
  125. $prep_statement = $db->prepare(check_sql($sql));
  126. $prep_statement->execute();
  127. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  128. $result_count = count($result);
  129. unset ($prep_statement, $sql);
  130. //pdo voicemail database connection
  131. // include "resources/pdo_vm.php";
  132. if ($result_count > 0) {
  133. foreach($result as $row) {
  134. $sql = "select count(*) as count from voicemail_msgs ";
  135. $sql .= "where domain = '".$_SESSION['domains'][$domain_uuid]['domain_name']."' ";
  136. $sql .= "and username = '".$row['extension']."' ";
  137. // $prep_statement = $db->prepare(check_sql($sql));
  138. // $prep_statement->execute();
  139. // $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  140. // foreach ($result as &$row2) {
  141. // $count = $row2["count"];
  142. // break; //limit to 1 row
  143. // }
  144. // unset ($prep_statement);
  145. echo "<tr >\n";
  146. echo " <td valign='top' class='".$row_style[$c]."'>".$row['extension']."</td>\n";
  147. echo " <td valign='top' class='".$row_style[$c]."'>".$row['vm_mailto']."&nbsp;</td>\n";
  148. echo " <td valign='top' class='".$row_style[$c]."'>".$count."&nbsp;</td>\n";
  149. echo " <td valign='top' class='".$row_style[$c]."'>".($row['vm_enabled']?"true":"false")."</td>\n";
  150. echo " <td valign='top' class='row_stylebg' width='30%'>".$row['description']."&nbsp;</td>\n";
  151. echo " <td valign='top' align='right'>\n";
  152. if (permission_exists('voicemail_status_delete')) {
  153. echo " <a href='voicemail_prefs_delete.php?id=".$row['extension_uuid']."' alt='".$text['confirm-prefs-delete-alt']."' title='".$text['confirm-prefs-delete-title']."' onclick=\"return confirm('".$text['confirm-prefs-delete']."')\">$v_link_label_delete</a>\n";
  154. }
  155. echo " </td>\n";
  156. echo "</tr>\n";
  157. unset($count);
  158. if ($c==0) { $c=1; } else { $c=0; }
  159. } //end foreach
  160. unset($sql, $result, $row_count);
  161. } //end if results
  162. echo "</table>";
  163. echo "</div>";
  164. echo "<br><br>";
  165. echo "<br><br>";
  166. echo "</td>";
  167. echo "</tr>";
  168. echo "</table>";
  169. echo "</div>";
  170. echo "<br><br>";
  171. //show the footer
  172. require "resources/require.php";
  173. require_once "resources/footer.php";
  174. ?>