Index: branches/unlabeled/unlabeled-1.8.2/core/units/categories/cache_updater.php =================================================================== diff -u -r7025 -r7057 --- branches/unlabeled/unlabeled-1.8.2/core/units/categories/cache_updater.php (.../cache_updater.php) (revision 7025) +++ branches/unlabeled/unlabeled-1.8.2/core/units/categories/cache_updater.php (.../cache_updater.php) (revision 7057) @@ -139,12 +139,17 @@ var $primaryLanguageId = 0; var $languageCount = 0; var $root_prefixes = Array(); + var $StrictPath = false; function Init($prefix, $special, $event_params = null) { parent::Init($prefix, $special, $event_params); $continuing = isset($event_params['continue']) ? $event_params['continue'] : 1; + $this->StrictPath = isset($event_params['strict_path']) ? $event_params['strict_path'] : false; + if ($this->StrictPath && !is_array($this->StrictPath)) { + $this->StrictPath = explode('|', trim($this->StrictPath, '|')); + } // cache widely used values to speed up process: begin $ml_helper =& $this->Application->recallObject('kMultiLanguageHelper'); @@ -171,6 +176,9 @@ { $this->Stack =& new clsRecursionStack(); $sql = 'DELETE FROM '.TABLE_PREFIX.'PermCache'; + if ($this->StrictPath) { + $sql .= ' WHERE CategoryId IN ('.implode(',',$this->StrictPath).')'; + } $this->Conn->Query($sql); $this->initData(); } @@ -257,6 +265,13 @@ // if we have more children if (isset($data['children'][$data['current_child']])) { + if ($this->StrictPath) { + while ( isset($data['children'][ $data['current_child'] ]) && !in_array($data['children'][ $data['current_child'] ], $this->StrictPath) ) { + $data['current_child']++; + continue; + } + if (!isset($data['children'][ $data['current_child'] ])) return false; //error + } $next_data = Array(); $next_data['titles'] = $data['titles']; $next_data['parent_path'] = $data['parent_path']; @@ -368,12 +383,12 @@ } } } - + /** * Rebuild all cache in one step * */ - function OneStepRun() + function OneStepRun($path='') { $needs_more = true; while ($needs_more) { Index: branches/unlabeled/unlabeled-1.25.2/core/units/categories/categories_event_handler.php =================================================================== diff -u -r7048 -r7057 --- branches/unlabeled/unlabeled-1.25.2/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 7048) +++ branches/unlabeled/unlabeled-1.25.2/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 7057) @@ -40,7 +40,7 @@ } $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField'); - + if (strlen($selected_ids) > 0) { $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName'); $sql = 'SELECT '.$id_field.', CreatedById @@ -59,7 +59,7 @@ $perm_value = true; $perm_helper =& $this->Application->recallObject('PermissionsHelper'); /* @var $perm_helper kPermissionsHelper */ - + foreach ($items as $item_id => $item_data) { if ($perm_helper->ModifyCheckPermission($item_data['CreatedById'], $item_data[$id_field], $event->Prefix) == 0) { // one of items selected has no permission @@ -94,10 +94,10 @@ $object =& $event->getObject(); /* @var $object kDBList */ - + // hide categories with status = 4 (system categories) $object->addFilter('system_categories', '%1$s.Status <> 4'); - + if ( $event->getEventParam('parent_cat_id') ) { $parent_cat_id = $event->getEventParam('parent_cat_id'); @@ -309,15 +309,24 @@ */ function OnAfterCopyToLive(&$event) { + $parent_path = false; + $object =& $this->Application->recallObject($event->Prefix.'.-item', null, Array('skip_autoload' => true, 'live_table' => true)); + $object->Load($event->getEventParam('id')); if ($event->getEventParam('temp_id') == 0) { - $object =& $this->Application->recallObject($event->Prefix.'.-item', null, Array('skip_autoload' => true, 'live_table' => true)); - $object->Load($event->getEventParam('id')); if ($object->isLoaded()) { // update path only for real categories (not including "Home" root category) $fields_hash = Array('ParentPath' => $object->buildParentPath()); $this->Conn->doUpdate($fields_hash, $object->TableName, 'CategoryId = '.$object->GetID()); + $parent_path = $fields_hash['ParentPath']; } } + else { + $parent_path = $object->GetDBField('ParentPath'); + } + if ($parent_path) { + $cache_updater =& $this->Application->recallObject('kPermCacheUpdater', null, array('strict_path' => $parent_path)); + $cache_updater->OneStepRun(); + } } /**