예제 #1
0
 public function renderFile()
 {
     $aCurrentValues = $this->oFormStorage->saveCurrentValuesToSession();
     $oFlash = Flash::getFlash();
     $oFlash->setArrayToCheck($aCurrentValues);
     $bHasCaptcha = false;
     foreach ($this->oFormStorage->getFormObjects() as $oFormObject) {
         if ($oFormObject instanceof CaptchaObject) {
             $bHasCaptcha = true;
         }
         if ($oFormObject->shouldExcludeFromReport()) {
             continue;
         }
         if ($oFormObject->isRequired()) {
             $oFlash->checkForValue($oFormObject->getName());
         }
         $oEmailItemTemplateInstance = clone $this->oEmailItemTemplate;
         $oEmailItemTemplateInstance->replaceIdentifier('name', $oFormObject->getName());
         $oEmailItemTemplateInstance->replaceIdentifier('label', $oFormObject->getLabel());
         $oEmailItemTemplateInstance->replaceIdentifier('value', $oFormObject->getCurrentValue());
         $this->oEmailTemplate->replaceIdentifierMultiple('form_content', $oEmailItemTemplateInstance);
     }
     if ($bHasCaptcha && !FormFrontendModule::validateRecaptchaInput()) {
         $oFlash->addMessage('captcha_code_required');
     }
     $oFlash->finishReporting();
     if (Flash::noErrors()) {
         $oEmail = new EMail(TranslationPeer::getString('wns.form_module.email_subject', null, null, array('page' => $this->sPageName)), $this->oEmailTemplate);
         $oEmail->addRecipient($this->sEmailAddress);
         $oEmail->send();
         $this->oFormStorage->deleteCurrentValuesFromSession();
         LinkUtil::redirect($_REQUEST['origin'] . '?form_success=true');
     } else {
         $oFlash->stick();
         LinkUtil::redirect($_REQUEST['origin']);
     }
 }
 /**
  * sendMail()
  */
 private function sendMail($oEmailTemplate, $bSendHtml = false)
 {
     $oEmailTemplate->replaceIdentifier('name', $this->oSubscriber->getName());
     $sSenderName = Settings::getSetting('newsletter', 'sender_name', 'Rapila Newsletter Plugin');
     $sSenderEmail = Settings::getSetting('newsletter', 'sender_email', LinkUtil::getDomainHolderEmail('no-reply'));
     $oEmailTemplate->replaceIdentifier('signature', $sSenderName);
     $oEmailTemplate->replaceIdentifier('weblink', LinkUtil::getHostName());
     $oEmail = new EMail(TranslationPeer::getString('wns.subscriber_email.subject'), $oEmailTemplate, $bSendHtml);
     $oEmail->setSender($sSenderName, $sSenderEmail);
     $oEmail->addRecipient($this->oSubscriber->getEmail());
     $oEmail->send();
 }
예제 #3
0
 public static function sendResetMail($oUser, $bShowUserName = false, $sLinkBase = null, $bForceReset = false)
 {
     UserPeer::ignoreRights(true);
     $oUser->setPasswordRecoverHint(PasswordHash::generateHint());
     $oUser->save();
     $oEmailTemplate = new Template('e_mail_pw_recover', array(DIRNAME_TEMPLATES, 'login'));
     $oEmailTemplate->replaceIdentifier('full_name', $oUser->getFullName());
     $oEmailTemplate->replaceIdentifier('first_name', $oUser->getFirstName());
     $oEmailTemplate->replaceIdentifier('last_name', $oUser->getLastName());
     $oEmailTemplate->replaceIdentifier('username', $oUser->getUsername());
     if ($bShowUserName) {
         $oEmailTemplate->replaceIdentifier('username_info', TranslationPeer::getString('wns.login.password_reset.your_username') . ': ' . $oUser->getUsername());
     }
     $sInfoTextKey = 'wns.login.password_recover_email_text2';
     if ($bForceReset) {
         $sInfoTextKey = 'wns.login.password_recover_email_text2_force';
     }
     $oEmailTemplate->replaceIdentifier('ignore_or_reset_info', TranslationPeer::getString($sInfoTextKey));
     if ($sLinkBase === null) {
         if (Manager::$CURRENT_MANAGER instanceof FrontendManager) {
             // We’re most likely on a login page: link to self should be ok
             $sLinkBase = LinkUtil::linkToSelf(null, null, true);
         } else {
             // Use the login manager
             $sLinkBase = LinkUtil::link(array(), 'LoginManager');
         }
     }
     $aParams = array('recover_hint' => md5($oUser->getPasswordRecoverHint()), 'recover_username' => $oUser->getUsername());
     if (Session::getSession()->hasAttribute('login_referrer')) {
         $aParams['recover_referrer'] = Session::getSession()->getAttribute('login_referrer');
     }
     $sLink = "http://" . $_SERVER['HTTP_HOST'] . $sLinkBase . LinkUtil::prepareLinkParameters($aParams);
     $oEmailTemplate->replaceIdentifier('new_pw_url', $sLink);
     $oEmail = new EMail(TranslationPeer::getString('wns.login.password_recover_email_subject'), $oEmailTemplate);
     $sSenderAddress = LinkUtil::getDomainHolderEmail('cms');
     $oEmail->setSender(Settings::getSetting('domain_holder', 'name', 'rapila on ' . $_SERVER['HTTP_HOST']), $sSenderAddress);
     $oEmail->addRecipient($oUser->getEmail(), $oUser->getFullName());
     $oEmail->send();
 }
