Index: branches/RC/core/units/general/cat_dbitem.php =================================================================== diff -u -r9623 -r9824 --- branches/RC/core/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 9623) +++ branches/RC/core/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 9824) @@ -167,7 +167,7 @@ function MoveToCat($cat_id=null) { // $this->NameCopy(); - $cat_id = $this->Application->GetVar('m_cat_id'); + if (!isset($cat_id)) $cat_id = $this->Application->GetVar('m_cat_id'); // check if the product already exists in destination cat $query = 'SELECT PrimaryCat FROM '.TABLE_PREFIX.'CategoryItems WHERE CategoryId = '.$cat_id.' AND ItemResourceId = '.$this->GetDBField('ResourceId'); Index: branches/RC/core/units/general/cat_event_handler.php =================================================================== diff -u -r9768 -r9824 --- branches/RC/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 9768) +++ branches/RC/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 9824) @@ -172,7 +172,54 @@ } } } + + /** + * Deletes all selected items. + * Automatically recurse into sub-items using temp handler, and deletes sub-items + * by calling its Delete method if sub-item has AutoDelete set to true in its config file + * + * @param kEvent $event + */ + function OnMassDelete(&$event) + { + if ($this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) { + return; + } + $event->status=erSUCCESS; + + $ids = $this->StoreSelectedIDs($event); + + $to_delete = array(); + if ($recycle_bin = $this->Application->ConfigValue('RecycleBinFolder')) { + $rb = $this->Application->recallObject('c.recycle', null, array('skip_autoload' => true)); + $rb->Load($recycle_bin); + $object = $this->Application->recallObject($event->Prefix.'.recycleitem', null, array('skip_autoload'=>true)); + foreach ($ids as $id) { + $object->Load($id); + if (preg_match('/^'.preg_quote($rb->GetDBField('ParentPath'),'/').'/', $object->GetDBField('ParentPath'))) { + $to_delete[] = $id; + continue; + } + $object->MoveToCat($recycle_bin); + } + $ids = $to_delete; + } + + $temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler'); + + $event->setEventParam('ids', $ids); + $this->customProcessing($event, 'before'); + $ids = $event->getEventParam('ids'); + + if($ids) + { + $temp->DeleteItems($event->Prefix, $event->Special, $ids); + } + $this->clearSelectedIDs($event); + } + + /** * Return type clauses for list bulding on front * Index: branches/RC/core/units/categories/categories_event_handler.php =================================================================== diff -u -r9705 -r9824 --- branches/RC/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 9705) +++ branches/RC/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 9824) @@ -557,9 +557,24 @@ return; } -// $event->status = erSUCCESS; - $ids = $this->StoreSelectedIDs($event); + $to_delete = array(); + if ($recycle_bin = $this->Application->ConfigValue('RecycleBinFolder')) { + $rb = $this->Application->recallObject('c.recycle', null, array('skip_autoload' => true)); + $rb->Load($recycle_bin); + $cat = $event->getObject(array('skip_autoload'=>true)); + foreach ($ids as $id) { + $cat->Load($id); + if (preg_match('/^'.preg_quote($rb->GetDBField('ParentPath'),'/').'/', $cat->GetDBField('ParentPath'))) { + $to_delete[] = $id; + continue; + } + $cat->SetDBField('ParentId', $recycle_bin); + $cat->Update(); + } + $ids = $to_delete; + $event->redirect = 'in-portal/categories/cache_updater'; + } $event->setEventParam('ids', $ids); $this->customProcessing($event, 'before');