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 include_once( 'kernel/classes/notification/eznotificationeventtype.php' );
00040 include_once( 'kernel/classes/ezpersistentobject.php' );
00041
00042 define( 'EZ_NOTIFICATIONEVENT_STATUS_CREATED', 0 );
00043 define( 'EZ_NOTIFICATIONEVENT_STATUS_HANDLED', 1 );
00044
00045 class eZNotificationEvent extends eZPersistentObject
00046 {
00047
00048
00049
00050 function eZNotificationEvent( $row = array() )
00051 {
00052 $this->eZPersistentObject( $row );
00053 $this->TypeString = $this->attribute( 'event_type_string' );
00054 }
00055
00056 function definition()
00057 {
00058 return array( "fields" => array( "id" => array( 'name' => 'ID',
00059 'datatype' => 'integer',
00060 'default' => 0,
00061 'required' => true ),
00062 "status" => array( 'name' => 'Status',
00063 'datatype' => 'integer',
00064 'default' => 0,
00065 'required' => true ),
00066 "event_type_string" => array( 'name' => "EventTypeString",
00067 'datatype' => 'string',
00068 'default' => '',
00069 'required' => true ),
00070 "data_int1" => array( 'name' => "DataInt1",
00071 'datatype' => 'integer',
00072 'default' => 0,
00073 'required' => true ),
00074 "data_int2" => array( 'name' => "DataInt2",
00075 'datatype' => 'integer',
00076 'default' => 0,
00077 'required' => true ),
00078 "data_int3" => array( 'name' => "DataInt3",
00079 'datatype' => 'integer',
00080 'default' => 0,
00081 'required' => true ),
00082 "data_int4" => array( 'name' => "DataInt4",
00083 'datatype' => 'integer',
00084 'default' => 0,
00085 'required' => true ),
00086 "data_text1" => array( 'name' => "DataText1",
00087 'datatype' => 'text',
00088 'default' => '',
00089 'required' => true ),
00090 "data_text2" => array( 'name' => "DataText2",
00091 'datatype' => 'text',
00092 'default' => '',
00093 'required' => true ),
00094 "data_text3" => array( 'name' => "DataText3",
00095 'datatype' => 'text',
00096 'default' => '',
00097 'required' => true ),
00098 "data_text4" => array( 'name' => "DataText4",
00099 'datatype' => 'text',
00100 'default' => '',
00101 'required' => true ) ),
00102 "keys" => array( "id" ),
00103 "function_attributes" => array( 'content' => 'content' ),
00104 "increment_key" => "id",
00105 "sort" => array( "id" => "asc" ),
00106 "class_name" => "eZNotificationEvent",
00107 "name" => "eznotificationevent" );
00108 }
00109
00110 function create( $type, $params = array() )
00111 {
00112 $row = array(
00113 "id" => null,
00114 'event_type_string' => $type,
00115 'data_int1' => 0,
00116 'data_int2' => 0,
00117 'data_int3' => 0,
00118 'data_int4' => 0,
00119 'data_text1' => '',
00120 'data_text2' => '',
00121 'data_text3' => '',
00122 'data_text4' => '' );
00123 $event = new eZNotificationEvent( $row );
00124 eZDebugSetting::writeDebug( 'kernel-notification', $event, "event" );
00125 $event->initializeEventType( $params );
00126 return $event;
00127 }
00128
00129 function initializeEventType( $params = array() )
00130 {
00131 $eventType =& $this->eventType();
00132 $eventType->initializeEvent( $this, $params );
00133 eZDebugSetting::writeDebug( 'kernel-notification', $this, 'event after initialization' );
00134 }
00135
00136 function &eventType()
00137 {
00138 if ( ! isset ( $this->EventType ) )
00139 {
00140 $this->EventType =& eZNotificationEventType::create( $this->TypeString );
00141 }
00142 return $this->EventType;
00143 }
00144
00145
00146
00147
00148
00149 function &content()
00150 {
00151 if ( $this->Content === null )
00152 {
00153 $eventType =& $this->eventType();
00154 $this->Content = $eventType->eventContent( $this );
00155 }
00156 return $this->Content;
00157 }
00158
00159
00160
00161
00162 function setContent( $content )
00163 {
00164 $this->Content =& $content;
00165 }
00166
00167 function fetchList()
00168 {
00169 return eZPersistentObject::fetchObjectList( eZNotificationEvent::definition(),
00170 null, null, null,null,
00171 true );
00172 }
00173
00174 function fetch( $eventID )
00175 {
00176 return eZPersistentObject::fetchObject( eZNotificationEvent::definition(),
00177 null,
00178 array( 'id' => $eventID ) );
00179 }
00180
00181 function fetchUnhandledList()
00182 {
00183 return eZPersistentObject::fetchObjectList( eZNotificationEvent::definition(),
00184 null, array( 'status' => EZ_NOTIFICATIONEVENT_STATUS_CREATED ), null,null,
00185 true );
00186 }
00187
00188
00189
00190
00191
00192 function cleanup()
00193 {
00194 $db =& eZDB::instance();
00195 $db->query( "DELETE FROM eznotificationevent" );
00196 }
00197
00198 var $Content = null;
00199 }
00200
00201 ?>