Forums / Developer / Customise notifications

Customise notifications

Author Message

Dries Samyn

Wednesday 15 June 2005 7:06:55 am

Hi,

I posted this in the general forum, but it might fit better here:

We have notification set up so that a user get notified whenever a new article is created in a certain folder.
However, there are 2 issues:
- A notification is send when a new folder is created
- A notification is send when the article is edited

Is there any way you can set "filters" or something to say "only notify if a new node of type article is being created" or something similar?

Or does anybody have any example of "customised" notifications that could help me?

Thanks,

Dries.

Paul Borgermans

Wednesday 15 June 2005 10:56:14 am

Dries,

Please file this as a suggestion or enhancement in the bug tracker as this is not possible now without tweaking the notification system.

It was also discussed a bit during the summer camp

Regards

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Dries Samyn

Thursday 16 June 2005 2:44:13 am

Thanks Paul.
I have now added it as a suggestion.

Is there anybody who could point me to where to tweak the notification system so to implement this?

Regards,

Dries.

Paul Borgermans

Thursday 16 June 2005 3:17:35 am

I think I found it (at least it works like you want here on a live ezp 3.4.6 site):

in file kernel/classes/notification/handler/ezsubtree/ezsubtreehandler.php

around line 122 uncomment the part that checks for an updated version.

So change

...

if (  //$versionObject->attribute( 'version' ) != 1 ||
             $versionObject->attribute( 'version' ) != $contentObject->attribute( 'current_version' ) )
        {
            return EZ_NOTIFICATIONEVENTHANDLER_EVENT_SKIPPED;
        }

....

to

...

if (  $versionObject->attribute( 'version' ) != 1 ||
             $versionObject->attribute( 'version' ) != $contentObject->attribute( 'current_version' ) )
        {
            return EZ_NOTIFICATIONEVENTHANDLER_EVENT_SKIPPED;
        }

....

hth

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Paul Borgermans

Thursday 16 June 2005 3:22:34 am

By consequence, it is easy to change the behaviour according to some scenarios:

- allow the user to have an option to receive updates as well
- turn it on/off globally for notifying updates
- turn notifications off temporarily globally, for a certain node/object or a subtree

What do you think?

Anyone volunteering or should I do it?

Regards

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Dries Samyn

Thursday 16 June 2005 5:21:40 am

Thanks for the pointers Paul.
I've managed to do what I wanted to do by implementing the code you gave, and also by changing:

if ( !$contentClass )
            return EZ_NOTIFICATIONEVENTHANDLER_EVENT_SKIPPED;

with

if ( !$contentClass ||
        	$contentClass->attribute( 'name' )!="News Article" )
        {
            return EZ_NOTIFICATIONEVENTHANDLER_EVENT_SKIPPED;
        }

where obviously "News Article" is the name of the content class of the content that I want to be queued for notifications.
This works fine. It'd be great, as a suggestion, if in a future release these things could be configured in the notification ini file.

Thanks again for the help.

Dries.

Andy Caiger

Wednesday 29 June 2011 10:59:12 pm

Six years later, is it possible to do this with eZ Publish out of the box, or do we still have to modify the kernel PHP? Filtering notifications on class or on new objects versus existing objects (as we can do using the publish workflow) seems a very useful thing to be able to do. Is it possible now?

EAB - Integrated Internet Success
Offices in England, France & China.
http://www.eab.co.uk http://www.eab-china.com http://www.eab-france.com