You are here

protected function SimplenewsSourceNode::setContext in Simplenews 7

Set up the necessary language and user context.

2 calls to SimplenewsSourceNode::setContext()
SimplenewsSourceNode::getBodyWithFormat in includes/simplenews.source.inc
Get the body with the requested format.
SimplenewsSourceNode::getFooterWithFormat in includes/simplenews.source.inc
Get the footer in the specified format.

File

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

Class

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

Code

protected function setContext() {

  // Switch to the user
  if ($this->uid = $this
    ->getSubscriber()->uid) {
    simplenews_impersonate_user($this->uid);
  }

  // Change language if the requested language is enabled.
  $language = $this
    ->getLanguage();
  $languages = language_list();
  if (isset($languages[$language])) {
    $this->original_language = $GLOBALS['language'];
    $GLOBALS['language'] = $languages[$language];
    $GLOBALS['language_url'] = $languages[$language];

    // Overwrites the current content language for i18n_select.
    if (module_exists('i18n_select')) {
      $GLOBALS['language_content'] = $languages[$language];
    }
  }
}