Esempio n. 1
0
 private function getLinkAuthCode(Email $email, $url, $isPreview, $isPlainText = false)
 {
     global $TYPO3_DB;
     $url = html_entity_decode($url);
     // First check in our local cache
     if (isset($this->linksCache[$url])) {
         $linkId = $this->linksCache[$url];
     } elseif ($isPreview) {
         $linkId = count($this->linksCache);
     } else {
         // Look for the link database, it may already exist
         $res = $TYPO3_DB->sql_query('SELECT uid FROM tx_newsletter_domain_model_link WHERE url = ' . $TYPO3_DB->fullQuoteStr($url, 'tx_newsletter_domain_model_link') . ' AND newsletter = ' . $TYPO3_DB->fullQuoteStr($this->newsletter->getUid(), 'tx_newsletter_domain_model_link') . ' LIMIT 1');
         $row = $TYPO3_DB->sql_fetch_row($res);
         if ($row) {
             $linkId = $row[0];
         } else {
             $TYPO3_DB->exec_INSERTquery('tx_newsletter_domain_model_link', array('pid' => $this->newsletter->getPid(), 'url' => $url, 'newsletter' => $this->newsletter->getUid()));
             $linkId = $TYPO3_DB->sql_insert_id();
         }
     }
     // Store link in cache
     $this->linksCache[$url] = $linkId;
     $authCode = md5($email->getAuthCode() . $linkId);
     $newUrl = Tools::buildFrontendUri('clicked', array(), 'Link') . '&n=' . $this->newsletter->getUid() . '&l=' . $authCode . ($isPlainText ? '&p=1' : '');
     return $newUrl;
 }
Esempio n. 2
0
 /**
  * Sends an email to the address configured in extension settings when a recipient unsubscribe
  * @param \Ecodev\Newsletter\Domain\Model\Newsletter $newsletter
  * @param \Ecodev\Newsletter\Domain\Model\RecipientList $recipientList
  * @param \Ecodev\Newsletter\Domain\Model\Email $email
  * @return void
  */
 protected function notifyUnsubscribe($newsletter, $recipientList, Email $email)
 {
     $notificationEmail = Tools::confParam('notification_email');
     // Use the page-owner as user
     if ($notificationEmail == 'user') {
         $rs = $GLOBALS['TYPO3_DB']->sql_query("SELECT email\n\t\t\tFROM be_users\n\t\t\tLEFT JOIN pages ON be_users.uid = pages.perms_userid\n\t\t\tWHERE pages.uid = " . $newsletter->getPid());
         list($notificationEmail) = $GLOBALS['TYPO3_DB']->sql_fetch_row($rs);
     }
     // If cannot find valid email, don't send any notification
     if (!\TYPO3\CMS\Core\Utility\GeneralUtility::validEmail($notificationEmail)) {
         return;
     }
     // Build email texts
     $baseUrl = 'http://' . $newsletter->getDomain();
     $urlRecipient = $baseUrl . '/typo3/alt_doc.php?&edit[tx_newsletter_domain_model_email][' . $email->getUid() . ']=edit';
     $urlRecipientList = $baseUrl . '/typo3/alt_doc.php?&edit[tx_newsletter_domain_model_recipientlist][' . $recipientList->getUid() . ']=edit';
     $urlNewsletter = $baseUrl . '/typo3/alt_doc.php?&edit[tx_newsletter_domain_model_newsletter][' . $newsletter->getUid() . ']=edit';
     $subject = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('unsubscribe_notification_subject', 'newsletter');
     $body = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('unsubscribe_notification_body', 'newsletter', array($email->getRecipientAddress(), $urlRecipient, $recipientList->getTitle(), $urlRecipientList, $newsletter->getTitle(), $urlNewsletter));
     // Actually sends email
     $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
     $message->setTo($notificationEmail)->setFrom(array($newsletter->getSenderEmail() => $newsletter->getSenderName()))->setSubject($subject)->setBody($body, 'text/html');
     $message->send();
 }