function execute($process, $event) { $user = eZUser::currentUser(); if ($user->isLoggedIn()) { return eZWorkflowType::STATUS_ACCEPTED; } $http = eZHTTPTool::instance(); // Get current content object ID. $parameters = $process->attribute('parameter_list'); $nodeID = $parameters['node_id']; $node = eZContentObjectTreeNode::fetch($nodeID); if (!$node) { return eZWorkflowType::STATUS_REJECTED; } $objectID = $node->attribute('contentobject_id'); // Get newsletter hash $uri = $GLOBALS['eZRequestedURI']; $userParameters = $uri->userParameters(); $hash = isset($userParameters['hash']) ? $userParameters['hash'] : false; $sendItem = eZSendNewsletterItem::fetchByHash($hash); if ($http->hasSessionVariable('NewsletterNodeIDArray')) { $globalNodeIDList = $http->sessionVariable('NewsletterNodeIDArray'); if (in_array($nodeID, $http->sessionVariable('NewsletterNodeIDArray'))) { $sendID = $http->sessionVariable('NewletterNodeMap_' . $nodeID); $sendItem = eZSendNewsletterItem::fetch($sendID); $sendItem->addObjectRead($objectID); return eZWorkflowType::STATUS_ACCEPTED; } } // Get send item, and check that is contains the object id. if (!$sendItem) { return eZWorkflowType::STATUS_REJECTED; } $sendItemIDList = $sendItem->attribute('newsletter_related_object_list'); if (!$sendItemIDList || !in_array($objectID, $sendItemIDList)) { return eZWorkflowType::STATUS_REJECTED; } $sendNodeIDArray = array(); // Set session variables foreach ($sendItemIDList as $sendObjectID) { $sendObject = eZContentObject::fetch($sendObjectID); if ($sendObject) { foreach ($sendObject->assignedNodes(false) as $nodeArray) { $http->setSessionVariable('NewletterNodeMap_' . $nodeArray['node_id'], $sendItem->attribute('id')); $sendNodeIDArray[] = $nodeArray['node_id']; } } } $globalNodeIDList = array_unique(array_merge($globalNodeIDList, $sendNodeIDArray)); $http->setSessionVariable('NewsletterNodeIDArray', $globalNodeIDList); // Add object read $sendItem->addObjectRead($objectID); return eZWorkflowType::STATUS_ACCEPTED; }
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 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')));