bulk_account_settings_devices_update.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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-2016
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. KonradSC <[email protected]>
  20. */
  21. //set the include path
  22. $conf = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE);
  23. set_include_path(parse_ini_file($conf[0])['document.root']);
  24. //includes files
  25. require_once "resources/require.php";
  26. require_once "resources/check_auth.php";
  27. //check permissions
  28. if (permission_exists('bulk_account_settings_devices')) {
  29. //access granted
  30. }
  31. else {
  32. echo "access denied";
  33. exit;
  34. }
  35. //add multi-lingual support
  36. $language = new text;
  37. $text = $language->get();
  38. //check for the ids
  39. if (is_array($_REQUEST) && sizeof($_REQUEST) > 0) {
  40. $device_uuids = $_REQUEST["id"];
  41. $option_selected = $_REQUEST["option_selected"];
  42. $new_setting = $_REQUEST["new_setting"];
  43. foreach($device_uuids as $device_uuid) {
  44. $device_uuid = check_str($device_uuid);
  45. if ($device_uuid != '') {
  46. //line settings
  47. if (preg_match ('/line/', $option_selected)) {
  48. preg_match ('/line_(.)/', $option_selected, $matches);
  49. $line_number = $matches[1];
  50. $matches = null;
  51. preg_match ('/line_._(.*$)/', $option_selected, $matches);
  52. $option_line = $matches[1];
  53. $sql = "select * from v_device_lines ";
  54. $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
  55. $sql .= "and device_uuid = '".$device_uuid."' ";
  56. $sql .= "and line_number = '".$line_number."' ";
  57. $database = new database;
  58. $devices = $database->select($sql, 'all');
  59. if (is_array($devices)) {
  60. foreach ($devices as &$row) {
  61. $device_line_uuid = $row["device_line_uuid"];
  62. }
  63. unset ($prep_statement);
  64. }
  65. $array["device_lines"][$i]["device_line_uuid"] = $device_line_uuid;
  66. $array["device_lines"][$i][$option_line] = $new_setting;
  67. $array["device_lines"][$i]["domain_uuid"] = $domain_uuid;
  68. $array["device_lines"][$i]["device_uuid"] = $device_uuid;
  69. $database = new database;
  70. $database->app_name = 'bulk_account_settings';
  71. $database->app_uuid = null;
  72. $database->save($array);
  73. $message = $database->message;
  74. unset($database,$array,$i);
  75. }
  76. //other device settings
  77. else {
  78. $array["devices"][$i]["domain_uuid"] = $domain_uuid;
  79. $array["devices"][$i]["device_uuid"] = $device_uuid;
  80. $array["devices"][$i][$option_selected] = $new_setting;
  81. $database = new database;
  82. $database->app_name = 'bulk_account_settings';
  83. $database->app_uuid = null;
  84. $database->save($array);
  85. $message = $database->message;
  86. //echo "<pre>".print_r($message, true)."<pre>\n";
  87. //exit;
  88. unset($database,$array,$i);
  89. }
  90. }
  91. }
  92. }
  93. //redirect the browser
  94. $_SESSION["message"] = $text['message-update'];
  95. header("Location: bulk_account_settings_devices.php?option_selected=".$option_selected."");
  96. return;
  97. ?>