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();
 }
 static function fetchCountForEvent( $eventID )
 {
     $result = eZPersistentObject::fetchObjectList( eZNotificationCollectionItem::definition(),
                                                    array(),
                                                    array( 'event_id' => $eventID ),
                                                    false,
                                                    null,
                                                    false,
                                                    false,
                                                    array( array( 'operation' => 'count( * )',
                                                                  'name' => 'count' ) ) );
     return $result[0]['count'];
 }
 static function cleanup()
 {
     $db = eZDB::instance();
     $db->begin();
     eZNotificationCollectionItem::cleanup();
     $db->query("DELETE FROM eznotificationcollection");
     $db->commit();
 }
 function fetchUsersForDigest($timestamp)
 {
     return eZPersistentObject::fetchObjectList(eZNotificationCollectionItem::definition(), array(), array('send_date' => array('', array(1, $timestamp))), array('address' => 'asc'), null, false, false, array(array('operation' => 'distinct address')));
 }