You are here

function sendgrid_integration_admin in SendGrid Integration 7

Same name and namespace in other branches
  1. 6 sendgrid_integration.module \sendgrid_integration_admin()

Provides Settings Form.

1 string reference to 'sendgrid_integration_admin'
sendgrid_integration_menu in ./sendgrid_integration.module
Implements hook_menu().

File

./sendgrid_integration.admin.inc, line 6

Code

function sendgrid_integration_admin() {
  $form = [];
  $form['authentication'] = [
    '#type' => 'fieldset',
    '#title' => t('Authentication'),
  ];
  $requirenewkey = TRUE;
  if (!empty(variable_get('sendgrid_integration_apikey', FALSE))) {
    $form['authentication']['secretkeynotice'] = [
      '#markup' => t('You have saved a secret key. You may change the key by inputing a new one in the field directly below.'),
    ];
    $requirenewkey = FALSE;
  }
  $form['authentication']['sendgrid_integration_apikey'] = [
    '#type' => 'password',
    '#required' => $requirenewkey,
    '#title' => t('API Secret Key'),
    '#description' => t('The secret key of your key pair. These are only generated once by Sendgrid. Your existing key is hidden. If you need to change this, provide a new key here.'),
  ];
  $form['debugging']['maillog'] = [
    '#type' => 'fieldset',
    '#title' => t('Maillog integration'),
  ];
  $form['actions'] = [
    '#type' => 'actions',
  ];
  $form['actions']['submit'] = [
    '#type' => 'submit',
    '#value' => t('Save Settings'),
    '#submit' => [
      'sendgrid_integration_admin_submit',
    ],
    '#validate' => [
      'sendgrid_integration_admin_validate',
    ],
  ];
  if (!module_exists('maillog')) {
    $form['debugging']['maillog']['#description'] = t('Installing the <a href="@url">Maillog module</a> also allows keeping copies of all emails sent through the site.', [
      '@url' => 'https://www.drupal.org/project/maillog',
    ]);
  }
  else {
    $form['debugging']['maillog']['#description'] = t('The <a href="@url">Maillog module</a> is installed, it can also be used to keep copies of all emails sent through the site.', [
      '@url' => url('admin/config/development/maillog'),
    ]);
    $form['debugging']['maillog']['sendgrid_integration_maillog_log'] = [
      '#type' => 'checkbox',
      '#title' => t('Create table entries in maillog table for each e-mail.'),
      '#default_value' => variable_get('sendgrid_integration_maillog_log', TRUE),
    ];
    $form['debugging']['maillog']['sendgrid_integration_maillog_devel'] = [
      '#type' => 'checkbox',
      '#title' => t("Display the e-mails on page using devel module (if enabled)."),
      '#default_value' => variable_get('sendgrid_integration_maillog_devel', TRUE),
      '#disabled' => !module_exists('devel'),
    ];
  }
  return $form;
}