コード例 #1
0
 static function generateDeliveryForNewsletter($node)
 {
     // TODO: Should use a different method / datatype
     // Better with string
     $data_map = $node->DataMap();
     $status = $data_map['status'];
     $status->fromString("in progress");
     $status->store();
     $subscribers = jajNewsletterSubscription::fetchUniqueForNewsletterId($node->ID, false);
     $result = 0;
     foreach ($subscribers as $subscription) {
         $row = array("contentobject_id" => $node->ID, "uuid" => $subscription['uuid'], "email" => $subscription['email'], "state" => "pending", "created" => time());
         $delivery = new jajNewsletterDelivery($row);
         $delivery->store();
         $result += 1;
     }
     return $result;
 }
コード例 #2
0
ファイル: send.php プロジェクト: jjohnsen/jaj_newsletter
<?php

$Module = $Params['Module'];
$tpl = eZTemplate::factory();
$http = eZHTTPTool::instance();
$newsletter_id = $Params['NewsletterID'];
$node = eZContentObject::fetch($newsletter_id);
if (!$node || !$node->canRead()) {
    return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
if ($Module->isCurrentAction('SendNewsletter')) {
    $result = jajNewsletterDelivery::generateDeliveryForNewsletter($node);
    $http->setSessionVariable('NewsletterSent', $result);
}
if ($Module->isCurrentAction('Cancel') || $Module->isCurrentAction('SendNewsletter')) {
    return $Module->redirectTo($Module->functionURI("newsletter") . "/" . $node->mainNodeID());
}
$tpl->setVariable('node', $node);
// TODO: Fix with own counter function
$unique_recipients = count(jajNewsletterSubscription::fetchUniqueForNewsletterId($node->ID, false));
$tpl->setVariable('unique_recipients', $unique_recipients);
$Result = array('content' => $tpl->fetch('design:jaj_newsletter/newsletters/send.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', 'Send Newsletter'))));
コード例 #3
0
ファイル: view.php プロジェクト: jjohnsen/jaj_newsletter
}
$offset = $Params['Offset'];
switch (eZPreferences::value('admin_jaj_newsletter_newsletter_view_limit')) {
    case '25':
        $limit = 25;
        break;
    case '50':
        $limit = 50;
        break;
    default:
        $limit = 10;
        break;
}
$view_parameters = array('offset' => $offset);
$deliveries = jajNewsletterDelivery::fetchDeliveriesByContentobjectID($node->ID, $limit, $offset);
$deliveries_count = jajNewsletterDelivery::fetchDeliveriesByContentobjectIdCount($node->ID);
$newsletter_ini = eZINI::instance('jaj_newsletter.ini');
$from_email = $newsletter_ini->variable('NewsletterSettings', 'FromEmail');
$from_name = $newsletter_ini->variable('NewsletterSettings', 'FromName');
$reply_email = $newsletter_ini->variable('NewsletterSettings', 'ReplyEmail');
$tpl->setVariable('node', $node);
$tpl->setVariable('recipients_lists', $recipients_lists);
$tpl->setVariable('tabs', $tabs);
$tpl->setVariable('selected_tab', $selected_tab);
$tpl->setVariable('error_strings', $error_strings);
$tpl->setVariable('feedback_strings', $feedback_strings);
$tpl->setVariable('total_active_recipients', jajNewsletterSubscription::countByRecipientsLists($recipients_lists, 'active'));
$tpl->setVariable('total_recipients', jajNewsletterSubscription::countByRecipientsLists($recipients_lists));
$tpl->setVariable('from_email', $from_email);
$tpl->setVariable('from_name', $from_name);
$tpl->setVariable('reply_email', $reply_email);
コード例 #4
0
        try {
            $mail_transport->send($mail);
        } catch (Exception $e) {
            $cli->output('Error sending mail: ' . $e->getMessage());
        }
        $delivery->setAttribute('state', 'sent');
        $delivery->setAttribute('sent', time());
        $delivery->store();
        // Check time limit
        $time = time() - $start_time;
        if ($time > $time_limit) {
            $cli->output('Time Limit existed. Stopping delivery');
            break 2;
            // Break out of both loops
        }
    }
    // Check if remaining deliveries
    $deliveries_count = jajNewsletterDelivery::fetchDeliveriesByContentobjectIdCount($object_id, 'pending');
    if ($deliveries_count == 0) {
        $cli->output('Pending deliveries: ' . $deliveries_count . ', archiving newsletter');
        $status = $data_map['status'];
        $status->fromString("archive");
        $status->store();
    }
    if ($batch_limit <= 0) {
        $cli->output('Batch limit reached. Stopping');
        break;
    }
}
//$cli->output( 'Testing... ' );
exec('ls');
コード例 #5
0
ファイル: track.php プロジェクト: jjohnsen/jaj_newsletter
<?php

$object_id = $Params['object_id'];
$uuid = $Params['uuid'];
$operation = $Params['operation'];
$delivery = jajNewsletterDelivery::fetchByObjectIdAndUUID($object_id, $uuid);
if (is_object($delivery)) {
    $delivery->markAsOpened();
    if ($operation == 'view') {
        $delivery->markAsViewed();
    }
}
$image = 'extension/jaj_newsletter/design/standard/images/logo.gif';
if (!file_exists($image)) {
    eZDebug::writeEror("Image for tracking doesn't exist", 'jaj_newsletter::newsletter::track');
    return;
}
ob_clean();
header('Pragma: ');
header('Cache-Control: ');
/* Set cache time out to 10 seconds, this should be good enough to work around an IE bug */
header("Expires: " . gmdate('D, d M Y H:i:s', time() + 10) . ' GMT');
header('X-Powered-By: eZ Publish');
header('Content-Length: ' . filesize($image));
header('Content-Type: image/gif');
header('Content-Transfer-Encoding: binary');
header('Accept-Ranges: bytes');
ob_end_clean();
$fp = @fopen($image, 'r');
@fpassthru($fp);
fclose($fp);