2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2017-09-08 08:28:34 +00:00
|
|
|
class FormGroupSelection < ActiveRecord::Migration[4.2]
|
2017-06-28 17:19:19 +00:00
|
|
|
def up
|
|
|
|
|
|
|
|
# return if it's a new setup
|
2020-08-03 08:35:43 +00:00
|
|
|
return if !Setting.exists?(name: 'system_init_done')
|
2017-06-28 17:19:19 +00:00
|
|
|
|
|
|
|
group = Group.where(active: true).first
|
|
|
|
if !group
|
|
|
|
group = Group.first
|
|
|
|
end
|
|
|
|
group_id = 1
|
|
|
|
if group
|
|
|
|
group_id = group.id
|
|
|
|
end
|
|
|
|
Setting.create_if_not_exists(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'Group selection for Ticket creation',
|
|
|
|
name: 'form_ticket_create_group_id',
|
|
|
|
area: 'Form::Base',
|
2017-06-28 17:19:19 +00:00
|
|
|
description: 'Defines if group of created tickets via web form.',
|
2018-12-19 17:31:51 +00:00
|
|
|
options: {
|
2017-06-28 17:19:19 +00:00
|
|
|
form: [
|
|
|
|
{
|
2018-12-19 17:31:51 +00:00
|
|
|
display: '',
|
|
|
|
null: true,
|
|
|
|
name: 'form_ticket_create_group_id',
|
|
|
|
tag: 'select',
|
2017-06-28 17:19:19 +00:00
|
|
|
relation: 'Group',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
state: group_id,
|
2017-06-28 17:19:19 +00:00
|
|
|
preferences: {
|
|
|
|
permission: ['admin.channel_formular'],
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
frontend: false,
|
2017-06-28 17:19:19 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
Setting.create_if_not_exists(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'Limit tickets by ip per hour',
|
|
|
|
name: 'form_ticket_create_by_ip_per_hour',
|
|
|
|
area: 'Form::Base',
|
2017-06-28 17:19:19 +00:00
|
|
|
description: 'Defines limit of tickets by ip per hour via web form.',
|
2018-12-19 17:31:51 +00:00
|
|
|
options: {
|
2017-06-28 17:19:19 +00:00
|
|
|
form: [
|
|
|
|
{
|
|
|
|
display: '',
|
2018-12-19 17:31:51 +00:00
|
|
|
null: true,
|
|
|
|
name: 'form_ticket_create_by_ip_per_hour',
|
|
|
|
tag: 'input',
|
2017-06-28 17:19:19 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
state: 20,
|
2017-06-28 17:19:19 +00:00
|
|
|
preferences: {
|
|
|
|
permission: ['admin.channel_formular'],
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
frontend: false,
|
2017-06-28 17:19:19 +00:00
|
|
|
)
|
|
|
|
Setting.create_if_not_exists(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'Limit tickets by ip per day',
|
|
|
|
name: 'form_ticket_create_by_ip_per_day',
|
|
|
|
area: 'Form::Base',
|
2017-06-28 17:19:19 +00:00
|
|
|
description: 'Defines limit of tickets by ip per day via web form.',
|
2018-12-19 17:31:51 +00:00
|
|
|
options: {
|
2017-06-28 17:19:19 +00:00
|
|
|
form: [
|
|
|
|
{
|
|
|
|
display: '',
|
2018-12-19 17:31:51 +00:00
|
|
|
null: true,
|
|
|
|
name: 'form_ticket_create_by_ip_per_day',
|
|
|
|
tag: 'input',
|
2017-06-28 17:19:19 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
state: 240,
|
2017-06-28 17:19:19 +00:00
|
|
|
preferences: {
|
|
|
|
permission: ['admin.channel_formular'],
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
frontend: false,
|
2017-06-28 17:19:19 +00:00
|
|
|
)
|
|
|
|
Setting.create_if_not_exists(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'Limit tickets per day',
|
|
|
|
name: 'form_ticket_create_per_day',
|
|
|
|
area: 'Form::Base',
|
2017-06-28 17:19:19 +00:00
|
|
|
description: 'Defines limit of tickets per day via web form.',
|
2018-12-19 17:31:51 +00:00
|
|
|
options: {
|
2017-06-28 17:19:19 +00:00
|
|
|
form: [
|
|
|
|
{
|
|
|
|
display: '',
|
2018-12-19 17:31:51 +00:00
|
|
|
null: true,
|
|
|
|
name: 'form_ticket_create_per_day',
|
|
|
|
tag: 'input',
|
2017-06-28 17:19:19 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
state: 5000,
|
2017-06-28 17:19:19 +00:00
|
|
|
preferences: {
|
|
|
|
permission: ['admin.channel_formular'],
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
frontend: false,
|
2017-06-28 17:19:19 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|