apps_delete.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. require_once "root.php";
  22. require_once "includes/require.php";
  23. require_once "includes/checkauth.php";
  24. if (if_group("superadmin")) {
  25. //access granted
  26. }
  27. else {
  28. echo "access denied";
  29. exit;
  30. }
  31. if (count($_GET) > 0) {
  32. $id = check_str($_GET["id"]);
  33. }
  34. if (strlen($id)>0) {
  35. if (count($_GET)>0 && $_POST["persistformvar"] != "true") {
  36. $app_uuid = $_GET["id"];
  37. //get the list of installed apps from the core and mod directories
  38. $config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
  39. $x=0;
  40. foreach ($config_list as $config_path) {
  41. include($config_path);
  42. $x++;
  43. }
  44. //find the app using the $app_uuid
  45. foreach ($apps as &$row) {
  46. if ($row["uuid"] == $app_uuid) {
  47. $name = $row['name'];
  48. if ($row["uuid"] == $app_uuid && $row['category'] != "Core") {
  49. //delete the app from the menu
  50. foreach ($row['menu'] as &$menu) {
  51. //delete menu groups and permissions from the database
  52. $sql = "delete from v_menu_item_groups ";
  53. $sql .= "where menu_item_uuid = '".$menu['uuid']."' ";
  54. $db->query($sql);
  55. $sql = "delete from v_menu_items ";
  56. $sql .= "where menu_item_uuid = '".$menu['uuid']."' ";
  57. $db->query($sql);
  58. //delete the app from the file system
  59. if (strlen($menu['path']) > 0) {
  60. system('rm -rf '.dirname($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.$menu['path']));
  61. }
  62. }
  63. //delete the group permissions for the app
  64. foreach ($row['permissions'] as &$permission) {
  65. $sql = "delete from v_group_permissions ";
  66. $sql .= "where permission_name = '".$permission['name']."' ";
  67. $db->query($sql);
  68. }
  69. }
  70. }
  71. }
  72. }
  73. }
  74. //redirect the browser
  75. require_once "includes/header.php";
  76. echo "<meta http-equiv=\"refresh\" content=\"2;url=apps.php\">\n";
  77. echo "<div align='center'>\n";
  78. echo "Delete Complete\n";
  79. echo "</div>\n";
  80. require_once "includes/footer.php";
  81. return;
  82. ?>