/**
  * Replaces markers in newsletter content
  * @param string $content
  * @param CjwNewsletterEditionSend $newsletterEditionSend
  * @param CjwNewsletterUser $newsletterUser
  * @return string
  */
 static function replaceNewsletterMarkers($content, CjwNewsletterEditionSend $newsletterEditionSend, CjwNewsletterUser $newsletterUser = null)
 {
     // TODO parse extra variables
     $editionSendHash = $newsletterEditionSend->attribute('hash');
     $searchArray = array('#_hash_editionsend_#');
     $replaceArray = array($editionSendHash);
     if ($newsletterUser) {
         $subscription = CjwNewsletterSubscription::fetchByListIdAndNewsletterUserId($newsletterEditionSend->attribute('list_contentobject_id'), $newsletterUser->attribute('id'));
         $newsletterUnsubscribeHash = $subscription->attribute('hash');
         $newsletterConfigureHash = $newsletterUser->attribute('hash');
         $personalizeContent = (int) $newsletterEditionSend->attribute('personalize_content');
         $searchArray = array_merge($searchArray, array('#_hash_unsubscribe_#', '#_hash_configure_#'));
         $replaceArray = array_merge($replaceArray, array($newsletterUnsubscribeHash, $newsletterConfigureHash));
         if ($personalizeContent === 1) {
             $searchArray = array_merge($searchArray, array('[[name]]', '[[salutation_name]]', '[[first_name]]', '[[last_name]]'));
             $replaceArray = array_merge($replaceArray, array($newsletterUser->attribute('name'), $newsletterUser->attribute('salutation_name'), $newsletterUser->attribute('first_name'), $newsletterUser->attribute('last_name')));
         }
     }
     return str_replace($searchArray, $replaceArray, $content);
 }
 /**
  * used by Newletter edition preview and newsletter cronjob process
  *
  * @param CjwNewsletterUser $newsletterUser
  * @return boolean
  */
 public function setExtraMailHeadersByNewsletterUser($newsletterUser)
 {
     if ($newsletterUser instanceof CjwNewsletterUser) {
         $this->setExtraMailHeader('receiver', $newsletterUser->attribute('email'));
         $this->setExtraMailHeader('user', $newsletterUser->attribute('hash'));
     } else {
         return false;
     }
 }