You are here

function sendinblue_send_email_form in SendinBlue 7.2

Same name and namespace in other branches
  1. 7 includes/sendinblue_home.admin.inc \sendinblue_send_email_form()

Form to send email of Home page.

1 string reference to 'sendinblue_send_email_form'
SendinblueManager::generateHomeLogin in includes/sendinblue.manage.inc
Generate Home layout of Log out.

File

includes/sendinblue_home.admin.inc, line 110
Sendinblue module home admin settings.

Code

function sendinblue_send_email_form($form, &$form_state) {
  $sendInBlueConfigFactory = new SendInBlueConfigFactory();
  $smtpDetails = $sendInBlueConfigFactory
    ->getSmtpDetails();
  $smtpAvailable = $smtpDetails !== NULL;
  $sendInBlueTransacEmailOn = $sendInBlueConfigFactory
    ->getSendInBlueOn();
  $form = array();
  if (!$smtpAvailable) {
    $form['sendinblue_alert'] = array(
      '#type' => 'markup',
      '#prefix' => '<div id="sendinblue_alert_area" style="padding: 10px;background-color: #fef5f1;color: #8c2e0b;border-color: #ed541d;border-width: 1px;border-style: solid;">',
      '#markup' => t('Current you can not use SendinBlue SMTP. Please confirm at <a href="@smtp-sendinblue" target="_blank">Here</a>', array(
        '@smtp-sendinblue' => 'https://mysmtp.sendinblue.com/?utm_source=drupal_plugin&utm_medium=plugin&utm_campaign=module_link',
      )),
      '#suffix' => '</div>',
      '#tree' => TRUE,
    );
  }
  $form['sendinblue_on'] = array(
    '#type' => 'radios',
    '#title' => t('Send emails through SendinBlue SMTP'),
    '#default_value' => $sendInBlueTransacEmailOn,
    '#description' => t('Choose "Yes" if you want to use SendinBlue SMTP to send transactional emails.'),
    '#options' => array(
      1 => t('Yes'),
      0 => t('No'),
    ),
    '#disabled' => $smtpAvailable === TRUE ? FALSE : TRUE,
  );
  $form['sendinblue_to_email'] = array(
    '#type' => 'textfield',
    '#title' => t('Enter email to send a test'),
    '#description' => t('Select here the email address you want to send a test email to.'),
    '#disabled' => $smtpAvailable === TRUE ? FALSE : TRUE,
    '#states' => array(
      // Hide unless needed.
      'visible' => array(
        ':input[name="sendinblue_on"]' => array(
          'value' => 1,
        ),
      ),
      'required' => array(
        ':input[name="sendinblue_on"]' => array(
          'value' => 1,
        ),
      ),
    ),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save Settings'),
    '#disabled' => $smtpAvailable === TRUE ? FALSE : TRUE,
  );
  return $form;
}