2
0

schema_data_delete.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 "resources/require.php";
  23. require_once "resources/check_auth.php";
  24. if (permission_exists('schema_delete')) {
  25. //access granted
  26. }
  27. else {
  28. echo "access denied";
  29. exit;
  30. }
  31. //add multi-lingual support
  32. $language = new text;
  33. $text = $language->get();
  34. if (count($_GET)>0) {
  35. //declare variable(s)
  36. $schema_parent_id = '';
  37. //get the http get and set them as php variables
  38. $data_row_uuid = check_str($_GET["data_row_uuid"]);
  39. $data_parent_row_uuid = check_str($_GET["data_parent_row_uuid"]);
  40. $schema_uuid = check_str($_GET["schema_uuid"]);
  41. //show the results and redirect
  42. require_once "resources/header.php";
  43. //get the schema_parent_id from the child table
  44. if (strlen($schema_parent_id) == 0) {
  45. $sql = "select * from v_schemas ";
  46. $sql .= "where domain_uuid = '$domain_uuid' ";
  47. $sql .= "and schema_uuid = '$schema_uuid' ";
  48. $prep_statement = $db->prepare($sql);
  49. $prep_statement->execute();
  50. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  51. foreach ($result as &$row) {
  52. $schema_parent_id = $row["schema_parent_id"];
  53. }
  54. }
  55. //delete the child data
  56. $sql = "delete from v_schema_data ";
  57. $sql .= "where domain_uuid = '$domain_uuid' ";
  58. $sql .= "and data_parent_row_uuid = '$data_row_uuid' ";
  59. $db->exec(check_sql($sql));
  60. unset($sql);
  61. //delete the data
  62. $sql = "delete from v_schema_data ";
  63. $sql .= "where domain_uuid = '$domain_uuid' ";
  64. $sql .= "and data_row_uuid = '$data_row_uuid' ";
  65. $db->exec(check_sql($sql));
  66. unset($sql);
  67. //mark the the item as deleted and who deleted it
  68. //$sql = "update v_schema_data set ";
  69. //$sql .= "data_del_date = now(), ";
  70. //$sql .= "data_del_user = '".$_SESSION["username"]."' ";
  71. //$sql .= "where domain_uuid = '$domain_uuid' ";
  72. //$sql .= "and data_row_uuid = '$data_row_uuid' ";
  73. //$db->exec(check_sql($sql));
  74. //$lastinsertid = $db->lastInsertId($id);
  75. //unset($sql);
  76. //redirect user
  77. $_SESSION["message"] = $text['message-delete'];
  78. if (strlen($data_parent_row_uuid) == 0) {
  79. header("Location: schema_data_view.php?id=".$schema_uuid."&data_row_uuid=".$data_row_uuid);
  80. }
  81. else {
  82. header("Location: schema_data_edit.php?schema_uuid=".$schema_parent_id."&data_row_uuid=".$data_parent_row_uuid);
  83. }
  84. return;
  85. }
  86. ?>