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.

eZ debug

Timing: Jan 18 2025 21:00:29
Script start
Timing: Jan 18 2025 21:00:29
Module start 'layout'
Timing: Jan 18 2025 21:00:29
Module start 'content'
Timing: Jan 18 2025 21:00:30
Module end 'content'
Timing: Jan 18 2025 21:00:30
Script end

Main resources:

Total runtime0.5771 sec
Peak memory usage4,096.0000 KB
Database Queries46

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0060 588.1563152.6563
Module start 'layout' 0.00600.0029 740.812539.5078
Module start 'content' 0.00890.5668 780.3203418.3906
Module end 'content' 0.57570.0014 1,198.710912.0938
Script end 0.5771  1,210.8047 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.5623160.0002
Check MTime0.00130.2295160.0001
Mysql Total
Database connection0.00080.146710.0008
Mysqli_queries0.536492.9523460.0117
Looping result0.00040.0723440.0000
Template Total0.547394.820.2736
Template load0.00200.354420.0010
Template processing0.545294.471520.2726
Template load and register function0.00020.031910.0002
states
state_id_array0.00130.221810.0013
state_identifier_array0.00200.341720.0010
Override
Cache load0.00160.2772170.0001
Sytem overhead
Fetch class attribute can translate value0.00080.134510.0008
Fetch class attribute name0.00090.150010.0009
XML
Image XML parsing0.00010.019210.0001
class_abstraction
Instantiating content class attribute0.00000.000710.0000
General
dbfile0.00080.1385100.0001
String conversion0.00000.001640.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
1content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
2content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 6
 Number of unique templates used: 5

Time used to render debug report: 0.0001 secs