static function process() { $limit = 100; $offset = 0; $availableHandlers = eZNotificationEventFilter::availableHandlers(); do { $eventList = eZNotificationEvent::fetchUnhandledList(array('offset' => $offset, 'length' => $limit)); foreach ($eventList as $event) { $db = eZDB::instance(); $db->begin(); foreach ($availableHandlers as $handler) { if ($handler === false) { eZDebug::writeError("Notification handler does not exist: {$handlerKey}", __METHOD__); } else { $handler->handle($event); } } $itemCountLeft = eZNotificationCollectionItem::fetchCountForEvent($event->attribute('id')); if ($itemCountLeft == 0) { $event->remove(); } else { $event->setAttribute('status', eZNotificationEvent::STATUS_HANDLED); $event->store(); } $db->commit(); } eZContentObject::clearCache(); } while (count($eventList) == $limit); // If less than limit, we're on the last iteration eZNotificationCollection::removeEmpty(); }
function createNotificationEvent($subType = false) { $handler = $this->attribute('handler'); $info = $handler->attribute('info'); $type = $info['type-identifier']; if ($subType) { $type .= '_' . $subType; } $event = eZNotificationEvent::create('ezcollaboration', array('collaboration_id' => $this->attribute('id'), 'collaboration_identifier' => $type)); $event->store(); return $event; }
public static function createNotificationEvent($objectID, $versionNum) { $event = eZNotificationEvent::create('ezpublish', array('object' => $objectID, 'version' => $versionNum)); $event->store(); }
<?php /** * @copyright Copyright (C) 1999-2012 eZ Systems AS. All rights reserved. * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2 * @version 2012.6 * @package kernel */ $http = eZHTTPTool::instance(); $Module = $Params['Module']; $tpl = eZTemplate::factory(); $tpl->setVariable('filter_proccessed', false); $tpl->setVariable('time_event_created', false); if ($http->hasPostVariable('RunFilterButton')) { eZNotificationEventFilter::process(); $tpl->setVariable('filter_proccessed', true); } else { if ($http->hasPostVariable('SpawnTimeEventButton')) { $event = eZNotificationEvent::create('ezcurrenttime', array()); $event->store(); $tpl->setVariable('time_event_created', true); } } $Result = array(); $Result['content'] = $tpl->fetch('design:notification/runfilter.tpl'); $Result['path'] = array(array('url' => false, 'text' => ezpI18n::tr('kernel/notification', 'Notification settings')));
if ( $clean['collaboration'] ) { $cli->output( "Removing all collaboration elements" ); eZCollaborationItem::cleanup(); } if ( $clean['collectedinformation'] ) { $cli->output( "Removing all collected information" ); eZInformationCollection::cleanup(); } if ( $clean['notification'] ) { $cli->output( "Removing all notifications events" ); eZNotificationEvent::cleanup(); eZNotificationCollection::cleanup(); eZNotificationEventFilter::cleanup(); } if ( $clean['searchstats'] ) { $cli->output( "Removing all search statistics" ); eZSearchLog::removeStatistics(); } $script->shutdown(); ?>
function eventContent($eventID) { $event = eZNotificationEvent::fetch($eventID); return array('result' => $event->content()); }
/** * Fetches unhandled notification events as objects, and returns them in an array. * * The optional $limit can be used to set an offset and a limit for the fetch. It is * passed to {@link eZPersistentObject::fetchObjectList()} and should be used in the same way. * * @static * @param array $limit An associative array with limitiations, can contain * - offset - Numerical value defining the start offset for the fetch * - length - Numerical value defining the max number of items to return * @return array An array of eZNotificationEvent objects */ static function fetchUnhandledList($limit = null) { return eZPersistentObject::fetchObjectList(eZNotificationEvent::definition(), null, array('status' => self::STATUS_CREATED), null, $limit, true); }
/** * @param eZNotificationEvent $event * @param array $parameters */ function sendMessage($event, $parameters) { /** @var eZNotificationCollection $collection */ $collection = eZNotificationCollection::fetchForHandler(self::NOTIFICATION_HANDLER_ID, $event->attribute('id'), self::TRANSPORT); if (!$collection) { return; } /** @var eZNotificationCollectionItem[] $items */ //$items = $collection->attribute( 'items_to_send' ); $items = $collection->items(); //print_r($collection); //print_r($items); //die(); if (!$items) { eZDebugSetting::writeDebug('kernel-notification', "No items to send now"); return; } $addressList = array(); foreach ($items as $item) { $addressList[] = $item->attribute('address'); $item->remove(); } $transport = eZNotificationTransport::instance('ezmail'); $transport->send($addressList, $collection->attribute('data_subject'), $collection->attribute('data_text'), null, $parameters); if ($collection->attribute('item_count') == 0) { $collection->remove(); } }
public static function createNotificationEvent($action, $uuid, $list_id) { $event = eZNotificationEvent::create('jaj_newsletter', array('action' => $action, 'uuid' => $uuid, 'list_id' => $list_id)); $event->store(); }