function sendConfirmation()
 {
     if ($this->attribute('status') != eZSubscription::StatusPending) {
         return;
     }
     $res = eZTemplateDesignResource::instance();
     $ini = eZINI::instance();
     $hostname = eZSys::hostname();
     $template = 'design:eznewsletter/sendout/registration.tpl';
     $tpl = eZNewsletterTemplateWrapper::templateInit();
     $tpl->setVariable('userData', eZUserSubscriptionData::fetch($this->attribute('email')));
     $tpl->setVariable('hostname', $hostname);
     $tpl->setVariable('subscription', $this);
     $tpl->setVariable('subscriptionList', $this->attribute('subscription_list'));
     $templateResult = $tpl->fetch($template);
     if ($tpl->hasVariable('subject')) {
         $subject = $tpl->variable('subject');
     }
     $mail = new eZMail();
     $mail->setSender($ini->variable('MailSettings', 'EmailSender'), $ini->variable('SiteSettings', 'SiteName'));
     $mail->setReceiver($this->attribute('email'));
     $mail->setBody($templateResult);
     $mail->setSubject($subject);
     eZMailTransport::send($mail);
 }
if (isset($Params['BrowseSelected']) && $Params['BrowseSelected'] == 'article') {
    if ($http->hasPostVariable('SelectedObjectIDArray')) {
        $articlePoolNodeID = $http->postVariable('SelectedObjectIDArray');
        if (isset($articlePoolNodeID) && !$http->hasPostVariable('BrowseCancelButton')) {
            $newsletterType->setAttribute('article_pool_object_id', $articlePoolNodeID[0]);
            $newsletterType->store();
        }
    }
} else {
    if (isset($Params['BrowseSelected']) && $Params['BrowseSelected'] == 'inbox') {
        if ($http->hasPostVariable('SelectedObjectIDArray')) {
            $inboxNodeID = $http->postVariable('SelectedObjectIDArray');
            if (isset($inboxNodeID) && !$http->hasPostVariable('BrowseCancelButton')) {
                $newsletterType->setAttribute('inbox_id', $inboxNodeID[0]);
                $newsletterType->store();
            }
        }
    }
}
$tpl = eZNewsletterTemplateWrapper::templateInit();
$tpl->setVariable('warning', $warning);
$tpl->setVariable('newsletter_type', $newsletterType);
$tpl->setVariable('contentclass_list', eZNewsletterType::unserializeArray($newsletterType->attribute('contentclass_list')));
$tpl->setVariable('selected_designs', eZNewsletterType::unserializeArray($newsletterType->attribute('allowed_designs')));
// countAll(eZSendNewsletterItem::definition()) ) ) erzeugt einen sql fehler
$tpl->setVariable('subscription_list_array', eZSubscriptionList::fetchList(0, eZSubscriptionList::countAll(eZSubscriptionList::StatusPublished)));
$Result = array();
$Result['newsletter_menu'] = 'design:parts/content/newsletter_menu.tpl';
$Result['left_menu'] = 'design:parts/content/eznewsletter_menu.tpl';
$Result['content'] = $tpl->fetch("design:{$extension}/edit_newslettertype.tpl");
$Result['path'] = array(array('url' => false, 'text' => ezpI18n::tr('eznewsletter/edit_newslettertype', 'Edit newsletter type')));
function sendConfirmation($email, $subscription, $subscribe)
{
    //send mail
    $res = eZTemplateDesignResource::instance();
    $ini = eZINI::instance();
    $hostname = eZSys::hostname();
    if ($subscribe) {
        $template = 'design:eznewsletter/sendout/subscription.tpl';
    } else {
        $template = 'design:eznewsletter/sendout/unsubscription.tpl';
    }
    $tpl = eZNewsletterTemplateWrapper::templateInit();
    $tpl->setVariable('userData', eZUserSubscriptionData::fetch($email));
    $tpl->setVariable('hostname', $hostname);
    $tpl->setVariable('subscription', $subscription);
    $subscriptionList = eZSubscriptionList::fetch($subscription->attribute('subscriptionlist_id'), eZSubscriptionList::StatusPublished, true, true);
    $tpl->setVariable('subscriptionList', $subscriptionList);
    $templateResult = $tpl->fetch($template);
    if ($tpl->hasVariable('subject')) {
        $subject = $tpl->variable('subject');
    }
    $mail = new eZMail();
    $mail->setSender($ini->variable('MailSettings', 'EmailSender'));
    $mail->setReceiver($email);
    $mail->setBody($templateResult);
    $mail->setSubject($subject);
    eZMailTransport::send($mail);
}
예제 #4
0
 function generateNewsletter($format = eZNewsletter::OutputFormatText, $sendPreview = false)
 {
     // 1. Set resource keys
     $res = eZTemplateDesignResource::instance();
     $res->setKeys(array(array('newslettertype_id', $this->attribute('newslettertype_id')), array('newsletter_id', $this->attribute('id')), array('class_identifier', ''), array('newsletter_type', 'mail')));
     if ($format == eZNewsletter::OutputFormatText) {
         $res->setKeys(array(array('output_format', 'plaintext')));
     }
     // 2. Set general mail and template properties
     $ini = eZINI::instance();
     $hostname = eZSys::hostname();
     $newsletterType = $this->attribute('newsletter_type');
     if (true === $sendPreview) {
         // Fetch the draft because the object is not published during preview
         $contentObject = $this->contentObjectVersion();
     } else {
         $contentObject = $this->contentObject();
     }
     // 3. get skin for newsletter
     $skin_prefix = 'eznewsletter';
     $custom_skin = $this->attribute('template_to_use');
     if ($custom_skin) {
         $skin_prefix = $custom_skin;
     }
     // 3. Generate mail variation
     switch ($format) {
         default:
         case eZNewsletter::OutputFormatText:
             $template = 'design:' . $skin_prefix . '/sendout/text.tpl';
             break;
         case eZNewsletter::OutputFormatExternalHTML:
             $template = 'design:' . $skin_prefix . '/sendout/linked.tpl';
             break;
         case eZNewsletter::OutputFormatHTML:
             $template = 'design:' . $skin_prefix . '/sendout/html.tpl';
             break;
         case eZNewsletter::OutputFormatSMS:
             $template = 'design:' . $skin_prefix . '/sendout/sms.tpl';
             break;
     }
     $tpl = eZNewsletterTemplateWrapper::templateInit();
     $tpl->setVariable('hostname', $hostname);
     $tpl->setVariable('contentobject', $contentObject);
     $tpl->setVariable('newsletter', $this);
     $body = $tpl->fetch($template);
     // Get images used.
     $imageList = false;
     $imageListName = false;
     if ($tpl->hasVariable('imageFileList') && $format == eZNewsletter::OutputFormatHTML) {
         foreach ($tpl->variable('imageFileList') as $imageMap) {
             $tplImageList = explode(';', $imageMap);
             $imagePath = $tplImageList[0];
             $imageURL = $tplImageList[1];
             $imageName = isset($tplImageList[2]) ? $tplImageList[2] : basename($imagePath);
             $md5Sum = md5($imageURL);
             $body = str_replace($imageURL, 'cid:' . $md5Sum, $body);
             $imageList[$md5Sum] = $imagePath;
             $imageListName[$md5Sum] = $imageName;
         }
     }
     if ($format == eZNewsletter::OutputFormatText || $format == eZNewsletter::OutputFormatExternalHTML) {
         if ($format == eZNewsletter::OutputFormatText) {
             $body = strip_tags($body);
         }
         $body = trim($body);
     }
     $subject = $this->attribute('name');
     if ($tpl->hasVariable('subject')) {
         $subject = $tpl->variable('subject');
     }
     if ($tpl->hasVariable('emailSenderName')) {
         $emailSenderName = $tpl->variable('emailSenderName');
     } else {
         $emailSenderName = false;
     }
     return array('body' => $body, 'subject' => $subject, 'emailSender' => $newsletterType->attribute('sender_address') ? $newsletterType->attribute('sender_address') : $ini->variable('MailSettings', 'EmailSender'), 'emailSenderName' => $emailSenderName, 'imageNameMap' => $imageList, 'userhash' => 'userhash', 'templateInstance' => $tpl, 'imageNameMapName' => $imageListName);
 }