call_acl.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. Igor Olhovskiy <[email protected]>
  21. Call ACL is written on Call Block base by Gerrit Visser <[email protected]>
  22. */
  23. require_once "root.php";
  24. require_once "resources/require.php";
  25. //check permissions
  26. require_once "resources/check_auth.php";
  27. if (permission_exists('call_acl_view')) {
  28. //access granted
  29. } else {
  30. echo "access denied";
  31. exit;
  32. }
  33. //add multi-lingual support
  34. $language = new text;
  35. $text = $language->get();
  36. //additional includes
  37. require_once "resources/header.php";
  38. require_once "resources/paging.php";
  39. //get variables used to control the order
  40. $order_by = $_GET["order_by"];
  41. $order = $_GET["order"];
  42. //show the content
  43. echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
  44. echo " <tr>\n";
  45. echo " <td width='50%' align='left' nowrap='nowrap'><b>".$text['title-call_acl']."</b></td>\n";
  46. echo " <td width='50%' align='right'>&nbsp;</td>\n";
  47. echo " </tr>\n";
  48. echo " <tr>\n";
  49. echo " <td align='left' colspan='2'>\n";
  50. echo " ".$text['description-call_acl']."<br /><br />\n";
  51. echo " </td>\n";
  52. echo " </tr>\n";
  53. echo "</table>\n";
  54. //prepare to page the results
  55. $sql = "SELECT count(*) AS num_rows FROM v_call_acl";
  56. $sql .= " WHERE domain_uuid = '".$_SESSION['domain_uuid']."' ";
  57. if (strlen($order_by)> 0) {
  58. $sql .= "ORDER BY $order_by $order ";
  59. }
  60. $prep_statement = $db->prepare($sql);
  61. if ($prep_statement) {
  62. $prep_statement->execute();
  63. $row = $prep_statement->fetch(PDO::FETCH_ASSOC);
  64. $num_rows = $row['num_rows'] > 0 ? $row['num_rows'] : "0";
  65. }
  66. //prepare to page the results
  67. $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
  68. $param = "";
  69. $page = $_GET['page'];
  70. if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
  71. list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page);
  72. $offset = $rows_per_page * $page;
  73. //get the list
  74. $sql = "SELECT * FROM v_call_acl";
  75. $sql .= " WHERE domain_uuid = '".$_SESSION['domain_uuid']."' ";
  76. if (strlen($order_by)> 0) {
  77. $sql .= "ORDER BY $order_by $order ";
  78. } else {
  79. $sql .= "ORDER BY call_acl_order ASC ";
  80. }
  81. $sql .= " LIMIT $rows_per_page OFFSET $offset ";
  82. $prep_statement = $db->prepare(check_sql($sql));
  83. $prep_statement->execute();
  84. $result = $prep_statement->fetchAll();
  85. $result_count = count($result);
  86. unset ($prep_statement, $sql);
  87. //table headers
  88. $c = 0;
  89. $row_style["0"] = "row_style0";
  90. $row_style["1"] = "row_style1";
  91. echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
  92. echo "<tr>\n";
  93. echo th_order_by('call_acl_order', $text['label-call_acl_order'], $order_by, $order);
  94. echo th_order_by('call_acl_name', $text['label-call_acl_name'], $order_by, $order);
  95. echo th_order_by('call_acl_source', $text['label-call_acl_source'], $order_by, $order);
  96. echo th_order_by('call_acl_destination', $text['label-call_acl_destination'], $order_by, $order);
  97. echo th_order_by('call_acl_action', $text['label-call_acl_action'], $order_by, $order);
  98. echo th_order_by('call_acl_enabled', $text['label-call_acl_enabled'], $order_by, $order);
  99. echo "<td class='list_control_icons'>";
  100. if (permission_exists('call_acl_add')) {
  101. echo "<a href='call_acl_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
  102. }
  103. echo "</td>\n";
  104. echo "</tr>\n";
  105. //show the results
  106. if ($result_count > 0) {
  107. foreach($result as $row) {
  108. $tr_link = (permission_exists('call_acl_edit')) ? "href='call_acl_edit.php?id=".$row['call_acl_uuid']."'" : null;
  109. echo "<tr ".$tr_link.">\n";
  110. echo " <td valign='top' class='".$row_style[$c]."'>";
  111. if (permission_exists('call_acl_edit')) {
  112. echo "<a href='call_acl_edit.php?id=".escape($row['call_acl_uuid'])."'>".escape($row['call_acl_order'])."</a>";
  113. } else {
  114. echo escape($row['call_acl_order']);
  115. }
  116. echo " </td>\n";
  117. echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['call_acl_name'])."</td>\n";
  118. echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['call_acl_source'])."</td>\n";
  119. echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['call_acl_destination'])."</td>\n";
  120. echo " <td valign='top' class='".$row_style[$c]."'>". (($row['call_acl_action'] == "reject") ? $text['label-reject'] : $text['label-allow']) ."</td>\n";
  121. echo " <td valign='top' class='".$row_style[$c]."'>".$text['label-'.escape($row['call_acl_enabled'])]."</td>\n";
  122. echo " <td class='list_control_icons'>";
  123. if (permission_exists('call_acl_edit')) {
  124. echo "<a href='call_acl_edit.php?id=".escape($row['call_acl_uuid'])."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
  125. }
  126. if (permission_exists('call_acl_delete')) {
  127. echo "<a href='call_acl_delete.php?id=".escape($row['call_acl_uuid'])."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
  128. };
  129. echo " </td>";
  130. echo "</tr>\n";
  131. $c = 1 - $c; // Switch $c = 0/1/0...
  132. } //end foreach
  133. unset($sql, $result, $row_count);
  134. } //end if results
  135. //complete the content
  136. echo "<tr>\n";
  137. echo "<td colspan='11' align='left'>\n";
  138. echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
  139. echo " <tr>\n";
  140. echo " <td width='33.3%' nowrap>&nbsp;</td>\n";
  141. echo " <td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
  142. echo " <td class='list_control_icons'>";
  143. if (permission_exists('call_acl_add')) {
  144. echo "<a href='call_acl_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
  145. }
  146. echo " </td>\n";
  147. echo " </tr>\n";
  148. echo " </table>\n";
  149. echo "</td>\n";
  150. echo "</tr>\n";
  151. echo "</table>";
  152. echo "<br /><br />";
  153. //include the footer
  154. require_once "resources/footer.php";
  155. ?>