예제 #4
0
 /** sendNewsletter()
  *
  * @param mixed string/object recipient
  * @param object oEmailTemplateInstance
  *
  * @return void
  */
 private function sendNewsletter($mRecipient, $oEmailTemplateInstance)
 {
     if (is_object($mRecipient)) {
         $oEmailTemplateInstance->replaceIdentifier('recipient', $mRecipient->getName());
         if ($mRecipient instanceof Subscriber && $this->oUnsubscribePage) {
             $sLanguageId = FrontendManager::shouldIncludeLanguageInLink() ? $this->oNewsletter->getLanguageId() : false;
             if (method_exists($mRecipient, 'getUnsubscribeQueryParams')) {
                 $sUnsubscribeLink = LinkUtil::absoluteLink(LinkUtil::link($this->oUnsubscribePage->getLink(), 'FrontendManager', $mRecipient->getUnsubscribeQueryParams(), $sLanguageId));
                 $oEmailTemplateInstance->replaceIdentifier('unsubscribe_link', $sUnsubscribeLink);
             }
         }
     } else {
         $oEmailTemplateInstance->replaceIdentifier('recipient', $mRecipient);
     }
     // Send newsletter and store invalid emails
     try {
         $sPlainTextMethod = Settings::getSetting('newsletter', 'plain_text_alternative_method', 'markdown');
         $oEMail = null;
         if ($sPlainTextMethod === null || $sPlainTextMethod === false) {
             $oEMail = new EMail($this->oNewsletter->getSubject(), $oEmailTemplateInstance, true);
         } else {
             $oEMail = new EMail($this->oNewsletter->getSubject(), MIMEMultipart::alternativeMultipartForTemplate($oEmailTemplateInstance, null, null, $sPlainTextMethod), true);
         }
         if (is_object($mRecipient)) {
             $oEMail->addRecipient($mRecipient->getEmail(), $mRecipient->getName() === $mRecipient->getEmail() ? null : $mRecipient->getName());
         } else {
             $oEMail->addRecipient($mRecipient);
         }
         $oEMail->setSender($this->sSenderName, $this->sSenderEmailAddress);
         $oEMail->send();
     } catch (Exception $e) {
         $this->aInvalidEmails[] = new NewsletterSendFailure($e, $mRecipient);
     }
 }
