20181030000001_setting_add_placetel1.rb 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. class SettingAddPlacetel1 < ActiveRecord::Migration[5.1]
  3. def change
  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: 'Placetel integration',
  8. name: 'placetel_integration',
  9. area: 'Integration::Switch',
  10. description: 'Defines if Placetel (http://www.placetel.de) is enabled or not.',
  11. options: {
  12. form: [
  13. {
  14. display: '',
  15. null: true,
  16. name: 'placetel_integration',
  17. tag: 'boolean',
  18. options: {
  19. true => 'yes',
  20. false => 'no',
  21. },
  22. },
  23. ],
  24. },
  25. state: false,
  26. preferences: {
  27. prio: 1,
  28. trigger: ['menu:render', 'cti:reload'],
  29. authentication: true,
  30. permission: ['admin.integration'],
  31. },
  32. frontend: true
  33. )
  34. placetel_config = Setting.find_by(name: 'placetel_config')
  35. if placetel_config
  36. placetel_config.preferences[:cache] = ['placetelGetVoipUsers']
  37. placetel_config.save!
  38. else
  39. Setting.create!(
  40. title: 'Placetel config',
  41. name: 'placetel_config',
  42. area: 'Integration::Placetel',
  43. description: 'Defines the Placetel config.',
  44. options: {},
  45. state: { 'outbound' => { 'routing_table' => [], 'default_caller_id' => '' }, 'inbound' => { 'block_caller_ids' => [] } },
  46. preferences: {
  47. prio: 2,
  48. permission: ['admin.integration'],
  49. cache: ['placetelGetVoipUsers'],
  50. },
  51. frontend: false,
  52. )
  53. end
  54. Setting.create_if_not_exists(
  55. title: 'PLACETEL Token',
  56. name: 'placetel_token',
  57. area: 'Integration::Placetel',
  58. description: 'Token for placetel.',
  59. options: {
  60. form: [
  61. {
  62. display: '',
  63. null: false,
  64. name: 'placetel_token',
  65. tag: 'input',
  66. },
  67. ],
  68. },
  69. state: ENV['PLACETEL_TOKEN'] || SecureRandom.urlsafe_base64(20),
  70. preferences: {
  71. permission: ['admin.integration'],
  72. },
  73. frontend: false
  74. )
  75. end
  76. end