Index: branches/5.0.x/core/units/structure/structure_config.php =================================================================== diff -u -N -r12877 -r13289 --- branches/5.0.x/core/units/structure/structure_config.php (.../structure_config.php) (revision 12877) +++ branches/5.0.x/core/units/structure/structure_config.php (.../structure_config.php) (revision 13289) @@ -1,6 +1,6 @@ '*', 'DoEvent' => 'OnDefineCustomFields', ), + + Array ( + 'Mode' => hBEFORE, + 'Conditional' => false, + 'HookToPrefix' => 'rel', + 'HookToSpecial' => '*', + 'HookToEvent' => Array ('OnAfterConfigRead'), + 'DoPrefix' => '', + 'DoSpecial' => '*', + 'DoEvent' => 'OnCloneSubItem', + ), + + Array ( + 'Mode' => hBEFORE, + 'Conditional' => false, + 'HookToPrefix' => 'img', + 'HookToSpecial' => '*', + 'HookToEvent' => Array ('OnAfterConfigRead'), + 'DoPrefix' => '', + 'DoSpecial' => '*', + 'DoEvent' => 'OnCloneSubItem', + ), ), 'IDField' => 'CategoryId', Index: branches/5.0.x/core/units/reviews/reviews_config.php =================================================================== diff -u -N -r13270 -r13289 --- branches/5.0.x/core/units/reviews/reviews_config.php (.../reviews_config.php) (revision 13270) +++ branches/5.0.x/core/units/reviews/reviews_config.php (.../reviews_config.php) (revision 13289) @@ -1,6 +1,6 @@ 'rev', - 'Clones' => Array ( - 'l-rev' => Array ( - 'ParentPrefix' => 'l', - 'ConfigMapping' => Array ( - 'PerPage' => 'Perpage_LinkReviews', - 'ShortListPerPage' => 'Perpage_LinkReviews_Short', - 'DefaultSorting1Field' => 'Link_ReviewsSort', - 'DefaultSorting2Field' => 'Link_ReviewsSort2', - 'DefaultSorting1Dir' => 'Link_ReviewsOrder', - 'DefaultSorting2Dir' => 'Link_ReviewsOrder2', - - 'ReviewDelayInterval' => 'link_ReviewDelay_Interval', - 'ReviewDelayValue' => 'link_ReviewDelay_Value', - ), - ), - - 'n-rev' => Array ( - 'ParentPrefix' => 'n', - 'ConfigMapping' => Array ( - 'PerPage' => 'Perpage_NewsReviews', - 'ShortListPerPage' => 'Perpage_NewsReviews_Short', - 'DefaultSorting1Field' => 'News_SortReviews', - 'DefaultSorting2Field' => 'News_SortReviews2', - 'DefaultSorting1Dir' => 'News_SortReviewsOrder', - 'DefaultSorting2Dir' => 'News_SortReviewsOrder2', - - 'ReviewDelayInterval' => 'News_ReviewDelay_Interval', - 'ReviewDelayValue' => 'News_ReviewDelay_Value', - ), - ), - - 'bb-rev' => Array ( - 'ParentPrefix' => 'bb', - 'ConfigMapping' => Array ( - 'PerPage' => 'Perpage_TopicReviews', - - 'ReviewDelayInterval' => 'topic_ReviewDelay_Interval', - 'ReviewDelayValue' => 'topic_ReviewDelay_Value', - ), - ), - - 'p-rev' => Array ( - 'ParentPrefix' => 'p', - 'ConfigMapping' => Array ( - 'PerPage' => 'Comm_Perpage_Reviews', - - 'ReviewDelayInterval' => 'product_ReviewDelay_Value', - 'ReviewDelayValue' => 'product_ReviewDelay_Interval', - ), - ), - ), - 'ItemClass' => Array ('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'), 'ListClass' => Array ('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'), 'EventHandlerClass' => Array ('class' => 'ReviewsEventHandler', 'file' => 'reviews_event_handler.php', 'build_event' => 'OnBuild'), @@ -169,8 +117,8 @@ 'formatter' => 'kDateFormatter', 'default' => '#NOW#', ), 'ReviewText' => Array ( - 'type' => 'string', - 'formatter' => 'kFormatter', + 'type' => 'string', + 'formatter' => 'kFormatter', 'using_fck' => 1, 'default' => null, 'required' => 1, ), 'Rating' => Array ( @@ -187,7 +135,7 @@ 'min_value_inc' => 0, 'max_value_inc' => 5, 'default' => 0, ), 'IPAddress' => Array ( - 'type' => 'string', + 'type' => 'string', 'max_value_inc' => 15, 'not_null' =>1, 'default' => '', ), 'ItemId' => Array ( @@ -201,8 +149,8 @@ 'left_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'PortalUser WHERE `%s` = \'%s\' ', 'left_key_field' => 'PortalUserId', - 'left_title_field' => 'Login', - 'required' => 1, 'not_null' => 1, 'default' => -1, + 'left_title_field' => 'Login', + 'required' => 1, 'not_null' => 1, 'default' => -1, 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), ), 'ItemType' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0), @@ -213,7 +161,7 @@ 'options' => Array ( 0 => 'la_Disabled', 1 => 'la_Active', - 2 => 'la_Pending', + 2 => 'la_Pending', ), 'not_null' =>1, 'default' => 2, ), Index: branches/5.0.x/core/kernel/utility/unit_config_reader.php =================================================================== diff -u -N -r13279 -r13289 --- branches/5.0.x/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 13279) +++ branches/5.0.x/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 13289) @@ -1,6 +1,6 @@ prefixFiles[$prefix]; $prefix = $this->PreloadConfigFile($file); + if ($this->FinalStage) { + // run prefix OnAfterConfigRead so all + // hooks to it can define their clonses + $this->runAfterConfigRead($prefix); + } + $clones = $this->postProcessConfig($prefix, 'AggregateConfigs', 'sub_prefix'); $clones = array_merge($this->postProcessConfig($prefix, 'Clones', 'prefix'), $clones); if ($this->FinalStage) { - array_unshift($clones, $prefix); $clones = array_unique($clones); foreach ($clones as $a_prefix) { $this->runAfterConfigRead($a_prefix); Index: branches/5.0.x/core/units/users/users_config.php =================================================================== diff -u -N -r13121 -r13289 --- branches/5.0.x/core/units/users/users_config.php (.../users_config.php) (revision 13121) +++ branches/5.0.x/core/units/users/users_config.php (.../users_config.php) (revision 13289) @@ -1,6 +1,6 @@ 'OnAutoLoginUser', ), + Array ( + 'Mode' => hBEFORE, + 'Conditional' => false, + 'HookToPrefix' => 'img', + 'HookToSpecial' => '*', + 'HookToEvent' => Array ('OnAfterConfigRead'), + 'DoPrefix' => '', + 'DoSpecial' => '*', + 'DoEvent' => 'OnCloneSubItem', + ), + // Captcha processing Array ( 'Mode' => hAFTER, @@ -474,7 +485,7 @@ 'PortalUserId' => Array ('title' => 'la_col_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter', 'width' => 70), 'Login' => Array ('title' => 'la_col_Username', 'filter_block' => 'grid_like_filter', 'width' => 150, ), 'FirstName' => Array ('title' => 'la_col_FirstName', 'filter_block' => 'grid_like_filter', 'width' => 150, ), - 'LastName' => Array ('title' => 'la_col_LastName', 'filter_block' => 'grid_like_filter', 'width' => 150, ), + 'LastName' => Array ('title' => 'la_col_LastName', 'filter_block' => 'grid_like_filter', 'width' => 150, ), 'Email' => Array ('title' => 'la_col_Email', 'filter_block' => 'grid_like_filter', 'width' => 200, ), 'PrimaryGroup' => Array ('title' => 'la_col_PrimaryGroup', 'filter_block' => 'grid_like_filter', 'width' => 140), 'Status' => Array ('title' => 'la_col_Status', 'filter_block' => 'grid_options_filter', 'width' => 100, ), Index: branches/5.0.x/core/units/categories/categories_config.php =================================================================== diff -u -N -r13270 -r13289 --- branches/5.0.x/core/units/categories/categories_config.php (.../categories_config.php) (revision 13270) +++ branches/5.0.x/core/units/categories/categories_config.php (.../categories_config.php) (revision 13289) @@ -1,6 +1,6 @@ '*', 'DoEvent' => 'OnDefineCustomFields', ), + + Array ( + 'Mode' => hBEFORE, + 'Conditional' => false, + 'HookToPrefix' => 'rel', + 'HookToSpecial' => '*', + 'HookToEvent' => Array ('OnAfterConfigRead'), + 'DoPrefix' => '', + 'DoSpecial' => '*', + 'DoEvent' => 'OnCloneSubItem', + ), + + Array ( + 'Mode' => hBEFORE, + 'Conditional' => false, + 'HookToPrefix' => 'img', + 'HookToSpecial' => '*', + 'HookToEvent' => Array ('OnAfterConfigRead'), + 'DoPrefix' => '', + 'DoSpecial' => '*', + 'DoEvent' => 'OnCloneSubItem', + ), ), 'AutoLoad' => true, Index: branches/5.0.x/core/units/images/images_config.php =================================================================== diff -u -N -r13270 -r13289 --- branches/5.0.x/core/units/images/images_config.php (.../images_config.php) (revision 13270) +++ branches/5.0.x/core/units/images/images_config.php (.../images_config.php) (revision 13289) @@ -1,6 +1,6 @@ 'img', 'Clones' => Array ( - 'u-img' => Array('ParentPrefix' => 'u'), - - 'l-img' => Array('ParentPrefix' => 'l'), - 'n-img' => Array('ParentPrefix' => 'n'), - 'bb-img'=> Array('ParentPrefix' => 'bb'), 'bb-post-img'=> Array('ParentPrefix' => 'bb-post'), - /*'p-img' => Array('ParentPrefix' => 'p'),*/ - 'c-img' => Array('ParentPrefix' => 'c'), ), 'ItemClass' => Array('class'=>'kDBItem','file'=>'','build_event'=>'OnItemBuild'), @@ -171,7 +164,7 @@ 'default' => 1, 'not_null' => 1, 'use_phrases' => 1, ), ), - + 'VirtualFields' => Array( 'Preview' => Array(), 'ImageUrl' => Array(), Index: branches/5.0.x/core/units/related_searches/related_searches_config.php =================================================================== diff -u -N -r13270 -r13289 --- branches/5.0.x/core/units/related_searches/related_searches_config.php (.../related_searches_config.php) (revision 13270) +++ branches/5.0.x/core/units/related_searches/related_searches_config.php (.../related_searches_config.php) (revision 13289) @@ -1,6 +1,6 @@ Array( 'c-search' => Array('ParentPrefix' => 'c'), - /*'l-rel' => Array('ParentPrefix' => 'l'), - 'n-rel' => Array('ParentPrefix' => 'n'), - 'bb-rel'=> Array('ParentPrefix' => 'bb'), - 'p-rel' => Array('ParentPrefix' => 'p'), - 'cms-rel'=> Array('ParentPrefix' => 'cms'),*/ ), 'ItemClass' => Array('class'=>'kDBItem','file'=>'','build_event'=>'OnItemBuild'), Index: branches/5.0.x/core/units/category_items/category_items_config.php =================================================================== diff -u -N -r12734 -r13289 --- branches/5.0.x/core/units/category_items/category_items_config.php (.../category_items_config.php) (revision 12734) +++ branches/5.0.x/core/units/category_items/category_items_config.php (.../category_items_config.php) (revision 13289) @@ -1,6 +1,6 @@ Array('class'=>'CategoryItemsTagProcessor','file'=>'category_items_tag_processor.php','build_event'=>'OnBuild'), 'AutoLoad' => true, - 'Clones' => Array( - 'l-ci' => Array('ParentPrefix' => 'l'), - 'n-ci' => Array('ParentPrefix' => 'n'), - 'bb-ci' => Array('ParentPrefix' => 'bb'), - 'p-ci' => Array('ParentPrefix' => 'p'), - 'cms-ci'=> Array('ParentPrefix' => 'cms',), - ), 'QueryString' => Array( 1 => 'id', 2 => 'page', Index: branches/5.0.x/core/units/relationship/relationship_config.php =================================================================== diff -u -N -r13270 -r13289 --- branches/5.0.x/core/units/relationship/relationship_config.php (.../relationship_config.php) (revision 13270) +++ branches/5.0.x/core/units/relationship/relationship_config.php (.../relationship_config.php) (revision 13289) @@ -1,6 +1,6 @@ 'rel', - 'Clones' => Array( - 'c-rel' => Array('ParentPrefix' => 'c'), - 'l-rel' => Array('ParentPrefix' => 'l'), - 'n-rel' => Array('ParentPrefix' => 'n'), - 'bb-rel'=> Array('ParentPrefix' => 'bb'), - /*'p-rel' => Array('ParentPrefix' => 'p'),*/ - /*'cms-rel'=> Array('ParentPrefix' => 'cms'),*/ - ), - 'ItemClass' => Array('class'=>'kDBItem','file'=>'','build_event'=>'OnItemBuild'), 'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'), 'EventHandlerClass' => Array('class'=>'RelationshipEventHandler','file'=>'relationship_event_handler.php','build_event'=>'OnBuild'), @@ -101,7 +92,7 @@ 'type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (0 => 'la_Disabled', 1 => 'la_Enabled'), 'use_phrases' => 1, - 'not_null' => 1, 'default' => 1, + 'not_null' => 1, 'default' => 1, ), 'Priority' => Array('type'=>'int','not_null'=>1,'default'=>0), ), Index: branches/5.0.x/core/units/favorites/favorites_config.php =================================================================== diff -u -N -r12734 -r13289 --- branches/5.0.x/core/units/favorites/favorites_config.php (.../favorites_config.php) (revision 12734) +++ branches/5.0.x/core/units/favorites/favorites_config.php (.../favorites_config.php) (revision 13289) @@ -1,6 +1,6 @@ true, - 'Clones' => Array ( - 'l-fav' => Array( - 'ParentPrefix' => 'l', - 'ParentTableKey' => 'ResourceId', - 'ForeignKey' => 'ResourceId', - ), - - 'n-fav' => Array ( - 'ParentPrefix' => 'n', - 'ParentTableKey' => 'ResourceId', - 'ForeignKey' => 'ResourceId', - ), - - 'bb-fav' => Array( - 'ParentPrefix' => 'bb', - 'ParentTableKey' => 'ResourceId', - 'ForeignKey' => 'ResourceId', - ), - - 'p-fav' => Array( - 'ParentPrefix' => 'p', - 'ParentTableKey' => 'ResourceId', - 'ForeignKey' => 'ResourceId', - ), - ), - 'Hooks' => Array ( Array( 'Mode' => hAFTER, Index: branches/5.0.x/core/kernel/db/db_event_handler.php =================================================================== diff -u -N -r12970 -r13289 --- branches/5.0.x/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 12970) +++ branches/5.0.x/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 13289) @@ -1,6 +1,6 @@ redirect = $this->Application->GetVar('translator_t'); - $event->redirect_params = Array('pass'=>'all,trans,'.$this->Application->GetVar('translator_prefixes'), - $event->getPrefixSpecial(true).'_id' => $object->GetID(), - 'trans_event' => 'OnLoad', - 'trans_prefix' => $this->Application->GetVar('translator_prefixes'), - 'trans_field' => $this->Application->GetVar('translator_field'), - 'trans_multi_line' => $this->Application->GetVar('translator_multi_line'), - ); + $event->redirect_params = Array ( + 'pass' => 'all,trans,' . $this->Application->GetVar('translator_prefixes'), + 'opener' => 's', + $event->getPrefixSpecial(true) . '_id' => $object->GetID(), + 'trans_event' => 'OnLoad', + 'trans_prefix' => $this->Application->GetVar('translator_prefixes'), + 'trans_field' => $this->Application->GetVar('translator_field'), + 'trans_multi_line' => $this->Application->GetVar('translator_multi_line'), + ); // 1. SAVE LAST TEMPLATE TO SESSION (really needed here, because of tweaky redirect) $last_template = $this->Application->RecallVar('last_template'); @@ -2572,4 +2574,17 @@ // abstract, for hooking } + /** + * [HOOK] Allows to add cloned subitem to given prefix + * + * @param kEvent $event + */ + function OnCloneSubItem(&$event) + { + $clones = $this->Application->getUnitOption($event->MasterEvent->Prefix, 'Clones'); + + $subitem_prefix = $event->Prefix . '-' . preg_replace('/^#/', '', $event->MasterEvent->Prefix); + $clones[$subitem_prefix] = Array ('ParentPrefix' => $event->Prefix); + $this->Application->setUnitOption($event->MasterEvent->Prefix, 'Clones', $clones); + } } \ No newline at end of file Index: branches/5.0.x/core/kernel/db/cat_event_handler.php =================================================================== diff -u -N -r12960 -r13289 --- branches/5.0.x/core/kernel/db/cat_event_handler.php (.../cat_event_handler.php) (revision 12960) +++ branches/5.0.x/core/kernel/db/cat_event_handler.php (.../cat_event_handler.php) (revision 13289) @@ -1,6 +1,6 @@ makeVote($object); } + + /** + * [HOOK] Allows to add cloned subitem to given prefix + * + * @param kEvent $event + */ + function OnCloneSubItem(&$event) + { + parent::OnCloneSubItem($event); + + if ($event->MasterEvent->Prefix == 'fav') { + $clones = $this->Application->getUnitOption($event->MasterEvent->Prefix, 'Clones'); + $subitem_prefix = $event->Prefix . '-' . $event->MasterEvent->Prefix; + + $clones[$subitem_prefix]['ParentTableKey'] = 'ResourceId'; + $clones[$subitem_prefix]['ForeignKey'] = 'ResourceId'; + + $this->Application->setUnitOption($event->MasterEvent->Prefix, 'Clones', $clones); + } + } } \ No newline at end of file Index: branches/5.0.x/core/units/files/file_eh.php =================================================================== diff -u -N -r12734 -r13289 --- branches/5.0.x/core/units/files/file_eh.php (.../file_eh.php) (revision 12734) +++ branches/5.0.x/core/units/files/file_eh.php (.../file_eh.php) (revision 13289) @@ -1,6 +1,6 @@ Application->getUnitOption('#file', 'Clones'); - $clones[$event->MasterEvent->Prefix.'-file'] = Array ( - 'ParentPrefix' => $event->MasterEvent->Prefix, - ); - $this->Application->setUnitOption('#file', 'Clones', $clones); - } - - /** * Remembers user, who is created file record. Makes file primary if no other files are uploaded. * * @param kEvent $event