Index: admin/system_presets/simple/categories_c.php =================================================================== --- admin/system_presets/simple/categories_c.php (revision 14467) +++ admin/system_presets/simple/categories_c.php (working copy) @@ -38,7 +38,7 @@ // fields to hide $hidden_fields = Array ( 'CategoryId', /*'Type', 'SymLinkCategoryId', 'ParentId', 'Name', 'Filename', 'AutomaticFilename',*/ - /*'Description',*/ 'CreatedOn', 'EditorsPick', 'Status', /*'Priority', 'MetaKeywords', 'CachedDescendantCatsQty', + /*'Description',*/ 'CreatedOn', 'EditorsPick', 'Status', 'DirectLinkEnabled', /*'Priority', 'MetaKeywords', 'CachedDescendantCatsQty', 'CachedNavbar',*/ 'CreatedById', /*'ResourceId', 'ParentPath', 'TreeLeft', 'TreeRight', 'NamedParentPath', 'MetaDescription', 'HotItem',*/ 'NewItem', /*'PopItem', 'Modified', 'ModifiedById', 'CachedTemplate',*/ 'Template', /*'UseExternalUrl', 'ExternalUrl',*/ 'UseMenuIconUrl', 'MenuIconUrl', 'Title', 'MenuTitle', Index: core/admin_templates/categories/categories_edit.tpl =================================================================== --- core/admin_templates/categories/categories_edit.tpl (revision 14467) +++ core/admin_templates/categories/categories_edit.tpl (working copy) @@ -146,13 +146,30 @@ - + + + + +
+ + onchange="update_checkbox(this, document.getElementById(''));" onclick="reflectDirectLink();"/> +
+ + + +
+ +
+
+ @@ -270,6 +287,25 @@ $(document).ready(reflectPageType); + + + function reflectDirectLink() { + $( get_control($field_mask, 'DirectLinkEnabled', undefined, '_cb') ).change( + function ($e) { + if ( $(this).attr('checked') ) { + $('#direct_link').show(); + } + else { + $('#direct_link').hide(); + } + } + ); + } + + $(document).ready(reflectDirectLink); + + + Application.setHook( 'c:*', function () { Index: core/install/english.lang =================================================================== --- core/install/english.lang (revision 14467) +++ core/install/english.lang (working copy) @@ -435,6 +435,7 @@ RGF0ZSBGb3JtYXQ= RGVjaW1hbCBQb2ludA== RGVzY3JpcHRpb24= + QWNjZXNzIHdpdGggTGluaw== RGlzcGxheQ== RGlzcGxheSBpbiBHcmlk RmllbGQgTGFiZWw= Index: core/install/install_schema.sql =================================================================== --- core/install/install_schema.sql (revision 14467) +++ core/install/install_schema.sql (working copy) @@ -460,6 +460,8 @@ OverridePageCacheKey tinyint(4) NOT NULL DEFAULT '0', PageCacheKey varchar(255) NOT NULL DEFAULT '', PageExpiration int(11) DEFAULT NULL, + DirectLinkEnabled tinyint(4) NOT NULL DEFAULT '1', + DirectLinkAuthKey varchar(20) NOT NULL, PRIMARY KEY (CategoryId), UNIQUE KEY ResourceId (ResourceId), KEY ParentId (ParentId), Index: core/install/upgrades.sql =================================================================== --- core/install/upgrades.sql (revision 14467) +++ core/install/upgrades.sql (working copy) @@ -2025,4 +2025,11 @@ # ===== v 5.1.3-B2 ===== ALTER TABLE Modules ADD AppliedDBRevisions TEXT NULL; -# ===== v 5.1.3-RC1 ===== \ No newline at end of file +# ===== v 5.1.3-RC1 ===== +ALTER TABLE Category + ADD DirectLinkEnabled TINYINT NOT NULL DEFAULT '1', + ADD DirectLinkAuthKey VARCHAR(20) NOT NULL; + +UPDATE Category +SET DirectLinkAuthKey = SUBSTRING( MD5( CONCAT(CategoryId, ':', ParentId, ':', l<%PRIMARY_LANGUAGE%>_Name, ':b38') ), 1, 20) +WHERE DirectLinkAuthKey = ''; \ No newline at end of file Index: core/units/categories/categories_config.php =================================================================== --- core/units/categories/categories_config.php (revision 14467) +++ core/units/categories/categories_config.php (working copy) @@ -401,6 +401,12 @@ ), 'PageCacheKey' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'default' => ''), 'PageExpiration' => Array ('type' => 'int', 'default' => NULL), + 'DirectLinkEnabled' => Array ( + 'type' => 'int', + 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1, + 'not_null' => 1, 'default' => 1 + ), + 'DirectLinkAuthKey' => Array ('type' => 'string', 'max_len' => 20, 'not_null' => 1, 'default' => '') ), 'VirtualFields' => Array ( Index: core/units/categories/categories_event_handler.php =================================================================== --- core/units/categories/categories_event_handler.php (revision 14467) +++ core/units/categories/categories_event_handler.php (working copy) @@ -1454,20 +1454,21 @@ */ function checkItemStatus(&$event) { - $status_fields = $this->Application->getUnitOption($event->Prefix,'StatusField'); - if (!$status_fields) { + $object =& $event->getObject(); + /* @var $object kDBItem */ + + if ( !$object->isLoaded() ) { return true; } - $status_field = array_shift($status_fields); - if ($status_field == 'Status' || $status_field == 'Enabled') { - $object =& $event->getObject(); - if (!$object->isLoaded()) { - return true; + if ( $object->GetDBField('Status') != STATUS_ACTIVE && $object->GetDBField('Status') != 4 ) { + if ( !$object->GetDBField('DirectLinkEnabled') || !$object->GetDBField('DirectLinkAuthKey') ) { + return false; } - return $object->GetDBField($status_field) == STATUS_ACTIVE || $object->GetDBField($status_field) == 4; + return $this->Application->GetVar('authkey') == $object->GetDBField('DirectLinkAuthKey'); } + return true; } @@ -1612,6 +1613,17 @@ $object->SetError('cust_RssSource', 'not_allowed', 'la_error_OperationNotAllowed'); } } + + if ( !$object->GetDBField('DirectLinkAuthKey') ) { + $key_parts = Array ( + $object->GetID(), + $object->GetDBField('ParentId'), + $object->GetField('Name'), + 'b38' + ); + + $object->SetDBField('DirectLinkAuthKey', substr( md5( implode(':', $key_parts) ), 0, 20 )); + } } /** Index: core/units/categories/categories_tag_processor.php =================================================================== --- core/units/categories/categories_tag_processor.php (revision 14467) +++ core/units/categories/categories_tag_processor.php (working copy) @@ -1665,6 +1665,28 @@ return $this->Application->HREF($object->GetDBField('NamedParentPath'), '_FRONT_END_', $url_params); } + function DirectLink($params) + { + $object =& $this->getObject($params); + + $themes_helper =& $this->Application->recallObject('ThemesHelper'); + /* @var $themes_helper kThemesHelper */ + + $url_params = Array ( + 'm_cat_id' => $object->GetID(), + 'm_theme' => $themes_helper->getCurrentThemeId(), + 'pass' => 'm', + 'index_file' => 'index.php', + 'authkey' => $object->GetDBField('DirectLinkAuthKey'), + ); + + if ($this->Application->ConfigValue('UseModRewrite')) { + $url_params['__MOD_REWRITE__'] = 1; + } + + return $this->Application->HREF($object->GetDBField('NamedParentPath'), '_FRONT_END_', $url_params); + } + /** * Builds link to cms page (used?) * Index: core/units/structure/structure_config.php =================================================================== --- core/units/structure/structure_config.php (revision 14467) +++ core/units/structure/structure_config.php (working copy) @@ -205,6 +205,12 @@ ), 'PageCacheKey' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'default' => ''), 'PageExpiration' => Array ('type' => 'int', 'default' => NULL), + 'DirectLinkEnabled' => Array ( + 'type' => 'int', + 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1, + 'not_null' => 1, 'default' => 1 + ), + 'DirectLinkAuthKey' => Array ('type' => 'string', 'max_len' => 20, 'not_null' => 1, 'default' => '') ), 'VirtualFields' => Array(