Index: install/english.lang =================================================================== --- install/english.lang (revision 15378) +++ install/english.lang (working copy) @@ -1,3 +1,4 @@ + @@ -148,6 +149,7 @@ TGlzdCBhdXRvbWF0aWMgcmVmcmVzaCBpbnRlcnZhbHMgKGluIG1pbnV0ZXMp QmFja3VwIFBhdGg= U3dpdGNoIENhdGFsb2cgdGFicyBiYXNlZCBvbiBNb2R1bGU= + U2VjdGlvbiBQZXJtaXNzaW9uIFJlYnVpbGQgTW9kZQ== Q2hlY2sgU3RvcCBXb3Jkcw== Q0tGaW5kZXIgTGljZW5zZSBLZXk= Q0tGaW5kZXIgTGljZW5zZSBOYW1l @@ -190,7 +192,6 @@ UGF0aCB0byBXZWJzaXRl UGVyZm9ybSBFeGFjdCBTZWFyY2g= Q29tbWVudHMgcGVyIHBhZ2U= - UXVpY2sgU2VjdGlvbiBQZXJtaXNzaW9uIFJlYnVpbGQ= IlJlY3ljbGUgQmluIiBTZWN0aW9uSWQ= VXNlcm5hbWUgUmVxdWlyZWQgRHVyaW5nIFJlZ2lzdHJhdGlvbg== UmVzdG9yZSBsYXN0IHZpc2l0ZWQgQWRtaW4gU2VjdGlvbiBhZnRlciBMb2dpbg== @@ -770,6 +771,7 @@ RmFkZQ== U2xpZGU= QXV0by1EZXRlY3Q= + QXV0b21hdGlj QmVmb3Jl Qm91bmNlZA== Q2FuY2VsZWQ= @@ -815,6 +817,7 @@ SXMgdW5pcXVl TGFzdCBOYW1l TG9nZ2VkIE91dA== + TWFudWFs bWludXRlKHMp TW9kYWwgV2luZG93 bW9udGgocyk= @@ -843,6 +846,7 @@ U2FtZSBXaW5kb3c= c2Vjb25kKHMp U2VtaS1jb2xvbg== + U2lsZW50 U3BhY2U= U3RhdGU= U3ViLW1hdGNo Index: install/install_data.sql =================================================================== --- install/install_data.sql (revision 15359) +++ install/install_data.sql (working copy) @@ -11,7 +11,7 @@ INSERT INTO SystemSettings VALUES(DEFAULT, 'AllowDeleteRootCats', '1', 'In-Portal', 'in-portal:configure_categories', 'la_title_General', 'la_AllowDeleteRootCats', 'checkbox', NULL, NULL, 10.08, 0, 0, NULL); INSERT INTO SystemSettings VALUES(DEFAULT, 'Catalog_PreselectModuleTab', '1', 'In-Portal', 'in-portal:configure_categories', 'la_title_General', 'la_config_CatalogPreselectModuleTab', 'checkbox', NULL, NULL, 10.09, 0, 0, NULL); INSERT INTO SystemSettings VALUES(DEFAULT, 'RecycleBinFolder', '', 'In-Portal', 'in-portal:configure_categories', 'la_title_General', 'la_config_RecycleBinFolder', 'text', NULL, NULL, 10.10, 0, 0, NULL); -INSERT INTO SystemSettings VALUES(DEFAULT, 'QuickCategoryPermissionRebuild', '1', 'In-Portal', 'in-portal:configure_categories', 'la_title_General', 'la_config_QuickCategoryPermissionRebuild', 'checkbox', NULL, NULL, 10.11, 0, 0, NULL); +INSERT INTO SystemSettings VALUES(DEFAULT, 'CategoryPermissionRebuildMode', '3', 'In-Portal', 'in-portal:configure_categories', 'la_title_General', 'la_config_CategoryPermissionRebuildMode', 'select', NULL, '1=la_opt_Manual||2=la_opt_Silent||3=la_opt_Automatic', 10.11, 0, 0, 'hint:la_config_CategoryPermissionRebuildMode'); INSERT INTO SystemSettings VALUES(DEFAULT, 'FilenameSpecialCharReplacement', '-', 'In-Portal', 'in-portal:configure_categories', 'la_title_General', 'la_config_FilenameSpecialCharReplacement', 'select', NULL, '_=+_||-=+-', 10.12, 0, 0, NULL); INSERT INTO SystemSettings VALUES(DEFAULT, 'Search_MinKeyword_Length', '3', 'In-Portal', 'in-portal:configure_categories', 'la_title_General', 'la_config_Search_MinKeyword_Length', 'text', NULL, NULL, 10.13, 0, 0, NULL); INSERT INTO SystemSettings VALUES(DEFAULT, 'ExcludeTemplateSectionsFromSearch', '0', 'In-Portal', 'in-portal:configure_categories', 'la_title_General', 'la_config_ExcludeTemplateSectionsFromSearch', 'checkbox', '', '', 10.14, 0, 0, NULL); Index: install/install_toolkit.php =================================================================== --- install/install_toolkit.php (revision 15375) +++ install/install_toolkit.php (working copy) @@ -887,14 +887,16 @@ $this->Conn->Query('DELETE FROM ' . TABLE_PREFIX . 'CachedUrls'); if ( $refresh_permissions ) { - if ( $this->Application->ConfigValue('QuickCategoryPermissionRebuild') ) { + $rebuild_mode = $this->Application->ConfigValue('CategoryPermissionRebuildMode'); + + if ( $rebuild_mode == CategoryPermissionRebuild::SILENT ) { // refresh permission without progress bar $updater = $this->Application->makeClass('kPermCacheUpdater'); /* @var $updater kPermCacheUpdater */ $updater->OneStepRun(); } - else { + elseif ( $rebuild_mode == CategoryPermissionRebuild::AUTOMATIC ) { // refresh permissions with ajax progress bar (when available) $this->Application->setDBCache('ForcePermCacheUpdate', 1); } Index: install/upgrades.sql =================================================================== --- install/upgrades.sql (revision 15390) +++ install/upgrades.sql (working copy) @@ -2756,3 +2756,7 @@ ADD CachedTemplateHash INT UNSIGNED NOT NULL DEFAULT '0' AFTER CachedTemplate, ADD INDEX (NamedParentPathHash), ADD INDEX (CachedTemplateHash); + +# ===== v 5.2.0 ===== +INSERT INTO SystemSettings VALUES(DEFAULT, 'CategoryPermissionRebuildMode', '3', 'In-Portal', 'in-portal:configure_categories', 'la_title_General', 'la_config_CategoryPermissionRebuildMode', 'select', NULL, '1=la_opt_Manual||2=la_opt_Silent||3=la_opt_Automatic', 10.11, 0, 0, 'hint:la_config_CategoryPermissionRebuildMode'); +DELETE FROM LanguageLabels WHERE PhraseKey = 'LA_CONFIG_QUICKCATEGORYPERMISSIONREBUILD'; Index: kernel/constants.php =================================================================== --- kernel/constants.php (revision 15359) +++ kernel/constants.php (working copy) @@ -189,4 +189,10 @@ const PS_DATE_TIME = 'DATE-TIME'; const PS_PREFIX = 'PREFIX'; const PS_USER = 'USER'; - } \ No newline at end of file + } + +class CategoryPermissionRebuild { + const MANUAL = 1; + const SILENT = 2; + const AUTOMATIC = 3; +} Index: units/admin/admin_tag_processor.php =================================================================== --- units/admin/admin_tag_processor.php (revision 15420) +++ units/admin/admin_tag_processor.php (working copy) @@ -590,10 +590,11 @@ $global_mark = $this->Application->getDBCache('ForcePermCacheUpdate'); $local_mark = $this->Application->RecallVar('PermCache_UpdateRequired'); - if ($global_mark || $local_mark) { + if ( $global_mark || $local_mark ) { $this->Application->RemoveVar('PermCache_UpdateRequired'); + $rebuild_mode = $this->Application->ConfigValue('CategoryPermissionRebuildMode'); - if ($this->Application->ConfigValue('QuickCategoryPermissionRebuild')) { + if ( $rebuild_mode == CategoryPermissionRebuild::SILENT ) { $updater = $this->Application->makeClass('kPermCacheUpdater'); /* @var $updater kPermCacheUpdater */ @@ -601,7 +602,7 @@ $this->Application->HandleEvent(new kEvent('c:OnResetCMSMenuCache')); } - else { + elseif ( $rebuild_mode == CategoryPermissionRebuild::AUTOMATIC ) { // update with progress bar return true; } Index: units/categories/categories_event_handler.php =================================================================== --- units/categories/categories_event_handler.php (revision 15417) +++ units/categories/categories_event_handler.php (working copy) @@ -601,7 +601,7 @@ { static $page_by_template = Array (); - if ($event->Special == 'current') { + if ( $event->Special == 'current' ) { return $this->Application->GetVar('m_cat_id'); } @@ -609,14 +609,14 @@ $page_id = parent::getPassedID($event); - if ($page_id === false) { + if ( $page_id === false ) { $template = $event->getEventParam('page'); - if (!$template) { + if ( !$template ) { $template = $this->Application->GetVar('t'); } // bug: when template contains "-" symbols (or others, that stripDisallowed will replace) it's not found - if (!array_key_exists($template, $page_by_template)) { + if ( !array_key_exists($template, $page_by_template) ) { $template_crc = kUtil::crc32(mb_strtolower($template)); $sql = 'SELECT ' . $this->Application->getUnitOption($event->Prefix, 'IDField') . ' @@ -633,14 +633,16 @@ $page_id = $page_by_template[$template]; } - if ($page_id === false && EDITING_MODE) { + if ( $page_id === false && EDITING_MODE ) { // create missing pages, when in editing mode - $object = $this->Application->recallObject($this->Prefix . '.rebuild', null, Array('skip_autoload' => true)); + $object = $this->Application->recallObject($this->Prefix . '.rebuild', NULL, Array ('skip_autoload' => true)); /* @var $object CategoriesItem */ - $created = $this->_prepareAutoPage($object, $template, null, SMS_MODE_AUTO); // create virtual (not system!) page - if ($created) { - if ($this->Application->ConfigValue('QuickCategoryPermissionRebuild') || !$this->Application->isAdmin) { + $created = $this->_prepareAutoPage($object, $template, NULL, SMS_MODE_AUTO); // create virtual (not system!) page + if ( $created ) { + $rebuild_mode = $this->Application->ConfigValue('CategoryPermissionRebuildMode'); + + if ( $rebuild_mode == CategoryPermissionRebuild::SILENT || !$this->Application->isAdmin ) { $updater = $this->Application->makeClass('kPermCacheUpdater'); /* @var $updater kPermCacheUpdater */ @@ -656,12 +658,12 @@ } } - if ($page_id) { + if ( $page_id ) { $page_by_template[$template] = $page_id; } } - if (!$page_id && !$this->Application->isAdmin) { + if ( !$page_id && !$this->Application->isAdmin ) { $page_id = $this->Application->GetVar('m_cat_id'); } @@ -1259,13 +1261,15 @@ */ protected function _ensurePermCacheRebuild($event) { - if ( $this->Application->ConfigValue('QuickCategoryPermissionRebuild') ) { + $rebild_mode = $this->Application->ConfigValue('CategoryPermissionRebuildMode'); + + if ( $rebild_mode == CategoryPermissionRebuild::SILENT ) { $updater = $this->Application->makeClass('kPermCacheUpdater'); /* @var $updater kPermCacheUpdater */ $updater->OneStepRun(); } - else { + elseif ( $rebild_mode == CategoryPermissionRebuild::AUTOMATIC ) { // rebuild with progress bar $event->redirect = 'categories/cache_updater'; } @@ -2227,8 +2231,8 @@ function OnAfterRebuildThemes($event) { $sql = 'SELECT t.ThemeId, CONCAT( tf.FilePath, \'/\', tf.FileName ) AS Path, tf.FileMetaInfo - FROM '.TABLE_PREFIX.'ThemeFiles AS tf - LEFT JOIN '.TABLE_PREFIX.'Themes AS t ON t.ThemeId = tf.ThemeId + FROM ' . TABLE_PREFIX . 'ThemeFiles AS tf + LEFT JOIN ' . TABLE_PREFIX . 'Themes AS t ON t.ThemeId = tf.ThemeId WHERE t.Enabled = 1 AND tf.FileType = 1 AND ( SELECT COUNT(CategoryId) @@ -2236,26 +2240,26 @@ WHERE CONCAT(\'/\', c.Template, \'.tpl\') = CONCAT( tf.FilePath, \'/\', tf.FileName ) AND (c.ThemeId = t.ThemeId) ) = 0 '; $files = $this->Conn->Query($sql, 'Path'); - if (!$files) { + if ( !$files ) { // all possible pages are already created - return ; + return; } set_time_limit(0); ini_set('memory_limit', -1); - $dummy = $this->Application->recallObject($event->Prefix . '.rebuild', null, Array ('skip_autoload' => true)); + $dummy = $this->Application->recallObject($event->Prefix . '.rebuild', NULL, Array ('skip_autoload' => true)); /* @var $dummy CategoriesItem */ $error_count = 0; foreach ($files as $a_file => $file_info) { $status = $this->_prepareAutoPage($dummy, $a_file, $file_info['ThemeId'], SMS_MODE_FORCE, unserialize($file_info['FileMetaInfo'])); // create system page - if (!$status) { + if ( !$status ) { $error_count++; } } - if ($this->Application->ConfigValue('QuickCategoryPermissionRebuild')) { + if ( $this->Application->ConfigValue('CategoryPermissionRebuildMode') == CategoryPermissionRebuild::SILENT ) { $updater = $this->Application->makeClass('kPermCacheUpdater'); /* @var $updater kPermCacheUpdater */ @@ -2264,7 +2268,7 @@ $this->_resetMenuCache(); - if ($error_count) { + if ( $error_count ) { // allow user to review error after structure page creation $event->MasterEvent->redirect = false; } Index: units/categories/categories_tag_processor.php =================================================================== --- units/categories/categories_tag_processor.php (revision 15418) +++ units/categories/categories_tag_processor.php (working copy) @@ -511,39 +511,44 @@ kUtil::safeDefine('CACHE_PERM_CHUNK_SIZE', 30); $continue = $this->Application->GetVar('continue'); - $total_cats = (int) $this->Conn->GetOne('SELECT COUNT(*) FROM '.TABLE_PREFIX.'Categories'); + $total_cats = (int)$this->Conn->GetOne('SELECT COUNT(*) FROM ' . TABLE_PREFIX . 'Categories'); - if ($continue === false && $total_cats > CACHE_PERM_CHUNK_SIZE) { - // first step, if category count > CACHE_PERM_CHUNK_SIZE, then ask for cache update - return true; - } + if ( $continue === false ) { + $rebuild_mode = $this->Application->ConfigValue('CategoryPermissionRebuildMode'); - if ($continue === false) { + if ( $rebuild_mode == CategoryPermissionRebuild::AUTOMATIC && $total_cats > CACHE_PERM_CHUNK_SIZE ) { + // first step, if category count > CACHE_PERM_CHUNK_SIZE, then ask for cache update + return true; + } + // if we don't have to ask, then assume user selected "Yes" in permcache update dialog $continue = 1; } - $updater = $this->Application->makeClass('kPermCacheUpdater', Array($continue)); + $updater = $this->Application->makeClass('kPermCacheUpdater', Array ($continue)); /* @var $updater kPermCacheUpdater */ - if ($continue === '0') { // No in dialog + if ( $continue === '0' ) { // No in dialog $updater->clearData(); $this->Application->Redirect($params['destination_template']); } $ret = false; // don't ask for update - if ($continue == 1) { // Initial run + + if ( $continue == 1 ) { // Initial run $updater->setData(); } - if ($continue == 2) { // Continuing + + if ( $continue == 2 ) { // Continuing // called from AJAX request => returns percent $needs_more = true; - while ($needs_more && $updater->iteration <= CACHE_PERM_CHUNK_SIZE) { - // until proceeeded in this step category count exceeds category per step limit + + while ( $needs_more && $updater->iteration <= CACHE_PERM_CHUNK_SIZE ) { + // until proceeded in this step category count exceeds category per step limit $needs_more = $updater->DoTheJob(); } - if ($needs_more) { + if ( $needs_more ) { // still some categories are left for next step $updater->setData(); } @@ -560,6 +565,7 @@ $ret = $updater->getDonePercent(); } + return $ret; }