예제 #5
0
 private function handleNewJournalComment($oPage, $oEntry)
 {
     $oFlash = Flash::getFlash();
     // Validate form and create new comment and
     $oComment = new JournalComment();
     $oComment->setUsername($_POST['comment_name']);
     $oFlash->checkForValue('comment_name', 'comment_name_required');
     $oComment->setEmail($_POST['comment_email']);
     $oFlash->checkForEmail('comment_email', 'comment_email_required');
     if ($oEntry->getJournal()->getUseCaptcha() && !Session::getSession()->isAuthenticated() && !FormFrontendModule::validateRecaptchaInput() && !isset($_POST['preview'])) {
         $oFlash->addMessage('captcha_required');
     }
     $oPurifierConfig = HTMLPurifier_Config::createDefault();
     $oPurifierConfig->set('Cache.SerializerPath', MAIN_DIR . '/' . DIRNAME_GENERATED . '/' . DIRNAME_CACHES . '/purifier');
     $oPurifierConfig->set('HTML.Doctype', 'XHTML 1.0 Transitional');
     $oPurifierConfig->set('AutoFormat.AutoParagraph', true);
     $oPurifier = new HTMLPurifier($oPurifierConfig);
     $_POST['comment_text'] = $oPurifier->purify($_POST['comment_text']);
     $oComment->setText($_POST['comment_text']);
     $oFlash->checkForValue('comment_text', 'comment_required');
     $oFlash->finishReporting();
     if (isset($_POST['preview'])) {
         $oComment->setCreatedAt(date('c'));
         $_POST['preview'] = $oComment;
     } else {
         if (Flash::noErrors()) {
             $oEntry->addJournalComment($oComment);
             // Post is considered as spam
             $bIsProblablySpam = isset($_POST['important_note']) && $_POST['important_note'] != null;
             $sCommentNotificationTemplate = 'e_mail_comment_notified';
             // Prevent publication if comments are not enabled or post is spam
             if (!$oEntry->getJournal()->getEnableComments() || $bIsProblablySpam) {
                 if (!Session::getSession()->isAuthenticated()) {
                     $oComment->setIsPublished(false);
                     $sCommentNotificationTemplate = 'e_mail_comment_moderated';
                 }
             }
             $oComment->save();
             // Notify new comment
             if ($oEntry->getJournal()->getNotifyComments()) {
                 $oEmailContent = JournalPageTypeModule::templateConstruct($sCommentNotificationTemplate, $oPage->getPagePropertyValue('journal:template_set', 'default'));
                 $oEmailContent->replaceIdentifier('email', $oComment->getEmail());
                 $oEmailContent->replaceIdentifier('user', $oComment->getUsername());
                 if ($bIsProblablySpam) {
                     $oEmailContent->replaceIdentifier('this_comment_is_spam_note', TranslationPeer::getString('journal.this_comment_is_spam_note', null, null, array('important_note_content' => $_POST['important_note'])));
                 }
                 $oEmailContent->replaceIdentifier('comment', $oComment->getText());
                 $oEmailContent->replaceIdentifier('entry', $oEntry->getTitle());
                 $oEmailContent->replaceIdentifier('journal', $oEntry->getJournal()->getName());
                 $oEmailContent->replaceIdentifier('entry_link', LinkUtil::absoluteLink(LinkUtil::link($oEntry->getLink($oPage))));
                 $oEmailContent->replaceIdentifier('deactivation_link', LinkUtil::absoluteLink(LinkUtil::link(array('journal_comment_moderation', $oComment->getActivationHash(), 'deactivate'), 'FileManager'), null, LinkUtil::isSSL()));
                 $oEmailContent->replaceIdentifier('activation_link', LinkUtil::absoluteLink(LinkUtil::link(array('journal_comment_moderation', $oComment->getActivationHash(), 'activate'), 'FileManager'), null, LinkUtil::isSSL()));
                 $oEmailContent->replaceIdentifier('deletion_link', LinkUtil::absoluteLink(LinkUtil::link(array('journal_comment_moderation', $oComment->getActivationHash(), 'delete'), 'FileManager'), null, LinkUtil::isSSL()));
                 $sSubject = TranslationPeer::getString('journal.notification_subject', null, null, array('entry' => $oEntry->getTitle()));
                 $oEmail = new EMail($sSubject, $oEmailContent);
                 $oSender = $oEntry->getUserRelatedByCreatedBy();
                 $oEmail->addRecipient($oSender->getEmail(), $oSender->getFullName());
                 $oEmail->send();
             }
             $oSession = Session::getSession();
             Flash::getFlash()->unfinishReporting()->addMessage('journal.has_new_comment', array(), "journal_entry.new_comment_thank_you" . ($oEntry->getJournal()->getEnableComments() || $oSession->isAuthenticated() ? '' : '.moderated'), 'new_comment_thank_you_message', 'p')->stick();
             LinkUtil::redirect(LinkUtil::link($oEntry->getLink($oPage)) . "#comments");
         }
     }
 }