You are here

function sendinblue_send_email_form in SendinBlue 7

Same name and namespace in other branches
  1. 7.2 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 98
Sendinblue module home admin settings.

Code

function sendinblue_send_email_form($form, &$form_state) {
  $smtp_details = variable_get(SendinblueManager::SMTP_DETAILS, FALSE);
  if ($smtp_details == FALSE) {
    $smtp_details = SendinblueManager::updateSmtpDetails();
  }
  if ($smtp_details == FALSE || $smtp_details['relay'] == FALSE) {
    variable_set('sendinblue_on', 0);
    $smtp_available = FALSE;
  }
  else {
    $smtp_available = TRUE;
  }
  $form = array();
  if ($smtp_available == FALSE) {
    $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' => variable_get('sendinblue_on', 0),
    '#description' => t('Choose "Yes" if you want to use SendinBlue SMTP to send transactional emails.'),
    '#options' => array(
      1 => t('Yes'),
      0 => t('No'),
    ),
    '#disabled' => $smtp_available == 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' => $smtp_available == 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' => $smtp_available == TRUE ? FALSE : TRUE,
  );
  return $form;
}