コード例 #1
0
 public function testRegisterOpen()
 {
     $this->emailRepository->registerOpen($this->authCode);
     $email = $this->emailRepository->findByUid(302);
     $this->assertTrue($email->isOpened(), 'email should be marked as opened');
     $this->assertRecipientListCallbackWasCalled('opened recipient2@example.com');
 }
コード例 #2
0
 public function testRegisterClick()
 {
     $authCodeForLink = md5($this->authCode . 3001);
     $this->linkRepository->registerClick(30, $authCodeForLink, false);
     $link = $this->linkRepository->findByUid(3001);
     $this->assertEquals(1, $link->getOpenedCount(), 'the link opened count must have been incrementated');
     $this->assertRecipientListCallbackWasCalled('clicked recipient2@example.com');
     $db = $this->getDatabaseConnection();
     $count = $db->exec_SELECTcountRows('*', 'tx_newsletter_domain_model_linkopened', 'link = 3001 AND email = 302');
     $this->assertEquals(1, $count, 'must have exactly 1 linkopened record for this link');
     $email = $this->emailRepository->findByUid(302);
     $this->assertTrue($email->isOpened(), 'email should be marked as open, even if the open spy did not work, because a link was clicked');
     $this->assertRecipientListCallbackWasCalled('opened recipient2@example.com');
 }
コード例 #3
0
 public function testRegisterClick()
 {
     $authCodeForLink = md5($this->authCode . 3001);
     $url = $this->linkRepository->registerClick(30, $authCodeForLink, false);
     $this->assertEquals('http://example.com/index.php?id=1&tx_newsletter_p%5Baction%5D=show&tx_newsletter_p%5Bcontroller%5D=Email&type=1342671779&c=87c4e9b09085befbb7f20faa7482213a', $url, 'the URL returned must have markers substituted');
     $link = $this->linkRepository->findByUid(3001);
     $this->assertEquals(1, $link->getOpenedCount(), 'the link opened count must have been incrementated');
     $this->assertRecipientListCallbackWasCalled('clicked recipient2@example.com');
     $db = $this->getDatabaseConnection();
     $count = $db->exec_SELECTcountRows('*', 'tx_newsletter_domain_model_linkopened', 'link = 3001 AND email = 302');
     $this->assertEquals(1, $count, 'must have exactly 1 linkopened record for this link');
     $email = $this->emailRepository->findByUid(302);
     $this->assertTrue($email->isOpened(), 'email should be marked as open, even if the open spy did not work, because a link was clicked');
     $this->assertRecipientListCallbackWasCalled('opened recipient2@example.com');
 }
コード例 #4
0
ファイル: EmailController.php プロジェクト: ecodev/newsletter
 /**
  * Unsubscribe recipient from RecipientList by registering a bounce of level \Ecodev\Newsletter\Utility\EmailParser::NEWSLETTER_UNSUBSCRIBE
  */
 public function unsubscribeAction()
 {
     $success = false;
     $newsletter = null;
     $email = null;
     $recipientAddress = null;
     $args = $this->request->getArguments();
     // For compatibility with old links
     if (!isset($args['c'])) {
         if (isset($_GET['c'])) {
             $args['c'] = $_GET['c'];
         }
     }
     // If we have an authentification code, look for the original email which was already sent
     if (@$args['c']) {
         $email = $this->emailRepository->findByAuthcode($args['c']);
         if ($email) {
             // Mark the email as requested to be unsubscribed
             $email->setUnsubscribed(true);
             $this->emailRepository->update($email);
             $recipientAddress = $email->getRecipientAddress();
             $newsletter = $email->getNewsletter();
             if ($newsletter) {
                 $recipientList = $newsletter->getRecipientList();
                 $recipientList->registerBounce($email->getRecipientAddress(), EmailParser::NEWSLETTER_UNSUBSCRIBE);
                 $success = true;
                 $this->notifyUnsubscribe($newsletter, $recipientList, $email);
             }
         }
     }
     // Redirect unsubscribe via config.
     $redirect = Tools::confParam('unsubscribe_redirect');
     // If it is a PID, convert to a URL
     if (is_numeric($redirect)) {
         $uriBuilder = $this->controllerContext->getUriBuilder();
         $uriBuilder->reset();
         $uriBuilder->setUseCacheHash(false);
         $uriBuilder->setTargetPageUid((int) $redirect);
         // Append the recipient address just in case you want to do something with it at the destination
         $uriBuilder->setArguments(['recipient' => $recipientAddress]);
         $redirect = $uriBuilder->build();
     }
     // If it is a valid URL, redirect to it
     if (GeneralUtility::isValidUrl($redirect)) {
         $this->redirectToUri($redirect);
     }
     // Else render the template.
     $this->view->assign('success', $success);
     $this->view->assign('recipientAddress', $recipientAddress);
 }