hunt_group_copy.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. include "root.php";
  22. require_once "resources/require.php";
  23. require_once "resources/check_auth.php";
  24. require_once "resources/paging.php";
  25. //check permissions
  26. if (permission_exists('hunt_group_add')) {
  27. //access granted
  28. }
  29. else {
  30. echo "access denied";
  31. exit;
  32. }
  33. //add multi-lingual support
  34. $language = new text;
  35. $text = $language->get();
  36. //set the http get/post variable(s) to a php variable
  37. if (isset($_REQUEST["id"])) {
  38. $hunt_group_uuid = check_str($_REQUEST["id"]);
  39. $hunt_group_extension_new = check_str($_REQUEST["ext"]);
  40. }
  41. //get the v_hunt_group data
  42. $sql = "select * from v_hunt_groups ";
  43. $sql .= "where hunt_group_uuid = '$hunt_group_uuid' ";
  44. $sql .= "and domain_uuid = '$domain_uuid' ";
  45. $prep_statement = $db->prepare(check_sql($sql));
  46. $prep_statement->execute();
  47. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  48. foreach ($result as &$row) {
  49. $hunt_group_extension = $row["hunt_group_extension"];
  50. $hunt_group_name = $row["hunt_group_name"]."_copy";
  51. $hunt_group_type = $row["hunt_group_type"];
  52. $hunt_group_context = $row["hunt_group_context"];
  53. $hunt_group_timeout = $row["hunt_group_timeout"];
  54. $hunt_group_timeout_destination = $row["hunt_group_timeout_destination"];
  55. $hunt_group_timeout_type = $row["hunt_group_timeout_type"];
  56. $hunt_group_ringback = $row["hunt_group_ringback"];
  57. $hunt_group_cid_name_prefix = $row["hunt_group_cid_name_prefix"];
  58. $hunt_group_pin = $row["hunt_group_pin"];
  59. $hunt_group_caller_announce = $row["hunt_group_caller_announce"];
  60. $hunt_group_user_list = $row["hunt_group_user_list"];
  61. $hunt_group_enabled = $row["hunt_group_enabled"];
  62. $hunt_group_description = "copy: ".$row["hunt_group_description"];
  63. break; //limit to 1 row
  64. }
  65. unset ($prep_statement);
  66. //copy the hunt group
  67. $hunt_group_uuid_new = uuid();
  68. $sql = "insert into v_hunt_groups ";
  69. $sql .= "(";
  70. $sql .= "hunt_group_uuid, ";
  71. $sql .= "domain_uuid, ";
  72. $sql .= "hunt_group_extension, ";
  73. $sql .= "hunt_group_name, ";
  74. $sql .= "hunt_group_type, ";
  75. $sql .= "hunt_group_context, ";
  76. $sql .= "hunt_group_timeout, ";
  77. $sql .= "hunt_group_timeout_destination, ";
  78. $sql .= "hunt_group_timeout_type, ";
  79. $sql .= "hunt_group_ringback, ";
  80. $sql .= "hunt_group_cid_name_prefix, ";
  81. $sql .= "hunt_group_pin, ";
  82. $sql .= "hunt_group_caller_announce, ";
  83. $sql .= "hunt_group_user_list, ";
  84. $sql .= "hunt_group_enabled, ";
  85. $sql .= "hunt_group_description ";
  86. $sql .= ")";
  87. $sql .= "values ";
  88. $sql .= "(";
  89. $sql .= "'$hunt_group_uuid_new', ";
  90. $sql .= "'$domain_uuid', ";
  91. $sql .= "'$hunt_group_extension_new', ";
  92. $sql .= "'$hunt_group_name', ";
  93. $sql .= "'$hunt_group_type', ";
  94. $sql .= "'$hunt_group_context', ";
  95. $sql .= "'$hunt_group_timeout', ";
  96. $sql .= "'$hunt_group_timeout_destination', ";
  97. $sql .= "'$hunt_group_timeout_type', ";
  98. $sql .= "'$hunt_group_ringback', ";
  99. $sql .= "'$hunt_group_cid_name_prefix', ";
  100. $sql .= "'$hunt_group_pin', ";
  101. $sql .= "'$hunt_group_caller_announce', ";
  102. $sql .= "'$hunt_group_user_list', ";
  103. $sql .= "'$hunt_group_enabled', ";
  104. $sql .= "'$hunt_group_description' ";
  105. $sql .= ")";
  106. $db->exec(check_sql($sql));
  107. unset($sql);
  108. //get the the hunt group destinations
  109. $sql = "select * from v_hunt_group_destinations ";
  110. $sql .= "where domain_uuid = '$domain_uuid' ";
  111. $sql .= "and hunt_group_uuid = '$hunt_group_uuid' ";
  112. $prep_statement = $db->prepare(check_sql($sql));
  113. $prep_statement->execute();
  114. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  115. foreach ($result as &$row) {
  116. $destination_data = $row["destination_data"];
  117. $destination_type = $row["destination_type"];
  118. $destination_profile = $row["destination_profile"];
  119. $destination_timeout = $row["destination_timeout"];
  120. $destination_order = $row["destination_order"];
  121. $destination_enabled = $row["destination_enabled"];
  122. $destination_description = $row["destination_description"];
  123. //copy the hunt group destinations
  124. $hunt_group_destination_uuid = uuid();
  125. $sql = "insert into v_hunt_group_destinations ";
  126. $sql .= "(";
  127. $sql .= "domain_uuid, ";
  128. $sql .= "hunt_group_uuid, ";
  129. $sql .= "hunt_group_destination_uuid, ";
  130. $sql .= "destination_data, ";
  131. $sql .= "destination_type, ";
  132. $sql .= "destination_profile, ";
  133. $sql .= "destination_timeout, ";
  134. $sql .= "destination_order, ";
  135. $sql .= "destination_enabled, ";
  136. $sql .= "destination_description ";
  137. $sql .= ")";
  138. $sql .= "values ";
  139. $sql .= "(";
  140. $sql .= "'$domain_uuid', ";
  141. $sql .= "'$hunt_group_uuid_new', ";
  142. $sql .= "'$hunt_group_destination_uuid', ";
  143. $sql .= "'$destination_data', ";
  144. $sql .= "'$destination_type', ";
  145. $sql .= "'$destination_profile', ";
  146. $sql .= "'$destination_timeout', ";
  147. $sql .= "'$destination_order', ";
  148. $sql .= "'$destination_enabled', ";
  149. $sql .= "'$destination_description' ";
  150. $sql .= ")";
  151. $db->exec(check_sql($sql));
  152. //echo $sql."<br><br>";
  153. //exit();
  154. unset($sql);
  155. }
  156. unset ($prep_statement);
  157. //synchronize the xml config
  158. save_hunt_group_xml();
  159. //redirect the user
  160. require_once "resources/header.php";
  161. echo "<meta http-equiv=\"refresh\" content=\"2;url=hunt_groups.php\">\n";
  162. echo "<div align='center'>\n";
  163. echo $text['message-copy']."\n";
  164. echo "</div>\n";
  165. require_once "resources/footer.php";
  166. return;
  167. ?>