00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 include_once( "kernel/classes/ezpersistentobject.php" );
00041
00042 class eZNotificationCollectionItem extends eZPersistentObject
00043 {
00044
00045
00046
00047 function eZNotificationCollectionItem( $row = array() )
00048 {
00049 $this->eZPersistentObject( $row );
00050 }
00051
00052 function definition()
00053 {
00054 return array( "fields" => array( "id" => array( 'name' => 'ID',
00055 'datatype' => 'integer',
00056 'default' => 0,
00057 'required' => true ),
00058 "collection_id" => array( 'name' => "CollectionID",
00059 'datatype' => 'integer',
00060 'default' => 0,
00061 'required' => true,
00062 'foreign_class' => 'eZNotificationCollection',
00063 'foreign_attribute' => 'id',
00064 'multiplicity' => '1..*' ),
00065 "event_id" => array( 'name' => "EventID",
00066 'datatype' => 'integer',
00067 'default' => 0,
00068 'required' => true,
00069 'foreign_class' => 'eZNotificationEvent',
00070 'foreign_attribute' => 'id',
00071 'multiplicity' => '1..*' ),
00072 "address" => array( 'name' => "Address",
00073 'datatype' => 'string',
00074 'default' => '',
00075 'required' => true ),
00076 "send_date" => array( 'name' => "SendDate",
00077 'datatype' => 'integer',
00078 'default' => 0,
00079 'required' => true ) ),
00080 "keys" => array( "id" ),
00081 "increment_key" => "id",
00082 "sort" => array( "id" => "asc" ),
00083 "class_name" => "eZNotificationCollectionItem",
00084 "name" => "eznotificationcollection_item" );
00085 }
00086
00087 function create( $collectionID, $eventID, $address, $sendDate = 0 )
00088 {
00089 return new eZNotificationCollectionItem( array( 'collection_id' => $collectionID,
00090 'event_id' => $eventID,
00091 'address' => $address,
00092 'send_date' => $sendDate ) );
00093 }
00094
00095 function fetchByDate( $date )
00096 {
00097 return eZPersistentObject::fetchObjectList( eZNotificationCollectionItem::definition(),
00098 null, array( 'send_date' => array( '<', $date ),
00099 'send_date' => array( '!=', 0 ) ) , null, null,
00100 true );
00101 }
00102
00103 function fetchCountForEvent( $eventID )
00104 {
00105 $result = eZPersistentObject::fetchObjectList( eZNotificationCollectionItem::definition(),
00106 array(),
00107 array( 'event_id' => $eventID ),
00108 false,
00109 null,
00110 false,
00111 false,
00112 array( array( 'operation' => 'count( * )',
00113 'name' => 'count' ) ) );
00114 return $result[0]['count'];
00115 }
00116
00117
00118
00119
00120
00121 function cleanup()
00122 {
00123 $db =& eZDB::instance();
00124 $db->query( "DELETE FROM eznotificationcollection_item" );
00125 }
00126 }
00127
00128 ?>