Index: trunk/kernel/units/category_items/category_items_event_handler.php =================================================================== diff -u -N -r6093 -r6625 --- trunk/kernel/units/category_items/category_items_event_handler.php (.../category_items_event_handler.php) (revision 6093) +++ trunk/kernel/units/category_items/category_items_event_handler.php (.../category_items_event_handler.php) (revision 6625) @@ -1,8 +1,8 @@ getObject(); - + $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); $object->addCalculatedField('CategoryName', 'c.'.$ml_formatter->LangFieldName('CachedNavbar')); } - + /** * Set's new category as primary for product * @@ -28,15 +28,15 @@ $ids=$this->getSelectedIDs($event); if($ids) { - $id = array_shift($ids); + $id = array_shift($ids); $table_info = $object->getLinkedInfo(); - + $this->Conn->Query('UPDATE '.$object->TableName.' SET PrimaryCat = 0 WHERE '.$table_info['ForeignKey'].' = '.$table_info['ParentId']); - $this->Conn->Query('UPDATE '.$object->TableName.' SET PrimaryCat = 1 WHERE ('.$table_info['ForeignKey'].' = '.$table_info['ParentId'].') AND (CategoryId = '.$id.')'); + $this->Conn->Query('UPDATE '.$object->TableName.' SET PrimaryCat = 1 WHERE ('.$table_info['ForeignKey'].' = '.$table_info['ParentId'].') AND (CategoryId = '.$id.')'); } $event->redirect_params = Array('opener' => 's', 'pass_events' => true); //stay! } - + /** * Apply custom processing to item * @@ -48,7 +48,7 @@ { $object =& $event->getObject(); $table_info = $object->getLinkedInfo(); - + switch ($type) { case 'before': @@ -59,7 +59,7 @@ $event->setEventParam('ids',$ids); } break; - + // not needed because 'before' does not allow to delete primary cat! /*case 'after': // set 1st not deleted category as primary @@ -73,7 +73,7 @@ } } } - + /** * Removes primary mark from cloned category items record * @@ -85,10 +85,10 @@ $table = $this->Application->getUnitOption($event->Prefix, 'TableName'); $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField'); $sql = 'UPDATE %s SET PrimaryCat = 0 WHERE %s = %s'; - + $this->Conn->Query( sprintf($sql, $table, $id_field, $id) ); } - + /** * Deletes items of requested type from requested categories. * In case if item is deleted from it's last category, then delete item too. @@ -99,29 +99,29 @@ { $category_ids = $event->getEventParam('category_ids'); if(!$category_ids) return false; - + $item_prefix = $event->getEventParam('item_prefix'); $item =& $this->Application->recallObject($item_prefix.'.-item', null, Array('skip_autoload' => true)); - + $ci_table = $this->Application->getUnitOption($event->Prefix, 'TableName'); $item_table = $this->Application->getUnitOption($item_prefix, 'TableName'); - + $sql = 'SELECT ItemResourceId, CategoryId FROM %1$s INNER JOIN %2$s ON (%1$s.ResourceId = %2$s.ItemResourceId) WHERE CategoryId IN (%3$s)'; $category_items = $this->Conn->Query( sprintf($sql, $item_table, $ci_table, implode(',', $category_ids) ) ); - + $item_hash = Array(); foreach($category_items as $ci_row) { $item_hash[ $ci_row['ItemResourceId'] ][] = $ci_row['CategoryId']; } - + foreach($item_hash as $item_resource_id => $delete_category_ids) { $item->Load($item_resource_id, 'ResourceId'); $item->DeleteFromCategories($delete_category_ids); } } - + } ?> \ No newline at end of file