ring_group_extensions.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 "resources/require.php";
  23. require_once "resources/check_auth.php";
  24. if (permission_exists('voicemail_view')) {
  25. //access granted
  26. }
  27. else {
  28. echo "access denied";
  29. exit;
  30. }
  31. //get the includes
  32. require "resources/require.php";
  33. require_once "resources/header.php";
  34. echo "<pre>\n";
  35. //start the atomic transaction
  36. $db->exec("BEGIN;");
  37. //ring group export
  38. echo "<pre>\n";
  39. $sql = "SELECT g.domain_uuid, g.ring_group_extension_uuid, g.ring_group_uuid, g.extension_delay, g.extension_timeout, e.extension, e.extension_uuid ";
  40. $sql .= "FROM v_ring_groups as r, v_ring_group_extensions as g, v_extensions as e ";
  41. $sql .= "where g.ring_group_uuid = r.ring_group_uuid ";
  42. $sql .= "and e.extension_uuid = g.extension_uuid ";
  43. $sql .= "order by g.extension_delay asc, e.extension asc ";
  44. $prep_statement = $db->prepare(check_sql($sql));
  45. $prep_statement->execute();
  46. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  47. $result_count = count($result);
  48. foreach($result as $field) {
  49. if (strlen($field['extension_delay']) == 0) { $field['extension_delay'] = "0"; }
  50. if (strlen($field['extension_timeout']) == 0) { $field['extension_timeout'] = "30"; }
  51. $ring_group_uuid = $field['ring_group_uuid'];
  52. $ring_group_destination_uuid = $field['ring_group_extension_uuid'];
  53. $destination_number = $field['extension'];
  54. $destination_delay = $field['extension_delay'];
  55. $destination_timeout = $field['extension_timeout'];
  56. $sql = "insert into v_ring_group_destinations ";
  57. $sql .= "(";
  58. $sql .= "domain_uuid, ";
  59. $sql .= "ring_group_uuid, ";
  60. $sql .= "ring_group_destination_uuid, ";
  61. $sql .= "destination_delay, ";
  62. $sql .= "destination_timeout, ";
  63. $sql .= "destination_number ";
  64. $sql .= ") ";
  65. $sql .= "values ";
  66. $sql .= "(";
  67. $sql .= "'".$field['domain_uuid']."', ";
  68. $sql .= "'$ring_group_uuid', ";
  69. $sql .= "'$ring_group_destination_uuid', ";
  70. $sql .= "'$destination_delay', ";
  71. $sql .= "'$destination_timeout', ";
  72. $sql .= "'$destination_number' ";
  73. $sql .= ");";
  74. $db->exec(check_sql($sql));
  75. echo $sql."\n";
  76. unset($sql);
  77. }
  78. echo "completed";
  79. echo "<pre>\n";
  80. //commit the atomic transaction
  81. $count = $db->exec("COMMIT;"); //returns affected rows
  82. //show the footer
  83. echo "</pre>\n";
  84. require_once "resources/footer.php";
  85. ?>