You are here

function SimplenewsSourceNode::getSubject in Simplenews 7

Implements SimplenewsSourceInterface::getSubject().

Overrides SimplenewsSourceInterface::getSubject

File

includes/simplenews.source.inc, line 588
Contains SimplenewsSource interface and implementations.

Class

SimplenewsSourceNode
Simplenews source implementation based on nodes for a single subscriber.

Code

function getSubject() {

  // Build email subject and perform some sanitizing.
  $langcode = $this
    ->getLanguage();
  $language_list = language_list();

  // Use the requested language if enabled.
  $language = isset($language_list[$langcode]) ? $language_list[$langcode] : NULL;
  $subject = token_replace($this
    ->getCategory()->email_subject, $this
    ->getTokenContext(), array(
    'sanitize' => FALSE,
    'language' => $language,
  ));

  // Line breaks are removed from the email subject to prevent injection of
  // malicious data into the email header.
  $subject = str_replace(array(
    "\r",
    "\n",
  ), '', $subject);
  return $subject;
}