Fork of FusionPBX but with LDAP kinda working
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

133 lines
4.4 KiB

  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 <markjcrane@fusionpbx.com>
  16. Portions created by the Initial Developer are Copyright (C) 2008-2016
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. KonradSC <konrd@yahoo.com>
  20. Mark J Crane <markjcrane@fusionpbx.com>
  21. */
  22. //includes
  23. include "root.php";
  24. require_once "resources/require.php";
  25. require_once "resources/check_auth.php";
  26. require_once "resources/paging.php";
  27. //check permissions
  28. if (permission_exists('webphone_view')) {
  29. //access granted
  30. }
  31. else {
  32. echo "access denied";
  33. exit;
  34. }
  35. //create token
  36. $object = new token;
  37. $token = $object->create($_SERVER['PHP_SELF']);
  38. //add multi-lingual support
  39. $language = new text;
  40. $text = $language->get();
  41. //verify the id is as uuid then set as a variable
  42. if (is_uuid($_GET['id'])) {
  43. $extension_uuid = $_GET['id'];
  44. }
  45. //get the extension(s)
  46. if (permission_exists('extension_edit')) {
  47. //admin user
  48. $sql = "select * from v_extensions ";
  49. $sql .= "where domain_uuid = :domain_uuid ";
  50. $sql .= "and enabled = 'true' ";
  51. $sql .= "order by extension asc ";
  52. }
  53. else {
  54. //normal user
  55. $sql = "select e.* ";
  56. $sql .= "from v_extensions as e, ";
  57. $sql .= "v_extension_users as eu ";
  58. $sql .= "where e.extension_uuid = eu.extension_uuid ";
  59. $sql .= "and eu.user_uuid = :user_uuid ";
  60. $sql .= "and e.domain_uuid = :domain_uuid ";
  61. $sql .= "and e.enabled = 'true' ";
  62. $sql .= "order by e.extension asc ";
  63. $parameters['user_uuid'] = $_SESSION['user']['user_uuid'];
  64. }
  65. $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  66. $database = new database;
  67. $extensions = $database->select($sql, $parameters, 'all');
  68. unset($sql, $parameters);
  69. //include the header
  70. $document['title'] = $text['title-webphone'];
  71. require_once "resources/header.php";
  72. echo "<form name='frm' id='frm' method='get'>\n";
  73. echo "<div class='action_bar' id='action_bar'>\n";
  74. echo " <div class='heading'><b>".$text['title-webphone']."</b></div>\n";
  75. echo " <div class='actions'></div>\n";
  76. echo " \n";
  77. echo " <div style='clear: both;'></div>\n";
  78. echo "</div>\n";
  79. echo $text['title-description-webphone']."\n";
  80. echo "<br /><br />\n";
  81. echo "<div style='text-align: center; white-space: nowrap; margin: 10px 0 40px 0;'>";
  82. echo $text['label-select_extension']."<br />\n";
  83. echo "<select name='id' class='formfld' onchange='this.form.submit();'>\n";
  84. echo " <option value='' >".$text['label-select']."...</option>\n";
  85. if (is_array($extensions) && @sizeof($extensions) != 0) {
  86. foreach ($extensions as $row) {
  87. $selected = $row['extension_uuid'] == $extension_uuid ? "selected='selected'" : null;
  88. echo " <option value='".escape($row['extension_uuid'])."' ".$selected.">".escape($row['extension'])." ".escape($row['number_alias'])." ".escape($row['description'])."</option>\n";
  89. }
  90. }
  91. echo "</select>\n";
  92. echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
  93. echo "</form>\n";
  94. //begin the content
  95. if (strlen($extension_uuid) > 0 ) {
  96. echo " <a href=\"phone\" id=\"launchPhone\">".$text['label-webphone_launch']."</a>\n";
  97. }
  98. echo " <script>\n";
  99. echo " var url = 'phone/index.php?id=".escape($extension_uuid)."',\n";
  100. echo " features = 'menubar=no,location=no,resizable=no,scrollbars=no,status=no,addressbar=no,width=320,height=480'\n";
  101. echo " $('#launchPhone').on('click', function(event) { \n";
  102. echo " event.preventDefault() \n";
  103. // This is set when the phone is open and removed on close
  104. echo " if (!localStorage.getItem('ctxPhone')) { \n";
  105. echo " window.open(url, 'ctxPhone', features)\n";
  106. echo " return false\n";
  107. echo " } else { \n";
  108. echo " window.alert('Phone already open.')\n";
  109. echo " }\n";
  110. echo " })\n";
  111. echo " function updatevariable(data) { \n";
  112. echo " value = data;\n";
  113. echo " } \n";
  114. echo " </script>\n";
  115. echo "</div>\n";
  116. //show the footer
  117. require_once "resources/footer.php";
  118. ?>