contact_extensions.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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-2020
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. */
  21. //includes
  22. require_once "root.php";
  23. require_once "resources/require.php";
  24. require_once "resources/check_auth.php";
  25. //check permissions
  26. if (permission_exists('contact_extension_view')) {
  27. //access granted
  28. }
  29. else {
  30. echo "access denied";
  31. exit;
  32. }
  33. //get the extension list
  34. $sql = "select e.extension_uuid, e.extension, e.enabled, e.description ";
  35. $sql .= "from v_extensions e, v_extension_users eu, v_users u ";
  36. $sql .= "where e.extension_uuid = eu.extension_uuid ";
  37. $sql .= "and u.user_uuid = eu.user_uuid ";
  38. $sql .= "and e.domain_uuid = :domain_uuid ";
  39. $sql .= "and u.contact_uuid = :contact_uuid ";
  40. $sql .= "order by e.extension asc ";
  41. $parameters['domain_uuid'] = $domain_uuid;
  42. $parameters['contact_uuid'] = $contact_uuid;
  43. $database = new database;
  44. $contact_extensions = $database->select($sql, $parameters, 'all');
  45. unset($sql, $parameters);
  46. //show if exists
  47. if (is_array($contact_extensions) && @sizeof($contact_extensions) != 0) {
  48. //show the content
  49. echo "<div class='action_bar sub shrink'>\n";
  50. echo " <div class='heading'><b>".$text['label-contact_extensions']."</b></div>\n";
  51. echo " <div style='clear: both;'></div>\n";
  52. echo "</div>\n";
  53. echo "<table class='list'>\n";
  54. echo "<tr class='list-header'>\n";
  55. echo "<th>".$text['label-extension']."</th>\n";
  56. echo "<th class='center'>".$text['label-enabled']."</th>\n";
  57. echo "<th class='hide-md-dn'>".$text['label-description']."</th>\n";
  58. if (permission_exists('extension_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
  59. echo " <td class='action-button'>&nbsp;</td>\n";
  60. }
  61. echo "</tr>\n";
  62. if (is_array($contact_extensions) && @sizeof($contact_extensions) != 0) {
  63. $x = 0;
  64. foreach ($contact_extensions as $row) {
  65. if (permission_exists('extension_edit')) {
  66. $list_row_url = PROJECT_PATH.'/app/extensions/extension_edit.php?id='.urlencode($row['extension_uuid']);
  67. }
  68. echo "<tr class='list-row' href='".$list_row_url."' ".($row['url_primary'] ? "style='font-weight: bold;'" : null).">\n";
  69. echo " <td>";
  70. if (permission_exists('extension_edit')) {
  71. echo "<a href='".PROJECT_PATH."/app/extensions/extension_edit.php?id=".urlencode($row['extension_uuid'])."'>".escape($row['extension'])."</a>";
  72. }
  73. else {
  74. echo $row['extension'];
  75. }
  76. echo " </td>\n";
  77. echo " <td class='center'>".$text['label-'.escape($row['enabled'])]."&nbsp;</td>\n";
  78. echo " <td class='description overflow hide-md-dn'>".$row['description']."&nbsp;</td>\n";
  79. if (permission_exists('extension_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
  80. echo " <td class='action-button'>\n";
  81. echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
  82. echo " </td>\n";
  83. }
  84. echo "</tr>\n";
  85. $x++;
  86. }
  87. }
  88. unset($contact_extensions);
  89. echo "</table>";
  90. echo "<br />\n";
  91. }
  92. ?>