Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

eznotificationeventtype.php
Go to the documentation of this file.
1 <?php
17 class eZNotificationEventType
18 {
22 public $NotificationEventTypeString;
23 public $Attributes;
29 public function __construct( $notificationEventTypeString )
30 {
31 $this->NotificationEventTypeString = $notificationEventTypeString;
32 }
33
34 function initializeEvent( $event, $params )
35 {
36 }
37
43 static function create( $notificationEventTypeString )
44 {
45 $types =& $GLOBALS["eZNotificationEventTypes"];
46 if( !isset( $types[$notificationEventTypeString] ) )
47 {
48 eZDebugSetting::writeDebug( 'kernel-notification', $types, 'notification types' );
49 eZNotificationEventType::loadAndRegisterType( $notificationEventTypeString );
50 eZDebugSetting::writeDebug( 'kernel-notification', $types, 'notification types 2' );
51 }
52 $def = null;
53 if ( isset( $types[$notificationEventTypeString] ) )
54 {
55 $className = $types[$notificationEventTypeString];
56 $def =& $GLOBALS["eZNotificationEventTypeObjects"][$notificationEventTypeString];
57
58 if ( !is_object( $def ) || strtolower( get_class( $def ) ) != $className )
59 {
60 $def = new $className();
61 }
62 }
63 return $def;
64 }
65
66
67 function attributes()
68 {
69 return array_merge( array( 'description' ),
70 array_keys( $this->Attributes ) );
71 }
72
73 function hasAttribute( $attr )
74 {
75 return in_array( $attr, $this->attributes() );
76 }
77
78 function attribute( $attr )
79 {
80 if ( $attr == "description" )
81 {
82 return $this->eventDescription();
83 }
84 if ( isset( $this->Attributes[$attr] ) )
85 {
86 return $this->Attributes[$attr];
87 }
88
89 eZDebug::writeError( "Attribute '$attr' does not exist", __METHOD__ );
90 return null;
91 }
92
93 function eventDescription()
94 {
95 return $this->Attributes["name"];
96 }
97
98 function execute( $event )
99 {
100 }
101
102 function eventContent( $event )
103 {
104 return "";
105 }
106
107 static function allowedTypes()
108 {
109 $allowedTypes = $GLOBALS["eZNotificationEventTypeAllowedTypes"];
110 if ( !is_array( $allowedTypes ) )
111 {
112 $notificationINI = eZINI::instance( 'notification.ini' );
113 $eventTypes = $notificationINI->variable( 'NotificationEventTypeSettings', 'AvailableEventTypes' );
114 $allowedTypes = array_unique( $eventTypes );
115 }
116 return $allowedTypes;
117 }
118
119 static function loadAndRegisterAllTypes()
120 {
121 $allowedTypes = eZNotificationEventType::allowedTypes();
122 foreach( $allowedTypes as $type )
123 {
124 eZNotificationEventType::loadAndRegisterType( $type );
125 }
126 }
127
128 static function loadAndRegisterType( $type )
129 {
130 $types = $GLOBALS["eZNotificationEventTypes"];
131 if ( isset( $types[$type] ) )
132 {
133 eZDebug::writeError( "Notification event type already registered: $type", __METHOD__ );
134 return false;
135 }
136
137 $baseDirectory = eZExtension::baseDirectory();
138 $notificationINI = eZINI::instance( 'notification.ini' );
139 $repositoryDirectories = $notificationINI->variable( 'NotificationEventTypeSettings', 'RepositoryDirectories' );
140 $extensionDirectories = $notificationINI->variable( 'NotificationEventTypeSettings', 'ExtensionDirectories' );
141 foreach ( $extensionDirectories as $extensionDirectory )
142 {
143 $extensionPath = $baseDirectory . '/' . $extensionDirectory . '/notificationtypes';
144 if ( file_exists( $extensionPath ) )
145 $repositoryDirectories[] = $extensionPath;
146 }
147 $foundEventType = false;
148 foreach ( $repositoryDirectories as $repositoryDirectory )
149 {
150 $includeFile = "$repositoryDirectory/$type/" . $type . "type.php";
151 if ( file_exists( $includeFile ) )
152 {
153 $foundEventType = true;
154 break;
155 }
156 }
157 if ( !$foundEventType )
158 {
159 eZDebug::writeError( "Notification event type not found: $type, searched in these directories: " . implode( ', ', $repositoryDirectories ), __METHOD__ );
160 return false;
161 }
162 include_once( $includeFile );
163 return true;
164 }
165
166 static function register( $notificationTypeString, $className )
167 {
168 if ( !isset( $GLOBALS["eZNotificationEventTypes"] ) || !is_array( $GLOBALS["eZNotificationEventTypes"] ) )
169 {
170 $types = array();
171 }
172 $GLOBALS["eZNotificationEventTypes"][$notificationTypeString] = $className;
173 }
174
175
176
177
178 }
179
180 ?>
eZDebugSetting\writeDebug
static writeDebug( $conditionName, $string, $label="")
Definition: ezdebugsetting.php:127
eZDebug\writeError
static writeError( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:545
eZExtension\baseDirectory
static baseDirectory(eZINI|null $siteINI=null)
Definition: ezextension.php:39
eZNotificationEventType
The class eZNotificationEventType does.
Definition: eznotificationeventtype.php:18
eZNotificationEventType\hasAttribute
hasAttribute( $attr)
Definition: eznotificationeventtype.php:73
eZNotificationEventType\eventDescription
eventDescription()
Definition: eznotificationeventtype.php:93
eZNotificationEventType\attribute
attribute( $attr)
Definition: eznotificationeventtype.php:78
eZNotificationEventType\eventContent
eventContent( $event)
Definition: eznotificationeventtype.php:102
eZNotificationEventType\loadAndRegisterAllTypes
static loadAndRegisterAllTypes()
Definition: eznotificationeventtype.php:119
eZNotificationEventType\attributes
attributes()
Definition: eznotificationeventtype.php:67
eZNotificationEventType\initializeEvent
initializeEvent( $event, $params)
Definition: eznotificationeventtype.php:34
eZNotificationEventType\__construct
__construct( $notificationEventTypeString)
Definition: eznotificationeventtype.php:29
eZNotificationEventType\execute
execute( $event)
Definition: eznotificationeventtype.php:98
eZNotificationEventType\loadAndRegisterType
static loadAndRegisterType( $type)
Definition: eznotificationeventtype.php:128
eZNotificationEventType\allowedTypes
static allowedTypes()
Definition: eznotificationeventtype.php:107
eZNotificationEventType\create
static create( $notificationEventTypeString)
Definition: eznotificationeventtype.php:43
eZNotificationEventType\$NotificationEventTypeString
$NotificationEventTypeString
Definition: eznotificationeventtype.php:22
eZNotificationEventType\$Attributes
$Attributes
Definition: eznotificationeventtype.php:23
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.