You are here

function theme_simplenews_newsletter_confirmation in Simplenews 5

Construct the themable newsletter confirmation email.

1 theme call to theme_simplenews_newsletter_confirmation()
simplenews_mail_confirm in ./simplenews.module
Send confirmation email

File

./simplenews.module, line 2792

Code

function theme_simplenews_newsletter_confirmation($email, $newsletter, $snid, $op, $hash) {
  $mail = new stdClass();
  simplenews_set_from($mail, $newsletter->tid);
  $mail->s_format = 'plain';
  $mail->priority = 'none';
  $mail->to = $email;
  $mail->subject = t('Confirmation for @newsletter from @site', array(
    '@newsletter' => $newsletter->name,
    '@site' => $mail->from_name,
  ));
  $mail->body = t('This is a subscription status confirmation notice for the @newsletter.', array(
    '@newsletter' => $newsletter->name,
  ));
  $mail->body .= "\n\n";
  $user_is_subscribed = simplenews_user_is_subscribed($email, $newsletter->tid);
  switch ($op) {
    case 'subscribe':
      if ($user_is_subscribed) {
        $mail->body .= t('We have received a request for subscription of your e-mail address, @mail, to the @newsletter from @site (@uri). However, you are already subscribed to this newsletter. If you want to unsubscribe, you can visit our website by using the link at the bottom of this e-mail.', array(
          '@mail' => $email,
          '@newsletter' => $newsletter->name,
          '@site' => $mail->from_name,
          '@uri' => url('', NULL, NULL, TRUE),
        ));
      }
      else {
        $mail->body .= t('We have received a request for subscription of your e-mail address, @mail, to the @newsletter from @site (@uri). To confirm that you want to be added to this mailing list, simply visit the confirmation link at the bottom of this e-mail.', array(
          '@mail' => $email,
          '@newsletter' => $newsletter->name,
          '@site' => $mail->from_name,
          '@uri' => url('', NULL, NULL, TRUE),
        ));
        $mail->body .= "\n\n" . t('If you do not wish to be subscribed to this list, please disregard this message.');
        $footer = "\n\n-- \n" . t('Subscribe link: @url', array(
          '@url' => url('newsletter/confirm/add/' . $hash, NULL, NULL, TRUE),
        ));
      }
      break;
    case 'unsubscribe':
      if ($user_is_subscribed) {
        $mail->body .= t('We have received a request for the removal of your e-mail address, @mail, from the @newsletter from @site (@uri). If you want to unsubscribe, simply visit the confirmation link at the bottom of this e-mail.', array(
          '@mail' => $email,
          '@newsletter' => $newsletter->name,
          '@site' => $mail->from_name,
          '@uri' => url('', NULL, NULL, TRUE),
        ));
        $mail->body .= "\n\n" . t('If you did not make this request, please disregard this message.');
        $footer = "\n\n-- \n" . t('Unsubscribe link: @url', array(
          '@url' => url('newsletter/confirm/remove/' . $hash, NULL, NULL, TRUE),
        ));
      }
      else {
        $mail->body .= t('We have received a request for the removal of your e-mail address, @mail, from the @newsletter from @site (@uri). However, you were not subscribed to this newsletter. If you want to subscribe, you can visit our website by using the link at the bottom of this e-mail.', array(
          '@mail' => $email,
          '@newsletter' => $newsletter->name,
          '@site' => $mail->from_name,
          '@uri' => url('', NULL, NULL, TRUE),
        ));
        $mail->body .= "\n\n" . t('If you do not wish to be subscribed to this list, please disregard this message.');
      }
      break;
  }
  if (!isset($footer)) {
    $footer = "\n\n-- \n" . t('Visit our site: @url', array(
      '@url' => url('', NULL, NULL, TRUE),
    ));
  }
  $mail->body .= $footer;
  return $mail;
}