class UpdateSettings4 < ActiveRecord::Migration
  def up
    Setting.create_or_update(
      title: 'Authentication via Twitter',
      name: 'auth_twitter',
      area: 'Security::ThirdPartyAuthentication',
      description: "@T('Enables user authentication via twitter. Register your app first at [Twitter Developer Site](https://dev.twitter.com/apps)')",
      options: {
        form: [
          {
            display: '',
            null: true,
            name: 'auth_twitter',
            tag: 'boolean',
            options: {
              true  => 'yes',
              false => 'no',
            },
          },
        ],
      },
      state: false,
      frontend: true
    )
    Setting.create_or_update(
      title: 'Authentication via Facebook',
      name: 'auth_facebook',
      area: 'Security::ThirdPartyAuthentication',
      description: "@T('Enables user authentication via Facebook. Register your app first at [Facebook Developer Site](https://developers.facebook.com/apps/)')",
      options: {
        form: [
          {
            display: '',
            null: true,
            name: 'auth_facebook',
            tag: 'boolean',
            options: {
              true  => 'yes',
              false => 'no',
            },
          },
        ],
      },
      state: false,
      frontend: true
    )
    Setting.create_or_update(
      title: 'Ticket Hook Position',
      name: 'ticket_hook_position',
      area: 'Ticket::Base',
      description: "@T('The format of the subject.')
    * @T('**Right** means **Some Subject [Ticket#12345]**')
    * @T('**Left** means **[Ticket#12345] Some Subject**')
    * @T('**None** means **Some Subject** (without ticket number). In the last case you should enable *postmaster_follow_up_search_in* to recognize followups based on email headers and/or body.')",
      options: {
        form: [
          {
            display: '',
            null: true,
            name: 'ticket_hook_position',
            tag: 'select',
            options: {
              'left'  => 'Left',
              'right' => 'Right',
              'none'  => 'None',
            },
          },
        ],
      },
      state: 'right',
      frontend: false
    )
    Setting.create_or_update(
      title: 'Ticket Number Format',
      name: 'ticket_number',
      area: 'Ticket::Number',
      description: "@T('Selects the ticket number generator module.')
    * @T('**Increment** increments the ticket number, the SystemID and the counter are used with SystemID.Counter format (e.g. 1010138, 1010139).')
    * @T('With **Date** the ticket numbers will be generated by the current date, the SystemID and the counter. The format looks like Year.Month.Day.SystemID.counter (e.g. 201206231010138, 201206231010139).')

    @T('With param 'Checksum => true' the counter will be appended as checksum to the string. The format looks like SystemID.Counter.CheckSum (e. g. 10101384, 10101392) or Year.Month.Day.SystemID.Counter.CheckSum (e.g. 2012070110101520, 2012070110101535).')",
      options: {
        form: [
          {
            display: '',
            null: true,
            name: 'ticket_number',
            tag: 'select',
            options: {
              'Ticket::Number::Increment' => 'Increment (SystemID.Counter)',
              'Ticket::Number::Date'      => 'Date (Year.Month.Day.SystemID.Counter)',
            },
          },
        ],
      },
      state: 'Ticket::Number::Increment',
      frontend: false
    )
    Setting.create_or_update(
      title: 'Additional follow up detection',
      name: 'postmaster_follow_up_search_in',
      area: 'Email::Base',
      description: 'In default the follow up check is done via the subject of an email. With this setting you can add more fields where the follow up ckeck is executed.',
      options: {
        form: [
          {
            display: '',
            null: true,
            name: 'postmaster_follow_up_search_in',
            tag: 'checkbox',
            options: {
              'references' => 'References - Search for follow up also in In-Reply-To or References headers.',
              'body'       => 'Body - Search for follow up also in mail body.',
              'attachment' => 'Attachment - Search for follow up also in attachments.',
            },
          },
        ],
      },
      state: [],
      frontend: false
    )
  end
end
