Index: branches/5.2.x/core/units/categories/categories_event_handler.php =================================================================== diff -u -N -r15065 -r15108 --- branches/5.2.x/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 15065) +++ branches/5.2.x/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 15108) @@ -1,6 +1,6 @@ Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1) ) { $event->status = kEvent::erFAIL; - return ; + return; } $to_delete = Array (); @@ -1056,15 +1056,19 @@ foreach ($ids as $id) { $cat->Load($id); + if ( preg_match('/^' . preg_quote($rb->GetDBField('ParentPath'), '/') . '/', $cat->GetDBField('ParentPath')) ) { + // already in "Recycle Bin" -> delete for real $to_delete[] = $id; continue; } + + // just move into "Recycle Bin" category $cat->SetDBField('ParentId', $recycle_bin); $cat->Update(); } + $ids = $to_delete; - $event->redirect = 'categories/cache_updater'; } $event->setEventParam('ids', $ids); @@ -1079,10 +1083,10 @@ $recursive_helper->DeleteCategory($id, $event->Prefix); } } + $this->clearSelectedIDs($event); - $this->Application->StoreVar('RefreshStructureTree', 1); - $this->_resetMenuCache(); + $this->_ensurePermCacheRebuild($event); } /** @@ -1229,20 +1233,32 @@ } if ( $clipboard_data['cut'] || $clipboard_data['copy'] ) { - // rebuild with progress bar - if ( $this->Application->ConfigValue('QuickCategoryPermissionRebuild') ) { - $updater =& $this->Application->makeClass('kPermCacheUpdater'); - /* @var $updater kPermCacheUpdater */ + $this->_ensurePermCacheRebuild($event); + } + } - $updater->OneStepRun(); - } - else { - $event->redirect = 'categories/cache_updater'; - } + /** + * Ensures, that category permission cache is rebuild when category is added/edited/deleted + * + * @param kEvent $event + * @return void + * @access protected + */ + protected function _ensurePermCacheRebuild(&$event) + { + if ( $this->Application->ConfigValue('QuickCategoryPermissionRebuild') ) { + $updater =& $this->Application->makeClass('kPermCacheUpdater'); + /* @var $updater kPermCacheUpdater */ - $this->_resetMenuCache(); - $this->Application->StoreVar('RefreshStructureTree', 1); + $updater->OneStepRun(); } + else { + // rebuild with progress bar + $event->redirect = 'categories/cache_updater'; + } + + $this->_resetMenuCache(); + $this->Application->StoreVar('RefreshStructureTree', 1); } /**