schemas.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. require_once "root.php";
  22. require_once "resources/require.php";
  23. require_once "resources/check_auth.php";
  24. if (permission_exists('schema_view')) {
  25. //access granted
  26. }
  27. else {
  28. echo "access denied";
  29. exit;
  30. }
  31. //add multi-lingual support
  32. $language = new text;
  33. $text = $language->get();
  34. require_once "resources/header.php";
  35. $document['title'] = $text['title-schemas'];
  36. require_once "resources/paging.php";
  37. //get the http get variables
  38. $order_by = $_GET["order_by"];
  39. $order = $_GET["order"];
  40. //show the content
  41. echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
  42. echo "<tr>\n";
  43. echo "<td width='50%' align='left' nowrap='nowrap'><b>".$text['header-schemas']."</b></td>\n";
  44. echo "<td width='50%' align='right'>&nbsp;</td>\n";
  45. echo "</tr>\n";
  46. echo "<tr>\n";
  47. echo "<td align='left' colspan='2'>\n";
  48. echo $text['description-schemas']."\n";
  49. echo "<br /><br />\n";
  50. echo "</td>\n";
  51. echo "</tr>\n";
  52. echo "</tr></table>\n";
  53. $sql = " select * from v_schemas ";
  54. $sql .= " where domain_uuid = '$domain_uuid' ";
  55. if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
  56. $prep_statement = $db->prepare(check_sql($sql));
  57. $prep_statement->execute();
  58. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  59. $num_rows = count($result);
  60. unset ($prep_statement, $result, $sql);
  61. $rows_per_page = 100;
  62. $param = "";
  63. $page = $_GET['page'];
  64. if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
  65. list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page);
  66. $offset = $rows_per_page * $page;
  67. $sql = " select * from v_schemas ";
  68. $sql .= " where domain_uuid = '$domain_uuid' ";
  69. if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
  70. $sql .= " limit $rows_per_page offset $offset ";
  71. $prep_statement = $db->prepare(check_sql($sql));
  72. $prep_statement->execute();
  73. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  74. $result_count = count($result);
  75. unset ($prep_statement, $sql);
  76. $c = 0;
  77. $row_style["0"] = "row_style0";
  78. $row_style["1"] = "row_style1";
  79. echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
  80. echo "<tr>\n";
  81. echo th_order_by('schema_label', $text['label-label'], $order_by, $order);
  82. echo th_order_by('schema_name', $text['label-schema_name'], $order_by, $order);
  83. echo th_order_by('schema_auth', $text['label-authentication'], $order_by, $order);
  84. echo th_order_by('schema_description', $text['label-description'], $order_by, $order);
  85. //echo "<th align='center'>View</th>\n";
  86. echo "<td class='list_control_icons'>";
  87. if (permission_exists('schema_add')) {
  88. echo "<a href='schema_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
  89. }
  90. echo "</td>\n";
  91. echo "</tr>\n";
  92. if ($result_count == 0) {
  93. //no results
  94. }
  95. else { //received results
  96. foreach($result as $row) {
  97. $tr_link = (permission_exists('schema_edit')) ? "href='schema_edit.php?id=".$row['schema_uuid']."'" : null;
  98. echo "<tr ".$tr_link.">\n";
  99. echo " <td valign='top' class='".$row_style[$c]."'>".$row['schema_label']."&nbsp;</td>\n";
  100. echo " <td valign='top' class='".$row_style[$c]."'>";
  101. if (permission_exists('schema_edit')) {
  102. echo "<a href='schema_edit.php?id=".$row['schema_uuid']."'>".$row['schema_name']."</a>";
  103. }
  104. else {
  105. echo $row['schema_name'];
  106. }
  107. echo " </td>\n";
  108. echo " <td valign='top' class='".$row_style[$c]."'>";
  109. if ($row['schema_auth'] == 'yes') {
  110. echo $text['option-true'];
  111. }
  112. else if ($row['schema_auth'] == 'no') {
  113. echo $text['option-false'];
  114. }
  115. else {
  116. echo "&nbsp;";
  117. }
  118. echo " </td>\n";
  119. echo " <td valign='top' class='row_stylebg'>".$row['schema_description']."&nbsp;</td>\n";
  120. echo " <td class='list_control_icons'>";
  121. if (permission_exists('schema_edit')) {
  122. echo "<a href='schema_edit.php?id=".$row['schema_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
  123. }
  124. if (permission_exists('schema_delete')) {
  125. echo "<a href='schema_delete.php?id=".$row['schema_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
  126. }
  127. echo " </td>\n";
  128. echo "</tr>\n";
  129. if ($c==0) { $c=1; } else { $c=0; }
  130. } //end foreach
  131. unset($sql, $result, $row_count);
  132. } //end if results
  133. echo "<tr>\n";
  134. echo "<td colspan='6' align='left'>\n";
  135. echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
  136. echo " <tr>\n";
  137. echo " <td width='33.3%' nowrap>&nbsp;</td>\n";
  138. echo " <td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
  139. echo " <td class='list_control_icons'>";
  140. if (permission_exists('schema_add')) {
  141. echo "<a href='schema_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
  142. }
  143. echo " </td>\n";
  144. echo " </tr>\n";
  145. echo " </table>\n";
  146. echo "</td>\n";
  147. echo "</tr>\n";
  148. echo "</table>";
  149. echo "<br><br>";
  150. //show the footer
  151. require_once "resources/footer.php";
  152. ?>