bulk_account_settings_devices_update.php 3.3 KB

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