menu_item_move_up.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. //includes files
  22. require_once dirname(__DIR__, 2) . "/resources/require.php";
  23. require_once "resources/check_auth.php";
  24. //check permissions
  25. if (permission_exists('menu_edit')) {
  26. //access granted
  27. }
  28. else {
  29. echo "access denied";
  30. return;
  31. }
  32. //connect to the database
  33. $database = new database;
  34. //add multi-lingual support
  35. $language = new text;
  36. $text = $language->get();
  37. //move down more than one level at a time
  38. //update v_menu_items set menu_order = (menu_order+1) where menu_order > 2 or menu_order = 2
  39. if (count($_GET)>0) {
  40. $menu_item_id = $_GET["menu_item_id"];
  41. $menu_order = $_GET["menu_order"];
  42. if ($menu_order != 1) {
  43. //clear the menu session so it will rebuild with the update
  44. $_SESSION["menu"] = "";
  45. //move the current item's order number down
  46. $sql = "update v_menu_items set ";
  47. $sql .= "menu_order = (menu_order + 1) "; //move down
  48. $sql .= "where domain_uuid = :domain_uuid ";
  49. $sql .= "and menu_order = :menu_order ";
  50. $parameters['domain_uuid'] = $domain_uuid;
  51. $parameters['menu_order'] = $menu_order - 1;
  52. $database->app_name = 'menu';
  53. $database->app_uuid = 'f4b3b3d2-6287-489c-2a00-64529e46f2d7';
  54. $database->execute($sql, $parameters);
  55. unset($sql, $parameters);
  56. //move the selected item's order number up
  57. $sql = "update v_menu_items set ";
  58. $sql .= "menu_order = (menu_order - 1) "; //move up
  59. $sql .= "where domain_uuid = :domain_uuid ";
  60. $sql .= "and menu_item_id = :menu_item_id ";
  61. $parameters['domain_uuid'] = $domain_uuid;
  62. $parameters['menu_item_id'] = $menu_item_id;
  63. $database->app_name = 'menu';
  64. $database->app_uuid = 'f4b3b3d2-6287-489c-2a00-64529e46f2d7';
  65. $database->execute($sql, $parameters);
  66. unset($sql, $parameters);
  67. //set message
  68. message::add($text['message-moved_up']);
  69. }
  70. //redirect the user
  71. header("Location: menu_list.php?menu_item_id=".$menu_item_id);
  72. return;
  73. }
  74. ?>