コード例 #1
0
 function fetchNewsletterBounceCountGroupedByAddress()
 {
     return array('result' => eZBounce::count(eZBounce::definition(), null, "DISTINCT ADDRESS"));
 }
コード例 #2
0
 static function fetchAddress($id, $asObject = true)
 {
     $bounce = eZPersistentObject::fetchObject(eZBounce::definition(), null, array('address' => $id));
     return $bounce;
 }
コード例 #3
0
function handleBounce($type, $id, $bounceType)
{
    $previousBounce = eZBounce::fetchObject(eZBounce::definition(), null, array('newslettersenditem_id' => $id, 'bounce_type' => $bounceType), true);
    if ($previousBounce) {
        //Update the bounce count for this mailling
        $previousCount = $previousBounce->attribute('bounce_count');
        $previousBounce->setAttribute('bounce_count', ++$previousCount);
        $previousBounce->setAttribute('bounce_message', $type['bounce_message']);
        $previousBounce->store();
        $sendItem = eZSendNewsletterItem::fetch($id, true);
        if ($sendItem) {
            if ($bounceType == EZSOFTBOUNCE && $previousCount < $bounceCountStop) {
                $sendItem->setAttribute('send_status', eZSendNewsletterItem::SendStatusNone);
                $sendItem->store();
            }
            $subscriptionObject = eZSubscription::fetch($sendItem->attribute('subscription_id'));
            if ($subscriptionObject) {
                $bounce_count = $subscriptionObject->attribute('bounce_count');
                $subscriptionObject->setAttribute('bounce_count', ++$bounce_count);
                $subscriptionObject->store();
            }
        }
    } else {
        //We create a new bounce entry
        $db = eZDB::instance();
        $db->begin();
        $bounceData = new eZBounce(array());
        $bounceData->store();
        $bounceData->setAttribute('address', $type['address']);
        $bounceData->setAttribute('bounce_type', $bounceType);
        $bounceData->setAttribute('bounce_count', 1);
        $bounceData->setAttribute('bounce_arrived', $type['bounce_arrived']);
        $bounceData->setAttribute('newslettersenditem_id', $id);
        $bounceData->setAttribute('bounce_message', $type['bounce_message']);
        $bounceData->store();
        $db->commit();
        //Update the sendnewsletteritem table with reference to this bounce entry
        $sendItem = eZSendNewsletterItem::fetch($id, true);
        if ($sendItem) {
            $current_bounceID = $sendItem->attribute('bounce_id');
            if ($current_bounceID == 0) {
                $sendItem->setAttribute('bounce_id', $bounceData->attribute('id'));
                $sendItem->store();
            } else {
                eZDebug::writeNotice("Bounce ID already in place", 'check_bounce');
            }
            if ($bounceType == EZSOFTBOUNCE) {
                $sendItem->setAttribute('send_status', eZSendNewsletterItem::SendStatusNone);
                $sendItem->store();
            }
            //Set the bounce count for the matching subscription_id directly in the subscription table
            $subscription_id = $sendItem->attribute('subscription_id');
            $subscriptionObject = eZSubscription::fetch($subscription_id);
            if ($subscriptionObject) {
                $bounce_count = $subscriptionObject->attribute('bounce_count');
                $subscriptionObject->setAttribute('bounce_count', ++$bounce_count);
                $subscriptionObject->store();
            }
        }
    }
}