triggering ezpublishtype notification event alternative?

Author Message

Craig Pearson

Thursday 24 May 2007 4:01:21 pm

I am upgrading an ezPublish 3.6.4 site to 3.9.2, Upgrade works fine, no problems there.

However; the original site has a few "custom" patches to the kernel. :)

so In the process of the upgrade, the decision was made to take these "patches" and apply them as ezPublish extensions. All of which have been rather easy to apply... except this one.

In our templates/content/edit.tpl we have replaced the standatrd publish button with the buttons, Publish With Notifications and Publish Without Notifications; which do exactly what they say.

At this point I would ask if anyone already knows of an extended way of doing this, please let me know.

This is what has been done in the past.

* If an item is published and 'Publish WITHOUT Notifications' is pressed, no event is ever created in the eznotificationevent Database table.

* If an If an item is published and 'Publish WITH Notifications' is pressed, an "ezpublish" event is created in the eznotificationevent table (Standard functionality), but only if the content has been significantly modified, ( ie no event is created if only a new location is added to the item... etc )

All of this code has been added to the kernel/content/ezcontentoperationcollection.php file, as follows.

    /*!
     \note Transaction unsafe. If you call several transaction unsafe methods you must enclose
     the calls within a db transaction; thus within db->begin and db->commit.
     */
    function createNotificationEvent( $objectID, $versionNum )
    {
        /*!
         \MOD START
         */
        $http =& eZHTTPTool::instance();
        if ( $http->hasPostVariable( "PublishButton" ) && ( $http->postVariable( "PublishButton" ) == "Publish Without Notification" ) )
          return;
          
        if ( $versionNum > 1 )
          if ( eZContentOperationCollection::objectContentHash( $objectID, $versionNum ) == eZContentOperationCollection::objectContentHash( $objectID, ( $versionNum - 1 ) ) )
            return;
        /*!
         \MOD END
         */
        
        
        include_once( 'kernel/classes/notification/eznotificationevent.php' );
        $event = eZNotificationEvent::create( 'ezpublish', array( 'object' => $objectID,
                                                                   'version' => $versionNum ) );
        $event->store();
    }
    
    
    /*!
     \MOD START
     */
    function objectContentHash( $objectID, $versionNum )
    {
      $current_object =& eZContentObject::fetch( $objectID );
      $data_map = $current_object->fetchDataMap( $versionNum );

      // ensures ordered sequence for the datamap
      usort( $data_map, dataMapSort );
      $checksum = '';

      foreach ( $data_map as $attribute ) {
        
        if( ! isset( $attribute->DataFloat ))      $attribute->DataFloat = 0;
        if( ! isset( $attribute->DataInt ))        $attribute->DataInt = 0;
        if( ! isset( $attribute->DataText ))       $attribute->DataText = '[null]';
        if( ! isset( $attribute->DataTypeCustom )) $attribute->DataTypeCustom = '[null]';
        if( ! isset( $attribute->DataTypeString )) $attribute->DataTypeString = '[null]';
        
        $checksum .= $attribute->DataFloat;
        $checksum .= $attribute->DataInt;
        $checksum .= $attribute->DataText;
        $checksum .= $attribute->DataTypeCustom;
        $checksum .= $attribute->DataTypeString;
      }
      return md5( $checksum );
    }
    
    function dataMapSort( $a, $b )
    {
      $a1 = strtolower( $a->ContentClassAttributeIdentifier );
      $b1 = strtolower( $b->ContentClassAttributeIdentifier );
      return ( $a1 > $b1 ) ? +1 : -1 ;
    }

    /*!
     \ MOD END
     */

this is how this has been done in the past, and I would like to replace this with a custom notification event, however, I cant figure out how to trigger the events, without modifying the kernel modules???

The creation of the notification event is hard coded in the above file as a type of 'ezpublish', so I don't know if it is possible to replace it without modifying the kernel or overriding the entire content module.

I essentially want a nice clean way to not have the event created in the eznotificationevent table, or at least, trigger an event AFTER the "ezpublish" event is run, to mark the event as complete if it fits the above criteria.

Any Ideas?

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.