|
eZ Publish
[4.0]
|
00001 <?php 00002 // 00003 // Definition of eZNotificationEvent class 00004 // 00005 // Created on: <09-May-2003 16:03:28 sp> 00006 // 00007 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00008 // SOFTWARE NAME: eZ Publish 00009 // SOFTWARE RELEASE: 4.0.x 00010 // COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS 00011 // SOFTWARE LICENSE: GNU General Public License v2.0 00012 // NOTICE: > 00013 // This program is free software; you can redistribute it and/or 00014 // modify it under the terms of version 2.0 of the GNU General 00015 // Public License as published by the Free Software Foundation. 00016 // 00017 // This program is distributed in the hope that it will be useful, 00018 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 // GNU General Public License for more details. 00021 // 00022 // You should have received a copy of version 2.0 of the GNU General 00023 // Public License along with this program; if not, write to the Free 00024 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00025 // MA 02110-1301, USA. 00026 // 00027 // 00028 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00029 // 00030 00031 /*! \file eznotificationevent.php 00032 */ 00033 00034 /*! 00035 \class eZNotificationEvent eznotificationevent.php 00036 \brief The class eZNotificationEvent does 00037 00038 */ 00039 //include_once( 'kernel/classes/notification/eznotificationeventtype.php' ); 00040 //include_once( 'kernel/classes/ezpersistentobject.php' ); 00041 00042 class eZNotificationEvent extends eZPersistentObject 00043 { 00044 const STATUS_CREATED = 0; 00045 const STATUS_HANDLED = 1; 00046 00047 /*! 00048 Constructor 00049 */ 00050 function eZNotificationEvent( $row = array() ) 00051 { 00052 $this->eZPersistentObject( $row ); 00053 $this->TypeString = $this->attribute( 'event_type_string' ); 00054 } 00055 00056 static 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 static 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 Returns the content for this event. 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 Sets the content for the current event 00161 */ 00162 function setContent( $content ) 00163 { 00164 $this->Content = $content; 00165 } 00166 00167 static function fetchList() 00168 { 00169 return eZPersistentObject::fetchObjectList( eZNotificationEvent::definition(), 00170 null, null, null,null, 00171 true ); 00172 } 00173 00174 static function fetch( $eventID ) 00175 { 00176 return eZPersistentObject::fetchObject( eZNotificationEvent::definition(), 00177 null, 00178 array( 'id' => $eventID ) ); 00179 } 00180 00181 static function fetchUnhandledList() 00182 { 00183 return eZPersistentObject::fetchObjectList( eZNotificationEvent::definition(), 00184 null, array( 'status' => self::STATUS_CREATED ), null,null, 00185 true ); 00186 } 00187 00188 /*! 00189 \static 00190 Removes all notification events. 00191 */ 00192 static function cleanup() 00193 { 00194 $db = eZDB::instance(); 00195 $db->query( "DELETE FROM eznotificationevent" ); 00196 } 00197 00198 public $Content = null; 00199 } 00200 00201 ?>