menu_restore_default.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. //check permissions
  22. if(!defined('STDIN')) {
  23. //includes files
  24. require_once dirname(__DIR__, 2) . "/resources/require.php";
  25. require_once "resources/check_auth.php";
  26. if (permission_exists('menu_restore')) {
  27. //access granted
  28. }
  29. else {
  30. echo "access denied";
  31. return;
  32. }
  33. }
  34. //add multi-lingual support
  35. $language = new text;
  36. $text = $language->get();
  37. //get the http value and set as a php variable
  38. if (!empty($_REQUEST["menu_uuid"])) {
  39. $menu_uuid = $_REQUEST["menu_uuid"];
  40. }
  41. if (!empty($_REQUEST["menu_language"])) {
  42. $menu_language = $_REQUEST["menu_language"];
  43. }
  44. //menu restore default
  45. //require_once "resources/classes/menu.php";
  46. $menu = new menu;
  47. $menu->menu_uuid = $menu_uuid;
  48. $menu->menu_language = $menu_language;
  49. $menu->delete_unprotected();
  50. $menu->restore();
  51. unset($menu);
  52. //get the menu array and save it to the session
  53. $menu = new menu;
  54. $menu->menu_uuid = $_SESSION['domain']['menu']['uuid'] ?? null;
  55. $_SESSION['menu']['array'] = $menu->menu_array();
  56. unset($menu);
  57. //redirect
  58. if(!defined('STDIN')) {
  59. //show a message to the user
  60. if (empty($included) || !$included) {
  61. message::add($text['message-restore']);
  62. }
  63. header("Location: ".PROJECT_PATH."/core/menu/menu_edit.php?id=".urlencode($menu_uuid));
  64. return;
  65. }
  66. ?>