Forums / Setup & design / Notification Handler

Notification Handler

Author Message

Mahesh Arvind

Tuesday 23 December 2003 3:44:18 am

Hi,
I am creating a notification handler. I have created the extensions. This the structure of the extension folder

extension/emailuserextension/notification/handler/emailuserextension
extension/emailuserextension/notification/handler/emailuserextension/emailuserextensionhandler.php
extension/emailuserextension/settings/notification.ini.append

I have changed the site.ini as

[ExtensionSettings]
ActiveExtensions[]=emailuserextension
ActiveExtensions[]=myextension

Do I need to change any other files to activate the extension? Plz Help.

 

Thanks & Regards
Mahesh

Paul Forsyth

Tuesday 23 December 2003 3:58:35 am

Your extension setting is fine.

However, i believe the eZ extension system doesn't currently 'see' notification handlers. It does work with notification events but from my experience handlers are not catered for.

You can activate a handler by entering it in the main settings/notification.ini file, ie:

[NotificationEventHandlerSettings]
RepositoryDirectories[]=kernel/classes/notification/handler/;extension/emailuserextension/notification/handler
AvailableNotificationEventTypes[]=emailuserextension

and this will tell eZ to look for a handler at your location you have given.

see:

http://ez.no/developer/ez_publish_3/bug_reports/stabilise_extension_system

for other extension issues.

paul

Mahesh Arvind

Tuesday 23 December 2003 5:13:00 am

Hi,

Thanks Paul for your answer. I have added

[NotificationEventHandlerSettings]
RepositoryDirectories[]=kernel/classes/notification/handler/;extension/emailuserextension/notification/handler
AvailableNotificationEventTypes[]=emailuserextension
in notification.ini.append in the settings/override directory.

To brief on what i am doing now, I am creating a notification handler which works on object publish events. I want to track when a new user is created and send him a registration mail.

I am creating users in the content section through admin interface. Each time when I create a new user, the register.tpl is not called. It calls user_group.tpl and then ezstring.tpl. Is it possible to call register.tpl after user_group.tpl?

I have created a emailuserhandler.php which is the handler. But, when I turn on debug and see, the notification handler I created is not called. Can anyone tell me how to call this handler.

Can the above mentioned can be done with events?

Thanx.

Thanks & Regards
Mahesh

Paul Forsyth

Tuesday 23 December 2003 5:56:02 am

The handler should be called automatically if it is declared. I should say this is a grey area for me...

But, take a look at this file:

kernel/classes/notification/eznotificationeventfilter.php

It contains two functions of interest.

process() is where the handler is associated with the event.

availableHandlers() picks up the available handlers from the ini file. Notice the lack of an extension setting here, which is why i believe handlers are picked up from extensions.

have you printed out event values from your handlers event function? take a look at a current one like:

kernel/classes/notification/handler/ezgeneraldigest/ezgeneraldigesthandler.php

paul

Mahesh Arvind

Tuesday 23 December 2003 7:13:20 am

Hi,
I have looked at kernel/classes/notification/eznotificationeventfilter.php. Maybe its coming from $repositoryDirectories, which we have mentioned in settings/override/notification.ini.append file.
RepositoryDirectories[]=kernel/classes/notification/handler/;extension/emailuserextension/notification/handler.

I have moved the above in settings/notification.ini.

Its not searching the handler now. But, I get an error message like this if I put them in AvailableNotificationEventTypes. Maybe you are right "However, i believe the eZ extension system doesn't currently 'see' notification handlers."

But have a look at /kernel/classes/notification/handler/. This contains the default notification handlers ezcollaborationnotification, ezgeneraldigest, ezsubtree. I have created a new directory here and put the handler here. But, its not calling it now also. If you notic that default handler directories contain another php file. Do I need to create a similar file for my handler to make it active?

Mahesh

Thanks & Regards
Mahesh

Paul Forsyth

Wednesday 24 December 2003 4:18:05 am

You shouldn't need the extra file. If you look closely you will see that the other file isnt named consistently, and is included by each handler to do something specific for that event. When i looked i saw routines to handle some database tables.

I would look at the php within: kernel/classes/notification/eznotificationeventfilter.php

Try to add some debug/print statments to find the available handlers on line 58. You need to get your hands dirty a little here im afraid :) If you print out the returned availableHandlers you can tell if you handler is being seen or not.

paul

Mahesh Arvind

Wednesday 24 December 2003 5:25:23 am

Hi Paul,

I tested the output from kernel/classes/notification/eznotificationeventfilter.php
It does not refer to the handler. It produces the following error.

Error: eZNotificationEventFilter::loadHandler() Dec 24 2003 05:06:23
Notification handler does not exist: $handlerString

One more strange thing :)
If i change the handler directory from kernel/notification... to extensions then I get four lines of the above error message.
So, I guess in both cases it is not calling the handler.

Mahesh

Thanks & Regards
Mahesh

Paul Forsyth

Wednesday 24 December 2003 5:40:35 am

Just had a thought. The format of the notification.ini file may be wrong. Try this instead:

[NotificationEventHandlerSettings]
RepositoryDirectories[]=kernel/classes/notification/handler/
RepositoryDirectories[]=extension/emailuserextension/notification/handler
AvailableNotificationEventTypes[]=emailuserextension

paul

Mahesh Arvind

Wednesday 24 December 2003 6:07:34 am

Hi Paul,

I have tested with the changed notification.ini file. But, it's again the same problem. It just doesnt seems to be recognizing another notification. There is an extra notification.ini.append in extension/emailuserextension/settings/notification.ini.append. I have removed that file since we have specified them in the main notification.ini. Is this required?

Mahesh

Thanks & Regards
Mahesh

Paul Forsyth

Wednesday 24 December 2003 6:17:20 am

Only for new events.

Im not sure what to suggest next.

When i hit a problem like this i look at the PHP code, so take a closer look at the files i mentioned. Some of the eventfilter code is very simple and a few print statements in the right places will tell you why the ini file is not being read properly.

paul

Mahesh Arvind

Thursday 25 December 2003 8:46:27 pm

Hi Paul,
I debugged the PHP code. I had actually made a mistake in specifying the Repository Directories. Now it's calling the handler.
Thanks.

Thanks & Regards
Mahesh