[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZNotificationCollection class 4 // 5 // Created on: <09-May-2003 16:07:24 sp> 6 // 7 // SOFTWARE NAME: eZ publish 8 // SOFTWARE RELEASE: 3.9.0 9 // BUILD VERSION: 17785 10 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 11 // SOFTWARE LICENSE: GNU General Public License v2.0 12 // NOTICE: > 13 // This program is free software; you can redistribute it and/or 14 // modify it under the terms of version 2.0 of the GNU General 15 // Public License as published by the Free Software Foundation. 16 // 17 // This program is distributed in the hope that it will be useful, 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 21 // 22 // You should have received a copy of version 2.0 of the GNU General 23 // Public License along with this program; if not, write to the Free 24 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 25 // MA 02110-1301, USA. 26 // 27 // 28 29 /*! \file eznotificationcollection.php 30 */ 31 32 /*! 33 \class eZNotificationCollection eznotificationcollection.php 34 \brief The class eZNotificationCollection does 35 36 */ 37 include_once ( 'kernel/classes/notification/eznotificationcollectionitem.php' ); 38 39 class eZNotificationCollection extends eZPersistentObject 40 { 41 /*! 42 Constructor 43 */ 44 function eZNotificationCollection( $row = array() ) 45 { 46 $this->eZPersistentObject( $row ); 47 } 48 49 function definition() 50 { 51 return array( "fields" => array( "id" => array( 'name' => 'ID', 52 'datatype' => 'integer', 53 'default' => 0, 54 'required' => true ), 55 "event_id" => array( 'name' => "EventID", 56 'datatype' => 'integer', 57 'default' => 0, 58 'required' => true, 59 'foreign_class' => 'eZNotificationEvent', 60 'foreign_attribute' => 'id', 61 'multiplicity' => '1..*' ), 62 "handler" => array( 'name' => "Handler", 63 'datatype' => 'string', 64 'default' => '', 65 'required' => true ), 66 "transport" => array( 'name' => "Transport", 67 'datatype' => 'string', 68 'default' => '', 69 'required' => true ), 70 "data_subject" => array( 'name' => "DataText1", 71 'datatype' => 'text', 72 'default' => '', 73 'required' => true ), 74 "data_text" => array( 'name' => "DataText2", 75 'datatype' => 'text', 76 'default' => '', 77 'required' => true ) ), 78 "keys" => array( "id" ), 79 "function_attributes" => array( 'items' => 'items', 80 'items_to_send' => 'itemsToSend', 81 'item_count' => 'itemCount' ), 82 "increment_key" => "id", 83 "sort" => array( "id" => "asc" ), 84 "class_name" => "eZNotificationCollection", 85 "name" => "eznotificationcollection" ); 86 } 87 88 89 function create( $eventID, $handler, $transport ) 90 { 91 return new eZNotificationCollection( array( 'event_id' => $eventID, 92 'handler' => $handler, 93 'transport' => $transport ) ); 94 } 95 96 function addItem( $address, $sendDate = 0 ) 97 { 98 $item = eZNotificationCollectionItem::create( $this->attribute( 'id' ), $this->attribute( 'event_id' ), $address, $sendDate = 0 ); 99 $item->store(); 100 return $item; 101 } 102 103 function &items() 104 { 105 $items = eZPersistentObject::fetchObjectList( eZNotificationCollectionItem::definition(), 106 null, array( 'collection_id' => $this->attribute( 'id' ) ), null,null, 107 true ); 108 return $items; 109 } 110 111 function &itemCount() 112 { 113 $result = eZPersistentObject::fetchObjectList( eZNotificationCollectionItem::definition(), 114 array(), array( 'collection_id' => $this->attribute( 'id' ) ), array(),null, 115 false,false, array( array( 'operation' => 'count(*)', 116 'name' => 'count' ) ) ); 117 return $result[0]['count']; 118 } 119 120 function &itemsToSend() 121 { 122 $items = eZPersistentObject::fetchObjectList( eZNotificationCollectionItem::definition(), 123 null, array( 'collection_id' => $this->attribute( 'id' ), 124 'send_date' => 0 ), 125 null, null, true ); 126 return $items; 127 } 128 129 function fetchForHandler( $handler, $eventID, $transport ) 130 { 131 return eZPersistentObject::fetchObject( eZNotificationCollection::definition(), null, 132 array( 'event_id' => $eventID, 133 'handler'=> $handler, 134 'transport' => $transport ) ); 135 } 136 137 function fetchListForHandler( $handler, $eventID, $transport ) 138 { 139 return eZPersistentObject::fetchObjectList( eZNotificationCollection::definition(), null, 140 array( 'event_id' => $eventID, 141 'handler'=> $handler, 142 'transport' => $transport ) ); 143 } 144 145 /*! 146 \note Transaction unsafe. If you call several transaction unsafe methods you must enclose 147 the calls within a db transaction; thus within db->begin and db->commit. 148 */ 149 function removeEmpty() 150 { 151 $db =& eZDB::instance(); 152 if ( $db->databaseName() == 'oracle' ) // fix for compatibility with Oracle versions prior to 9 153 $query = 'SELECT eznotificationcollection.id FROM eznotificationcollection, eznotificationcollection_item 154 WHERE eznotificationcollection.id = eznotificationcollection_item.collection_id(+) AND 155 eznotificationcollection_item.collection_id IS NULL'; 156 else 157 $query = 'SELECT eznotificationcollection.id FROM eznotificationcollection 158 LEFT JOIN eznotificationcollection_item ON eznotificationcollection.id=eznotificationcollection_item.collection_id 159 WHERE eznotificationcollection_item.collection_id IS NULL'; 160 161 $idArray = $db->arrayQuery( $query ); 162 163 $db->begin(); 164 foreach ( $idArray as $id ) 165 { 166 eZPersistentObject::removeObject( eZNotificationCollection::definition(), array( 'id' => $id['id'] ) ); 167 } 168 $db->commit(); 169 } 170 171 /*! 172 \static 173 Removes all notification collections. 174 \note Transaction unsafe. If you call several transaction unsafe methods you must enclose 175 the calls within a db transaction; thus within db->begin and db->commit. 176 */ 177 function cleanup() 178 { 179 $db =& eZDB::instance(); 180 $db->begin(); 181 eZNotificationCollectionItem::cleanup(); 182 $db->query( "DELETE FROM eznotificationcollection" ); 183 $db->commit(); 184 } 185 } 186 187 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |