In-Portal Issue Tracker - In-Portal CMS
Viewing Issue Advanced Details
397 [In-Portal CMS] Data Management task always 2009-10-17 07:00 2012-07-25 05:33
alex  
alex  
normal  
closed 5.0.1  
fixed  
 
none 5.2.0-B1  
2
0000397: Ability to work with main event from OnBefore/OnAfter type events called from kDBItem class
There are two type of events:
1. external events - events, that could be called from outside of the script, by specifying their name in url
2. internal events - events, that are called by internal subroutines only and in most cases are indirectly related to external event being called.

For example OnCreate event is pure external and it allows to create record in database based on form data form request. On the other hand OnBeforeItemCreate is pure internal event, that is called before attempt is made to create database record. This internal event is indirectly called from OnCreate event by calling kDBItem::Create method.

All seems normal at first glance, but in fact it's not. There is no way to access OnCreate event $event object from OnBeforeItemCreate event. One of purposes of such type of access is to change redirect parameters or main event. For example in case of TestField value is equals to 5 we want to redirect user to non-default template after record is successful created.
How I see implementation:
1. add 2 methods to kDBItem class: setReferrerEvent(&$event) and removeReferrerEvent()
2. when event of any type is called from kDBItem class (via raiseEvent method), then we set it's MasterEvent attribute to referrer event in case if any was set before.
3. from OnBeforeItemCreate event OnCreate event will be accessed via $event->MasterEvent.
related to 0000898closed  (5.2.0)alex Admin Interface for managing "Permission Types" 
patch ability_to_use_main_event_from_internal_events.patch (3,492) 2011-08-24 07:39
http://tracker.in-portal.org/file_download.php?file_id=1115&type=bug
patch ability_to_use_main_event_from_internal_events_520.patch (5,485) 2011-10-03 04:48
http://tracker.in-portal.org/file_download.php?file_id=1180&type=bug
patch temp_handler_ignored_parent_event_fix.patch (8,470) 2011-10-12 03:50
http://tracker.in-portal.org/file_download.php?file_id=1231&type=bug
Issue History
2012-07-25 05:33 alex Note Added: 0005111
2012-07-25 05:33 alex Status resolved => closed
2011-10-22 05:27 alex Estimate Points => 2
2011-10-12 03:54 alex Relationship added related to 0000898
2011-10-12 03:52 alex Changeset attached 5.2.x r14657
2011-10-12 03:51 alex Note Added: 0004042
2011-10-12 03:50 alex File Added: temp_handler_ignored_parent_event_fix.patch
2011-10-03 04:49 alex Note Added: 0003964
2011-10-03 04:49 alex Status reviewed and tested => resolved
2011-10-03 04:49 alex Fixed in Version => 5.2.0-B1
2011-10-03 04:49 alex Resolution open => fixed
2011-10-03 04:49 alex Assigned To !COMMUNITY => alex
2011-10-03 04:49 alex Changeset attached 5.2.x r14608
2011-10-03 04:48 alex Note Added: 0003963
2011-10-03 04:48 alex Status needs testing => reviewed and tested
2011-10-03 04:48 alex Time Estimate Removed 1 =>
2011-10-03 04:48 alex Status needs work => needs testing
2011-10-03 04:48 alex File Added: ability_to_use_main_event_from_internal_events_520.patch
2011-09-26 04:53 alex Time Estimate Added 1
2011-09-23 20:43 Dmitry Note Added: 0003880
2011-09-23 20:43 Dmitry Status needs testing => needs work
2011-08-24 07:42 alex Note Added: 0003698
2011-08-24 07:42 alex Assigned To alex => !COMMUNITY
2011-08-24 07:42 alex Developer => alex
2011-08-24 07:42 alex Status needs work => needs testing
2011-08-24 07:39 alex Target Version Icebox => 5.2.0
2011-08-24 07:39 alex File Added: ability_to_use_main_event_from_internal_events.patch
2009-11-25 01:19 Dmitry Assigned To => alex
2009-11-25 01:19 Dmitry Status active => needs work
2009-10-17 07:01 alex Target Version => Icebox
2009-10-17 07:00 alex New Issue

Notes
(0003698)
alex   
2011-08-24 07:42   
Now events, that are called using kDBItem::raiseEvent method have $event->MasterEvent set to original event, that was specified in form submit.

This way:
OnBeforeItemCreate
OnAfterItemCreate

OnBeforeItemUpdate
OnAfterItemUpdate

OnBeforeItemDelete
OnAfterItemDelete

Now has references to OnSave,OnCreate,OnUpdate,OnMassDelete events, that indirectly raises them.
(0003880)
Dmitry   
2011-09-23 20:43   
New patch for 5.2.0 needed (PHP 5 format)
(0003963)
alex   
2011-10-03 04:48   
Will test all together.
(0003964)
alex   
2011-10-03 04:49   
Fix committed to 5.2.x branch. Commit Message:

Fixes 0000397: Ability to work with main event from OnBefore/OnAfter type events called from kDBItem class
(0004042)
alex   
2011-10-12 03:51   
Patch "temp_handler_ignored_parent_event_fix.patch" fixed problem, when objects created within temp handler were not having reference to event, that called temp handler method in first place.
(0005111)
alex   
2012-07-25 05:33   
Since 5.2.0 version was released.