Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

eznotificationcollection.php
Go to the documentation of this file.
1 <?php
16 class eZNotificationCollection extends eZPersistentObject
17 {
18 static function definition()
19 {
20 return array( "fields" => array( "id" => array( 'name' => 'ID',
21 'datatype' => 'integer',
22 'default' => 0,
23 'required' => true ),
24 "event_id" => array( 'name' => "EventID",
25 'datatype' => 'integer',
26 'default' => 0,
27 'required' => true,
28 'foreign_class' => 'eZNotificationEvent',
29 'foreign_attribute' => 'id',
30 'multiplicity' => '1..*' ),
31 "handler" => array( 'name' => "Handler",
32 'datatype' => 'string',
33 'default' => '',
34 'required' => true ),
35 "transport" => array( 'name' => "Transport",
36 'datatype' => 'string',
37 'default' => '',
38 'required' => true ),
39 "data_subject" => array( 'name' => "DataText1",
40 'datatype' => 'text',
41 'default' => '',
42 'required' => true ),
43 "data_text" => array( 'name' => "DataText2",
44 'datatype' => 'text',
45 'default' => '',
46 'required' => true ) ),
47 "keys" => array( "id" ),
48 "function_attributes" => array( 'items' => 'items',
49 'items_to_send' => 'itemsToSend',
50 'item_count' => 'itemCount' ),
51 "increment_key" => "id",
52 "sort" => array( "id" => "asc" ),
53 "class_name" => "eZNotificationCollection",
54 "name" => "eznotificationcollection" );
55 }
56
57
58 static function create( $eventID, $handler, $transport )
59 {
60 return new eZNotificationCollection( array( 'event_id' => $eventID,
61 'handler' => $handler,
62 'transport' => $transport ) );
63 }
64
65 function addItem( $address, $sendDate = 0 )
66 {
67 $item = eZNotificationCollectionItem::create( $this->attribute( 'id' ), $this->attribute( 'event_id' ), $address, $sendDate = 0 );
68 $item->store();
69 return $item;
70 }
71
72 function items()
73 {
74 return eZPersistentObject::fetchObjectList( eZNotificationCollectionItem::definition(),
75 null, array( 'collection_id' => $this->attribute( 'id' ) ), null,null,
76 true );
77 }
78
79 function itemCount()
80 {
81 $result = eZPersistentObject::fetchObjectList( eZNotificationCollectionItem::definition(),
82 array(),
83 array( 'collection_id' => $this->attribute( 'id' ) ),
84 false,
85 null,
86 false,
87 false,
88 array( array( 'operation' => 'count( * )',
89 'name' => 'count' ) ) );
90 return $result[0]['count'];
91 }
92
93 function itemsToSend()
94 {
95 return eZPersistentObject::fetchObjectList( eZNotificationCollectionItem::definition(),
96 null, array( 'collection_id' => $this->attribute( 'id' ),
97 'send_date' => 0 ),
98 null, null, true );
99 }
100
101 static function fetchForHandler( $handler, $eventID, $transport )
102 {
103 return eZPersistentObject::fetchObject( eZNotificationCollection::definition(), null,
104 array( 'event_id' => $eventID,
105 'handler'=> $handler,
106 'transport' => $transport ) );
107 }
108
109 static function fetchListForHandler( $handler, $eventID, $transport )
110 {
111 return eZPersistentObject::fetchObjectList( eZNotificationCollection::definition(), null,
112 array( 'event_id' => $eventID,
113 'handler'=> $handler,
114 'transport' => $transport ) );
115 }
116
121 static function removeEmpty()
122 {
123 $db = eZDB::instance();
124 if ( $db->databaseName() == 'oracle' ) // fix for compatibility with Oracle versions prior to 9
125 $query = 'SELECT eznotificationcollection.id FROM eznotificationcollection, eznotificationcollection_item
126 WHERE eznotificationcollection.id = eznotificationcollection_item.collection_id(+) AND
127 eznotificationcollection_item.collection_id IS NULL';
128 else
129 $query = 'SELECT eznotificationcollection.id FROM eznotificationcollection
130 LEFT JOIN eznotificationcollection_item ON eznotificationcollection.id=eznotificationcollection_item.collection_id
131 WHERE eznotificationcollection_item.collection_id IS NULL';
132
133 $idArray = $db->arrayQuery( $query );
134
135 $db->begin();
136 foreach ( $idArray as $id )
137 {
138 eZPersistentObject::removeObject( eZNotificationCollection::definition(), array( 'id' => $id['id'] ) );
139 }
140 $db->commit();
141 }
142
149 static function cleanup()
150 {
151 $db = eZDB::instance();
152 $db->begin();
153 eZNotificationCollectionItem::cleanup();
154 $db->query( "DELETE FROM eznotificationcollection" );
155 $db->commit();
156 }
157 }
158
159 ?>
eZDB\instance
static instance( $databaseImplementation=false, $databaseParameters=false, $forceNewInstance=false)
Definition: ezdb.php:117
eZNotificationCollectionItem\create
static create( $collectionID, $eventID, $address, $sendDate=0)
Definition: eznotificationcollectionitem.php:54
eZNotificationCollectionItem\cleanup
static cleanup()
Definition: eznotificationcollectionitem.php:88
eZNotificationCollectionItem\definition
static definition()
Definition: eznotificationcollectionitem.php:19
eZNotificationCollection
The class eZNotificationCollection does.
Definition: eznotificationcollection.php:17
eZNotificationCollection\addItem
addItem( $address, $sendDate=0)
Definition: eznotificationcollection.php:65
eZNotificationCollection\items
items()
Definition: eznotificationcollection.php:72
eZNotificationCollection\fetchForHandler
static fetchForHandler( $handler, $eventID, $transport)
Definition: eznotificationcollection.php:101
eZNotificationCollection\cleanup
static cleanup()
Definition: eznotificationcollection.php:149
eZNotificationCollection\itemCount
itemCount()
Definition: eznotificationcollection.php:79
eZNotificationCollection\create
static create( $eventID, $handler, $transport)
Definition: eznotificationcollection.php:58
eZNotificationCollection\definition
static definition()
Definition: eznotificationcollection.php:18
eZNotificationCollection\itemsToSend
itemsToSend()
Definition: eznotificationcollection.php:93
eZNotificationCollection\removeEmpty
static removeEmpty()
Definition: eznotificationcollection.php:121
eZNotificationCollection\fetchListForHandler
static fetchListForHandler( $handler, $eventID, $transport)
Definition: eznotificationcollection.php:109
eZPersistentObject
Definition: ezpersistentobject.php:33
eZPersistentObject\fetchObject
static fetchObject( $def, $field_filters, $conds, $asObject=true, $grouping=null, $custom_fields=null)
Definition: ezpersistentobject.php:213
eZPersistentObject\removeObject
static removeObject( $def, $conditions=null, $extraConditions=null)
Definition: ezpersistentobject.php:271
eZPersistentObject\attribute
attribute( $attr, $noFunction=false)
Definition: ezpersistentobject.php:1329
eZPersistentObject\fetchObjectList
static fetchObjectList( $def, $field_filters=null, $conds=null, $sorts=null, $limit=null, $asObject=true, $grouping=false, $custom_fields=null, $custom_tables=null, $custom_conds=null)
Definition: ezpersistentobject.php:806
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.