Forums / Setup & design / triggering ezpublishtype notification event alternative?

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?

eZ debug

Timing: Jan 18 2025 18:37:51
Script start
Timing: Jan 18 2025 18:37:51
Module start 'content'
Timing: Jan 18 2025 18:37:51
Module end 'content'
Timing: Jan 18 2025 18:37:52
Script end

Main resources:

Total runtime0.1632 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0095 591.5859180.8125
Module start 'content' 0.00950.0066 772.398493.8984
Module end 'content' 0.01610.1470 866.2969529.4219
Script end 0.1631  1,395.7188 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00412.5201200.0002
Check MTime0.00150.8922200.0001
Mysql Total
Database connection0.00090.522810.0009
Mysqli_queries0.114670.23621410.0008
Looping result0.00130.78371390.0000
Template Total0.146589.810.1465
Template load0.00100.608610.0010
Template processing0.145589.149310.1455
Override
Cache load0.00070.433310.0007
Sytem overhead
Fetch class attribute can translate value0.00080.515410.0008
XML
Image XML parsing0.00030.162510.0003
General
dbfile0.00342.0824200.0002
String conversion0.00000.006030.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs