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.

202 lines
7.0 KiB

2 years ago
  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-2020
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <markjcrane@fusionpbx.com>
  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('voicemail_greeting_edit')) {
  27. //access granted
  28. }
  29. else {
  30. echo "access denied";
  31. exit;
  32. }
  33. //add multi-lingual support
  34. $language = new text;
  35. $text = $language->get();
  36. //validate the uuids
  37. if (is_uuid($_REQUEST["id"])) {
  38. $voicemail_greeting_uuid = $_REQUEST["id"];
  39. }
  40. if (is_numeric($_REQUEST["voicemail_id"])) {
  41. $voicemail_id = $_REQUEST["voicemail_id"];
  42. }
  43. //get the form value and set to php variables
  44. if (count($_POST) > 0) {
  45. $greeting_name = $_POST["greeting_name"];
  46. $greeting_description = $_POST["greeting_description"];
  47. //clean the name
  48. $greeting_name = str_replace("'", "", $greeting_name);
  49. }
  50. if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
  51. //delete the voicemail greeting
  52. if (permission_exists('voicemail_greeting_delete')) {
  53. if ($_POST['action'] == 'delete' && is_uuid($voicemail_greeting_uuid)) {
  54. //prepare
  55. $array[0]['checked'] = 'true';
  56. $array[0]['uuid'] = $voicemail_greeting_uuid;
  57. //delete
  58. $obj = new voicemail_greetings;
  59. $obj->voicemail_id = $voicemail_id;
  60. $obj->delete($array);
  61. //redirect
  62. header("Location: voicemail_greetings.php?id=".$voicemail_id);
  63. exit;
  64. }
  65. }
  66. //validate the token
  67. $token = new token;
  68. if (!$token->validate($_SERVER['PHP_SELF'])) {
  69. message::add($text['message-invalid_token'],'negative');
  70. header('Location: ../voicemails/voicemails.php');
  71. exit;
  72. }
  73. //check for all required data
  74. $msg = '';
  75. if (strlen($greeting_name) == 0) { $msg .= "".$text['confirm-name']."<br>\n"; }
  76. if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
  77. require_once "resources/header.php";
  78. require_once "resources/persist_form_var.php";
  79. echo "<div align='center'>\n";
  80. echo "<table><tr><td>\n";
  81. echo $msg."<br />";
  82. echo "</td></tr></table>\n";
  83. persistformvar($_POST);
  84. echo "</div>\n";
  85. require_once "resources/footer.php";
  86. return;
  87. }
  88. //update the database
  89. if ($_POST["persistformvar"] != "true" && permission_exists('voicemail_greeting_edit')) {
  90. //build update array
  91. $array['voicemail_greetings'][0]['voicemail_greeting_uuid'] = $voicemail_greeting_uuid;
  92. $array['voicemail_greetings'][0]['greeting_name'] = $greeting_name;
  93. $array['voicemail_greetings'][0]['greeting_description'] = $greeting_description;
  94. //execute update
  95. $database = new database;
  96. $database->app_name = 'voicemail_greetings';
  97. $database->app_uuid = 'e4b4fbee-9e4d-8e46-3810-91ba663db0c2';
  98. $database->save($array);
  99. unset($array);
  100. //set message
  101. message::add($text['message-update']);
  102. //redirect
  103. header("Location: voicemail_greetings.php?id=".$voicemail_id);
  104. exit;
  105. }
  106. }
  107. //pre-populate the form
  108. if (count($_GET) > 0 && $_POST["persistformvar"] != "true") {
  109. $sql = "select * from v_voicemail_greetings ";
  110. $sql .= "where domain_uuid = :domain_uuid ";
  111. $sql .= "and voicemail_greeting_uuid = :voicemail_greeting_uuid ";
  112. $parameters['domain_uuid'] = $domain_uuid;
  113. $parameters['voicemail_greeting_uuid'] = $voicemail_greeting_uuid;
  114. $database = new database;
  115. $row = $database->select($sql, $parameters, 'row');
  116. if (is_array($row) && @sizeof($row) != 0) {
  117. $greeting_name = $row["greeting_name"];
  118. $greeting_description = $row["greeting_description"];
  119. }
  120. unset($sql, $parameters, $row);
  121. }
  122. //create token
  123. $object = new token;
  124. $token = $object->create($_SERVER['PHP_SELF']);
  125. //show the header
  126. $document['title'] = $text['label-edit'];
  127. require_once "resources/header.php";
  128. //show the content
  129. echo "<form name='frm' id='frm' method='post'>\n";
  130. echo "<div class='action_bar' id='action_bar'>\n";
  131. echo " <div class='heading'><b>".$text['label-edit']."</b></div>\n";
  132. echo " <div class='actions'>\n";
  133. echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','collapse'=>'hide-xs','link'=>'voicemail_greetings.php?id='.urlencode($voicemail_id)]);
  134. if (permission_exists('voicemail_greeting_delete')) {
  135. echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'name'=>'btn_delete','collapse'=>'hide-xs','style'=>'margin-right: 15px;','onclick'=>"modal_open('modal-delete','btn_delete');"]);
  136. }
  137. echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','collapse'=>'hide-xs']);
  138. echo " </div>\n";
  139. echo " <div style='clear: both;'></div>\n";
  140. echo "</div>\n";
  141. if (permission_exists('voicemail_greeting_delete')) {
  142. echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'delete','onclick'=>"modal_close();"])]);
  143. }
  144. echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
  145. echo "<tr>\n";
  146. echo "<td width='30%' class='vncellreq' valign='top' align='left' nowrap>\n";
  147. echo " ".$text['label-name']."\n";
  148. echo "</td>\n";
  149. echo "<td width='70%' class='vtable' align='left'>\n";
  150. echo " <input class='formfld' type='text' name='greeting_name' maxlength='255' value=\"".escape($greeting_name)."\">\n";
  151. echo "<br />\n";
  152. echo "".$text['description-name']."\n";
  153. echo "</td>\n";
  154. echo "</tr>\n";
  155. echo "<tr>\n";
  156. echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  157. echo " ".$text['label-description']."\n";
  158. echo "</td>\n";
  159. echo "<td class='vtable' align='left'>\n";
  160. echo " <input class='formfld' type='text' name='greeting_description' maxlength='255' value=\"".escape($greeting_description)."\">\n";
  161. echo "<br />\n";
  162. echo "".$text['description-info']."\n";
  163. echo "</td>\n";
  164. echo "</tr>\n";
  165. echo "</table>";
  166. echo "<br /><br />";
  167. echo "<input type='hidden' name='voicemail_greeting_uuid' value='".escape($voicemail_greeting_uuid)."'>\n";
  168. echo "<input type='hidden' name='voicemail_id' value='".escape($voicemail_id)."'>\n";
  169. echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
  170. echo "</form>";
  171. //include the footer
  172. require_once "resources/footer.php";
  173. ?>