20170727000001_setting_proxy.rb 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. class SettingProxy < ActiveRecord::Migration[4.2]
  3. def up
  4. # return if it's a new setup
  5. return if !Setting.exists?(name: 'system_init_done')
  6. Setting.create_if_not_exists(
  7. title: 'Proxy Settings',
  8. name: 'proxy',
  9. area: 'System::Network',
  10. description: 'Address of the proxy server for http and https resources.',
  11. options: {
  12. form: [
  13. {
  14. display: '',
  15. null: false,
  16. name: 'proxy',
  17. tag: 'input',
  18. placeholder: 'proxy.example.com:3128',
  19. },
  20. ],
  21. },
  22. state: '',
  23. preferences: {
  24. online_service_disable: true,
  25. controller: 'SettingsAreaProxy',
  26. prio: 1,
  27. permission: ['admin.system'],
  28. },
  29. frontend: false
  30. )
  31. Setting.create_if_not_exists(
  32. title: 'Proxy User',
  33. name: 'proxy_username',
  34. area: 'System::Network',
  35. description: 'Username for proxy connection.',
  36. options: {
  37. form: [
  38. {
  39. display: '',
  40. null: false,
  41. name: 'proxy_username',
  42. tag: 'input',
  43. },
  44. ],
  45. },
  46. state: '',
  47. preferences: {
  48. disabled: true,
  49. online_service_disable: true,
  50. prio: 2,
  51. permission: ['admin.system'],
  52. },
  53. frontend: false
  54. )
  55. # fix typo
  56. setting = Setting.find_by(name: 'proxy_password')
  57. if setting
  58. setting.options[:form][0][:name] = 'proxy_password'
  59. setting.save!
  60. else
  61. Setting.create_if_not_exists(
  62. title: 'Proxy Password',
  63. name: 'proxy_password',
  64. area: 'System::Network',
  65. description: 'Password for proxy connection.',
  66. options: {
  67. form: [
  68. {
  69. display: '',
  70. null: false,
  71. name: 'proxy_password',
  72. tag: 'input',
  73. },
  74. ],
  75. },
  76. state: '',
  77. preferences: {
  78. disabled: true,
  79. online_service_disable: true,
  80. prio: 3,
  81. permission: ['admin.system'],
  82. },
  83. frontend: false
  84. )
  85. end
  86. Setting.create_if_not_exists(
  87. title: 'No Proxy',
  88. name: 'proxy_no',
  89. area: 'System::Network',
  90. description: 'No proxy for the following hosts.',
  91. options: {
  92. form: [
  93. {
  94. display: '',
  95. null: false,
  96. name: 'proxy_no',
  97. tag: 'input',
  98. },
  99. ],
  100. },
  101. state: 'localhost,127.0.0.0,::1',
  102. preferences: {
  103. disabled: true,
  104. online_service_disable: true,
  105. prio: 4,
  106. permission: ['admin.system'],
  107. },
  108. frontend: false
  109. )
  110. end
  111. end