static function removeAllBounceInformation($bounceID) { $bounceItem = eZBounce::fetch($bounceID); if (!$bounceItem) { return; } $sendItem = eZSendNewsletterItem::fetch($bounceItem->attribute('newslettersenditem_id'), true); if ($sendItem) { $subscription = eZSubscription::fetch($sendItem->attribute('subscription_id')); if ($subscription) { $subscription->setAttribute('bounce_count', 0); $subscription->store(); } $sendItem->setAttribute('bounce_id', 0); $sendItem->store(); $bounceItem->remove(); } else { $bounceItem->remove(); } }
function subscriptionByID($id) { return array('result' => eZSubscription::fetch($id)); }
include_once "lib/ezutils/classes/ezmailtransport.php"; include_once "lib/ezfile/classes/ezfile.php"; include_once eZExtension::baseDirectory() . '/eznewsletter/classes/ezsubscriptionlist.php'; include_once eZExtension::baseDirectory() . '/eznewsletter/classes/ezsubscription.php'; include_once eZExtension::baseDirectory() . '/eznewsletter/classes/eznewsletter.php'; $Module =& $Params['Module']; $tpl = eZTemplate::instance(); $http = eZHTTPTool::instance(); $res = eZTemplateDesignResource::instance(); $res->setKeys(array(array('newsletter_view', 'register_subscription'))); $NewsletterItem = eZSendNewsletterItem::fetchByHash($Params['UserHash']); if (!$NewsletterItem) { return $Module->handleError(3, 'kernel'); } $sub = $NewsletterItem->userData(); $subscription = eZSubscription::fetch($NewsletterItem->attribute('subscription_id')); $tpl->setVariable('NewsletterItem', $NewsletterItem); $tpl->setVariable('UserHash', $Params['UserHash']); $tpl->setVariable('subscriptions', $subscription); if ($http->hasPostVariable('OKButton')) { $subscription->unsubscribe(); $siteini = eZINI::instance(); $sender = $siteini->variable('MailSettings', 'EmailSender'); $mail = new eZMail(); $mail->setReceiver($sub['email']); $mail->setSender($sender); $mail->setSubject(ezpI18n::tr('newsletteraddons', "Your subscription removal")); $hostName = eZSys::hostname(); $mailtpl = eZTemplate::instance(); $mailtpl->setVariable('hostname', $hostName); $mailtpl->setVariable('siteaccess', $GLOBALS['eZCurrentAccess']['name']);
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(); } } } }
$MailArray = eZBounce::fetchByOffset($offset, $limit, false, "address"); if (count($MailArray) >= 1) { $bounceDataArray = array(); foreach ($MailArray as $key => $MailBounceData) { $mail = $MailBounceData["address"]; $sb_c = $db->ArrayQuery("SELECT count(*) as 'softbounces' FROM ez_bouncedata WHERE address='{$mail}' and bounce_type = 0"); $hb_c = $db->ArrayQuery("SELECT count(*) as 'hardbounces' FROM ez_bouncedata WHERE address='{$mail}' and bounce_type = 1"); $bounceDataArray[$key]["mail"] = $mail; $bounceDataArray[$key]["sb_count"] = $sb_c[0]["softbounces"]; $bounceDataArray[$key]["hb_count"] = $hb_c[0]["hardbounces"]; $bounceDataArray[$key]["bounces"] = eZBounce::fetchListByAddress($mail); $bounceDataArray[$key]["bounceIDarray"] = array(); foreach ($bounceDataArray[$key]["bounces"] as $key2 => $bounce) { $sendItemBounced = eZSendNewsletterItem::fetch($bounce->ID); array_push($bounceDataArray[$key]["bounceIDarray"], $bounce->ID); $subscriptionObject = eZSubscription::fetch($sendItemBounced->attribute('subscription_id')); if ($subscriptionObject) { $bounceDataArray[$key]["subscriptions"][$key2] = $subscriptionObject; } } } $tpl->setVariable('bounce_data_array', $bounceDataArray); } $tpl->setVariable('statusNames', eZSubscription::statusNameMap()); $Result = array(); $Result['newsletter_menu'] = 'design:parts/content/bounce_menu.tpl'; $Result['left_menu'] = 'design:parts/content/eznewsletter_menu.tpl'; $Result['content'] = $tpl->fetch("design:{$extension}/list_newsletter_bounce.tpl"); $Result['path'] = array(array('url' => false, 'text' => ezpI18n::tr('eznewsletter/list_newsletterbounce', 'View newsletter bounces'))); break; }
function &userData() { $retVal = false; $subscription = eZSubscription::fetch($this->attribute('subscription_id')); if ($subscription) { $userSubscription = eZUserSubscriptionData::fetch($subscription->attribute('email')); if (!$userSubscription) { eZDebug::writeError("User subscription not found for: " . $subscription->attribute('email'), 'eZSendNewsletterItem::userData'); return false; } else { $generic_hash = $userSubscription->attribute('hash'); $retVal = array('firstname' => $subscription->attribute('firstname'), 'name' => $subscription->attribute('name'), 'email' => $subscription->attribute('email'), 'mobile' => $subscription->attribute('mobile'), 'output_format' => $subscription->attribute('output_format'), 'userhash' => $this->attribute('hash'), 'generic_userhash' => $generic_hash); } } return $retVal; }
static function fetchDraft($id, $asObject = true) { $subscription = eZSubscription::fetch($id, eZSubscription::VersionStatusDraft, $asObject); if (!$subscription) { $subscription = eZSubscription::fetch($id, eZSubscription::VersionStatusPublished, $asObject); if ($subscription) { $subscription->setAttribute('version_status', eZSubscription::VersionStatusDraft); $subscription->store(); } } if (!$subscription) { return false; } return $subscription; }