Index: kernel/db/cat_event_handler.php =================================================================== --- kernel/db/cat_event_handler.php (revision 13268) +++ kernel/db/cat_event_handler.php (working copy) @@ -2642,4 +2642,24 @@ echo $rating_helper->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: kernel/db/db_event_handler.php =================================================================== --- kernel/db/db_event_handler.php (revision 13268) +++ kernel/db/db_event_handler.php (working copy) @@ -2104,13 +2104,15 @@ } $event->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: kernel/utility/unit_config_reader.php =================================================================== --- kernel/utility/unit_config_reader.php (revision 13274) +++ kernel/utility/unit_config_reader.php (working copy) @@ -806,11 +806,16 @@ $file = $this->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: units/categories/categories_config.php =================================================================== --- units/categories/categories_config.php (revision 13270) +++ units/categories/categories_config.php (working copy) @@ -48,6 +48,28 @@ 'DoSpecial' => '*', '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: units/category_items/category_items_config.php =================================================================== --- units/category_items/category_items_config.php (revision 13268) +++ units/category_items/category_items_config.php (working copy) @@ -22,13 +22,6 @@ 'TagProcessorClass' => 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: units/favorites/favorites_config.php =================================================================== --- units/favorites/favorites_config.php (revision 13268) +++ units/favorites/favorites_config.php (working copy) @@ -23,32 +23,6 @@ 'AutoLoad' => 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: units/files/file_eh.php =================================================================== --- units/files/file_eh.php (revision 13268) +++ units/files/file_eh.php (working copy) @@ -31,21 +31,6 @@ } /** - * [HOOK] Allows to apply file functionality to specific config - * When main item is created, then #file config is cloned - * - * @param kEvent $event - */ - function OnDefineFiles(&$event) - { - $clones = $this->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 Index: units/images/images_config.php =================================================================== --- units/images/images_config.php (revision 13270) +++ units/images/images_config.php (working copy) @@ -17,14 +17,7 @@ $config = Array( 'Prefix' => '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: units/related_searches/related_searches_config.php =================================================================== --- units/related_searches/related_searches_config.php (revision 13270) +++ units/related_searches/related_searches_config.php (working copy) @@ -19,11 +19,6 @@ 'Clones' => 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: units/relationship/relationship_config.php =================================================================== --- units/relationship/relationship_config.php (revision 13270) +++ units/relationship/relationship_config.php (working copy) @@ -17,15 +17,6 @@ $config = Array( 'Prefix' => '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: units/reviews/reviews_config.php =================================================================== --- units/reviews/reviews_config.php (revision 13270) +++ units/reviews/reviews_config.php (working copy) @@ -17,58 +17,6 @@ $config = Array ( 'Prefix' => '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: units/structure/structure_config.php =================================================================== --- units/structure/structure_config.php (revision 13268) +++ units/structure/structure_config.php (working copy) @@ -41,6 +41,28 @@ 'DoSpecial' => '*', '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: units/users/users_config.php =================================================================== --- units/users/users_config.php (revision 13268) +++ units/users/users_config.php (working copy) @@ -71,6 +71,17 @@ 'DoEvent' => '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, ),