|
eZ Publish
[4.0]
|
00001 <?php 00002 // 00003 // Definition of eZNotificationCollectionItem class 00004 // 00005 // Created on: <09-May-2003 16:08:18 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 eznotificationcollectionitem.php 00032 */ 00033 00034 /*! 00035 \class eZNotificationCollectionItem eznotificationcollectionitem.php 00036 \brief The class eZNotificationCollectionItem does 00037 00038 */ 00039 00040 //include_once( "kernel/classes/ezpersistentobject.php" ); 00041 00042 class eZNotificationCollectionItem extends eZPersistentObject 00043 { 00044 /*! 00045 Constructor 00046 */ 00047 function eZNotificationCollectionItem( $row = array() ) 00048 { 00049 $this->eZPersistentObject( $row ); 00050 } 00051 00052 static 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 static 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 static 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 static 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 \static 00119 Removes all notification collection items. 00120 */ 00121 static function cleanup() 00122 { 00123 $db = eZDB::instance(); 00124 $db->query( "DELETE FROM eznotificationcollection_item" ); 00125 } 00126 } 00127 00128 ?>