コード例 #1
0
ファイル: Index.php プロジェクト: acp3/module-newsletter
 /**
  * @return array
  */
 public function execute()
 {
     $this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
     $resultsPerPage = $this->resultsPerPage->getResultsPerPage(Newsletter\Installer\Schema::MODULE_NAME);
     $this->pagination->setResultsPerPage($resultsPerPage)->setTotalResults($this->newsletterRepository->countAll(1));
     return ['newsletters' => $this->newsletterRepository->getAll(Newsletter\Helper\AccountStatus::ACCOUNT_STATUS_CONFIRMED, $this->pagination->getResultsStartOffset(), $resultsPerPage), 'pagination' => $this->pagination->render()];
 }
コード例 #2
0
ファイル: Details.php プロジェクト: acp3/module-newsletter
 /**
  * @param int $id
  *
  * @return array
  * @throws \ACP3\Core\Controller\Exception\ResultNotExistsException
  */
 public function execute($id)
 {
     $newsletter = $this->newsletterRepository->getOneByIdAndStatus($id, 1);
     if (!empty($newsletter)) {
         $this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
         $this->breadcrumb->append($this->translator->t('newsletter', 'index'), 'newsletter')->append($this->translator->t('newsletter', 'frontend_archive_index'), 'newsletter/archive')->append($newsletter['title']);
         return ['newsletter' => $newsletter];
     }
     throw new Core\Controller\Exception\ResultNotExistsException();
 }
コード例 #3
0
 /**
  * Versendet einen Newsletter
  *
  * @param int $newsletterId
  * @param string|array $recipients
  * @param bool $bcc
  *
  * @return bool
  */
 public function sendNewsletter($newsletterId, $recipients, $bcc = false)
 {
     $settings = $this->config->getSettings(Schema::MODULE_NAME);
     $newsletter = $this->newsletterRepository->getOneById($newsletterId);
     $sender = ['email' => $settings['mail'], 'name' => $this->config->getSettings(\ACP3\Modules\ACP3\System\Installer\Schema::MODULE_NAME)['site_title']];
     $this->mailer->reset()->setBcc($bcc)->setFrom($sender)->setSubject($newsletter['title'])->setUrlWeb($this->router->route('newsletter/archive/details/id_' . $newsletterId, true))->setMailSignature($settings['mailsig']);
     if ($newsletter['html'] == 1) {
         $this->mailer->setTemplate('newsletter/layout.email.tpl');
         $this->mailer->setHtmlBody($newsletter['text']);
     } else {
         $this->mailer->setBody($newsletter['text']);
     }
     $this->mailer->setRecipients($recipients);
     return $this->mailer->send();
 }
コード例 #4
0
ファイル: Send.php プロジェクト: acp3/module-newsletter
 /**
  * @param int $id
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  * @throws \ACP3\Core\Controller\Exception\ResultNotExistsException
  */
 public function execute($id)
 {
     if ($this->newsletterRepository->newsletterExists($id) === true) {
         $accounts = $this->accountRepository->getAllActiveAccounts();
         $cAccounts = count($accounts);
         $recipients = [];
         for ($i = 0; $i < $cAccounts; ++$i) {
             $recipients[] = $accounts[$i]['mail'];
         }
         $bool = $this->newsletterHelpers->sendNewsletter($id, $recipients);
         $bool2 = false;
         if ($bool === true) {
             $bool2 = $this->newsletterRepository->update(['status' => '1'], $id);
         }
         return $this->redirectMessages()->setMessage($bool === true && $bool2 !== false, $this->translator->t('newsletter', $bool === true && $bool2 !== false ? 'create_success' : 'create_save_error'));
     }
     throw new Core\Controller\Exception\ResultNotExistsException();
 }