Ejemplo n.º 1
0
<?php

$Module = $Params['Module'];
$http = eZHTTPTool::instance();
$tpl = eZTemplate::factory();
$newsletter_node_id = $Params['NewsletterNodeID'];
$node = eZContentObject::fetchByNodeID($newsletter_node_id);
if (!$node || !$node->canRead()) {
    return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
$tabs = array('details' => 'Details', 'preview_html' => 'Preview HTML', 'preview_text' => 'Preview Text', 'activity' => "Activity");
$selected_tab = array_key_exists($Params['Tab'], $tabs) ? $Params['Tab'] : 'details';
$recipients_lists = jajNewsletterRecipientsList::fetchByContentObjectID($node->ID);
$error_strings = array();
if ($http->hasSessionVariable('PreviewInvalidReceiver')) {
    $error_strings[] = ezpI18n::tr('design/admin/jaj_newsletter/newsletter', 'The email address of the preview receiver is not valid');
    $http->removeSessionVariable('PreviewInvalidReceiver');
}
if ($http->hasSessionVariable('PreviewSendEmailFailed')) {
    $error_strings[] = ezpI18n::tr('design/admin/jaj_newsletter/newsletter', $http->sessionVariable('PreviewSendEmailFailed'));
    $http->removeSessionVariable('PreviewSendEmailFailed');
}
if ($http->hasSessionVariable('PreviewEmailSent')) {
    $feedback_strings[] = ezpI18n::tr('design/admin/jaj_newsletter/newsletter', 'Preview e-mail was sent to: %email', null, array('%email' => $http->sessionVariable('PreviewEmailSent')));
    $http->removeSessionVariable('PreviewEmailSent');
}
if ($http->hasSessionVariable('NewsletterSent')) {
    $feedback_strings[] = ezpI18n::tr('design/admin/jaj_newsletter/newsletter', 'Newsletter delivery started for %count recipients', null, array('%count' => $http->sessionVariable('NewsletterSent')));
    $http->removeSessionVariable('NewsletterSent');
}
$offset = $Params['Offset'];
Ejemplo n.º 2
0
    foreach ($recipients_lists as $list) {
        $list->remove();
    }
    // And add the selected ones
    if ($Module->hasActionParameter('SubscriptionListIdArray')) {
        $subscription_list_ids = $Module->actionParameter('SubscriptionListIdArray');
        foreach ($subscription_list_ids as $list_id) {
            $recipients_list = jajNewsletterRecipientsList::create($newsletter_id, $list_id);
            $recipients_list->store();
        }
    }
}
if ($Module->isCurrentAction('RemoveRecipientsList')) {
    $recipients_list = jajNewsletterRecipientsList::fetch($newsletter_id, $Module->actionParameter('SubscriptionListID'));
    if (is_object($recipients_list)) {
        $recipients_list->remove();
    }
}
if ($Module->isCurrentAction('Cancel') || $Module->isCurrentAction('StoreRecipients') || $Module->isCurrentAction('RemoveRecipientsList')) {
    return $Module->redirectTo($Module->functionURI("newsletter") . "/" . $node->mainNodeID());
}
$lists = jajNewsletterSubscriptionList::fetchByOffset();
$recipients_lists = jajNewsletterRecipientsList::fetchByContentObjectID($newsletter_id, false);
$active_list_ids = array();
foreach ($recipients_lists as $list) {
    array_push($active_list_ids, $list['subscription_list_id']);
}
$tpl->setVariable('node', $node);
$tpl->setVariable('lists', $lists);
$tpl->setVariable('active_list_ids', $active_list_ids);
$Result = array('content' => $tpl->fetch('design:jaj_newsletter/newsletters/add_recipients.tpl'), 'path' => array(array('url' => 'jaj_newsletter/index', 'text' => ezpI18n::tr('jaj_newsletter/navigation', 'Newsletter')), array('url' => 'jaj_newsletter/newsletters', 'text' => ezpI18n::tr('jaj_newsletter/navigation', 'Newsletters')), array('url' => 'jaj_newsletter/newsletter/' . $node->mainNodeID(), 'text' => $node->attribute('name')), array('url' => false, 'text' => ezpI18n::tr('jaj_newsletter/navigation', 'Add Recipients'))));
 public function fetchRecipientsLists($asObject = true)
 {
     return eZPersistentObject::fetchObjectList(jajNewsletterRecipientsList::definition(), null, array('subscription_list_id' => $this->ID), array(), array(), $asObject);
 }
 static function removeByContentObjectID($contentobject_id)
 {
     return eZPersistentObject::fetchObjectList(jajNewsletterRecipientsList::definition(), array('contentobject_id' => $contentobject_id));
 }