From 5bbb2492407104d87308aebc728a1e440c962b24 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 17 Jul 2016 00:18:08 +0200 Subject: [PATCH] Added example trigger. Re-assigned ticket_subject_size and ticket_subject_re in admin interface. --- .../20160717000001_update_setting_email.rb | 71 ++++++++++++ db/seeds.rb | 101 +++++++++++------- 2 files changed, 136 insertions(+), 36 deletions(-) create mode 100644 db/migrate/20160717000001_update_setting_email.rb diff --git a/db/migrate/20160717000001_update_setting_email.rb b/db/migrate/20160717000001_update_setting_email.rb new file mode 100644 index 000000000..e6c152160 --- /dev/null +++ b/db/migrate/20160717000001_update_setting_email.rb @@ -0,0 +1,71 @@ +class UpdateSettingEmail < ActiveRecord::Migration + def up + # return if it's a new setup + return if !Setting.find_by(name: 'system_init_done') + + Setting.create_or_update( + title: 'Ticket Subject Size', + name: 'ticket_subject_size', + area: 'Email::Base', + description: 'Max size of the subjects in an email reply.', + options: { + form: [ + { + display: '', + null: false, + name: 'ticket_subject_size', + tag: 'input', + }, + ], + }, + state: '110', + frontend: false + ) + Setting.create_or_update( + title: 'Ticket Subject Reply', + name: 'ticket_subject_re', + area: 'Email::Base', + description: 'The text at the beginning of the subject in an email reply, e.g. RE, AW, or AS.', + options: { + form: [ + { + display: '', + null: true, + name: 'ticket_subject_re', + tag: 'input', + }, + ], + }, + state: 'RE', + frontend: false + ) + + Trigger.create_or_update( + name: 'customer notification (on owner change)', + condition: { + 'ticket.owner_id' => { + 'operator' => 'has changed', + 'pre_condition' => 'current_user.id', + 'value' => '', + 'value_completion' => '', + } + }, + perform: { + 'notification.email' => { + 'body' => '

The owner of ticket (Ticket##{ticket.number}) has changed and is now "#{ticket.owner.firstname} #{ticket.owner.lastname}".

+
+

To provide additional information, please reply to this email or click on the following link: +#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id} +

+
+

Zammad, your customer support system

', + 'recipient' => 'ticket_customer', + 'subject' => 'Owner has changed (#{ticket.title})', + }, + }, + active: false, + created_by_id: 1, + updated_by_id: 1, + ) + end +end diff --git a/db/seeds.rb b/db/seeds.rb index 6de0cebc8..eec1a7cdc 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -825,42 +825,6 @@ Setting.create_if_not_exists( state: 'right', frontend: false ) -Setting.create_if_not_exists( - title: 'Ticket Subject Size', - name: 'ticket_subject_size', - area: 'Ticket::Base', - description: 'Max size of the subjects in an email reply.', - options: { - form: [ - { - display: '', - null: false, - name: 'ticket_subject_size', - tag: 'input', - }, - ], - }, - state: '110', - frontend: false -) -Setting.create_if_not_exists( - title: 'Ticket Subject Reply', - name: 'ticket_subject_re', - area: 'Ticket::Base', - description: 'The text at the beginning of the subject in an email reply, e.g. RE, AW, or AS.', - options: { - form: [ - { - display: '', - null: true, - name: 'ticket_subject_re', - tag: 'input', - }, - ], - }, - state: 'RE', - frontend: false -) Setting.create_if_not_exists( title: 'Ticket Number Format', name: 'ticket_number', @@ -1056,6 +1020,43 @@ Setting.create_if_not_exists( frontend: false, ) +Setting.create_if_not_exists( + title: 'Ticket Subject Size', + name: 'ticket_subject_size', + area: 'Email::Base', + description: 'Max size of the subjects in an email reply.', + options: { + form: [ + { + display: '', + null: false, + name: 'ticket_subject_size', + tag: 'input', + }, + ], + }, + state: '110', + frontend: false +) +Setting.create_if_not_exists( + title: 'Ticket Subject Reply', + name: 'ticket_subject_re', + area: 'Email::Base', + description: 'The text at the beginning of the subject in an email reply, e.g. RE, AW, or AS.', + options: { + form: [ + { + display: '', + null: true, + name: 'ticket_subject_re', + tag: 'input', + }, + ], + }, + state: 'RE', + frontend: false +) + Setting.create_if_not_exists( title: 'Sender Format', name: 'ticket_define_email_from', @@ -4403,6 +4404,34 @@ Trigger.create_or_update( updated_by_id: 1, ) +Trigger.create_or_update( + name: 'customer notification (on owner change)', + condition: { + 'ticket.owner_id' => { + 'operator' => 'has changed', + 'pre_condition' => 'current_user.id', + 'value' => '', + 'value_completion' => '', + } + }, + perform: { + 'notification.email' => { + 'body' => '

The owner of ticket (Ticket##{ticket.number}) has changed and is now "#{ticket.owner.firstname} #{ticket.owner.lastname}".

+
+

To provide additional information, please reply to this email or click on the following link: +#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id} +

+
+

Zammad, your customer support system

', + 'recipient' => 'ticket_customer', + 'subject' => 'Owner has changed (#{ticket.title})', + }, + }, + active: false, + created_by_id: 1, + updated_by_id: 1, +) + # reset primary key sequences if ActiveRecord::Base.connection_config[:adapter] == 'postgresql' ActiveRecord::Base.connection.tables.each do |t|