Index: branches/unlabeled/unlabeled-1.79.4/core/kernel/db/db_event_handler.php =================================================================== diff -u -r7040 -r7043 --- branches/unlabeled/unlabeled-1.79.4/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 7040) +++ branches/unlabeled/unlabeled-1.79.4/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 7043) @@ -344,9 +344,7 @@ // $this->Application->setEvent($event->Prefix_Special, $current_event); $this->Application->setEvent($event->Prefix_Special, ''); - $mode_var = $this->GetMode($event); - $mode_processed = $this->Application->processPrefix($mode_var); - $save_event = $mode_var && $mode_processed['prefix'] == $event->Prefix ? 'OnSave' : 'OnUpdate'; + $save_event = $this->UseTempTables($event) && $this->Application->GetTopmostPrefix($event->Prefix) == $event->Prefix ? 'OnSave' : 'OnUpdate'; $this->Application->SetVar($event->Prefix_Special.'_SaveEvent',$save_event); } @@ -398,33 +396,26 @@ */ function UseTempTables(&$event) { - return $this->GetMode($event) !== false; - } - - function GetMode(&$event) - { $object = &$event->getObject(); $top_prefix = $this->Application->GetTopmostPrefix($event->Prefix); $var_names = Array ( $top_prefix, rtrim($top_prefix.'_'.$event->Special, '_'), rtrim($top_prefix.'.'.$event->Special, '.'), - $event->Prefix, - rtrim($event->Prefix.'_'.$event->Special, '_'), - rtrim($event->Prefix.'.'.$event->Special, '.'), ); $var_names = array_unique($var_names); $temp_mode = false; foreach ($var_names as $var_name) { $value = $this->Application->GetVar($var_name.'_mode'); if (substr($value, 0, 1) == 't') { - return $var_name; + $temp_mode = true; + break; } } - return false; + return $temp_mode; } /** Index: branches/unlabeled/unlabeled-1.166.4/core/kernel/application.php =================================================================== diff -u -r7036 -r7043 --- branches/unlabeled/unlabeled-1.166.4/core/kernel/application.php (.../application.php) (revision 7036) +++ branches/unlabeled/unlabeled-1.166.4/core/kernel/application.php (.../application.php) (revision 7043) @@ -2104,19 +2104,31 @@ } /** - * Returns main prefix for subtable prefix passes + * Returns genealogical main prefix for subtable prefix passes + * OR prefix, that has been found in REQUEST and some how is parent of passed subtable prefix * * @param string $current_prefix * @return string * @access public - * @author Kostja + * @author Kostja / Alex */ function GetTopmostPrefix($current_prefix) { - while ( $parent_prefix = $this->getUnitOption($current_prefix, 'ParentPrefix') ) - { + // 1. get genealogical tree of $current_prefix + $prefixes = Array ($current_prefix); + while ( $parent_prefix = $this->getUnitOption($current_prefix, 'ParentPrefix') ) { $current_prefix = $parent_prefix; + array_unshift($prefixes, $current_prefix); } + + // 2. find what if parent is passed + $passed = explode(',', $this->GetVar('passed')); + foreach ($prefixes as $current_prefix) { + if (in_array($current_prefix, $passed)) { + break; + } + } + return $current_prefix; } Index: branches/unlabeled/unlabeled-1.39.8/core/kernel/event_manager.php =================================================================== diff -u -r7042 -r7043 --- branches/unlabeled/unlabeled-1.39.8/core/kernel/event_manager.php (.../event_manager.php) (revision 7042) +++ branches/unlabeled/unlabeled-1.39.8/core/kernel/event_manager.php (.../event_manager.php) (revision 7043) @@ -248,9 +248,8 @@ } } + // 3. store all prefixes passed before event processing, because they are used by GetTopmostPrefix $passed = explode(',', $this->Application->GetVar('passed')); - - foreach ($events as $prefix_special => $event_name) { if (!$event_name) continue; $prefix_special = explode('.',$prefix_special);