contact_delete.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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-2015
  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('contact_delete')) {
  25. //access granted
  26. }
  27. else {
  28. echo "access denied";
  29. exit;
  30. }
  31. // check if included in another file
  32. if (!$included) {
  33. //add multi-lingual support
  34. $language = new text;
  35. $text = $language->get();
  36. $contact_uuid = $_GET["id"];
  37. }
  38. if (is_uuid($contact_uuid)) {
  39. //specify tables
  40. $tables[] = 'contact_addresses';
  41. $tables[] = 'contact_attachments';
  42. $tables[] = 'contact_emails';
  43. $tables[] = 'contact_groups';
  44. $tables[] = 'contact_notes';
  45. $tables[] = 'contact_phones';
  46. $tables[] = 'contact_relations';
  47. $tables[] = 'contact_settings';
  48. $tables[] = 'contact_times';
  49. $tables[] = 'contact_urls';
  50. $tables[] = 'contact_users';
  51. $tables[] = 'contacts';
  52. //create array from tables
  53. foreach ($tables as $table) {
  54. $array[$table][0]['contact_uuid'] = $contact_uuid;
  55. $array[$table][0]['domain_uuid'] = $_SESSION['domain_uuid'];
  56. }
  57. //include reciprocal relationships
  58. $array['contact_relations'][1]['relation_contact_uuid'] = $contact_uuid;
  59. $array['contact_relations'][1]['domain_uuid'] = $_SESSION['domain_uuid'];
  60. //grant temp permissions
  61. $p = new permissions;
  62. $database = new database;
  63. foreach ($tables as $table) {
  64. $p->add($database->singular($table).'_delete', 'temp');
  65. }
  66. //execute
  67. $database = new database;
  68. $database->app_name = 'contacts';
  69. $database->app_uuid = '04481e0e-a478-c559-adad-52bd4174574c';
  70. $database->delete($array);
  71. unset($array);
  72. //revoke temp permissions
  73. foreach ($tables as $table) {
  74. $p->delete($database->singular($table).'_delete', 'temp');
  75. }
  76. //set message
  77. message::add($text['message-delete']);
  78. }
  79. if (!$included) {
  80. header("Location: contacts.php");
  81. exit;
  82. }
  83. ?>