Index: branches/5.3.x/core/units/category_items/category_items_event_handler.php =================================================================== diff -u -N -r15902 -r15986 --- branches/5.3.x/core/units/category_items/category_items_event_handler.php (.../category_items_event_handler.php) (revision 15902) +++ branches/5.3.x/core/units/category_items/category_items_event_handler.php (.../category_items_event_handler.php) (revision 15986) @@ -1,6 +1,6 @@ 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 (Id = ' . $id . ')'); } $event->SetRedirectParam('opener', 's'); } /** - * Apply custom processing to item - * - * @param kEvent $event - * @param string $type - * @return void - * @access protected - */ - protected function customProcessing(kEvent $event, $type) - { - if ( $event->Name == 'OnMassDelete' ) { - $object = $event->getObject(); - $table_info = $object->getLinkedInfo(); - - switch ($type) { - case 'before': - $ids = $event->getEventParam('ids'); - - if ( $ids ) { - $sql = 'SELECT CategoryId - FROM ' . $object->TableName . ' - WHERE (PrimaryCat = 0) AND (' . $table_info['ForeignKey'] . '=' . $table_info['ParentId'] . ') AND CategoryId IN (' . implode(',', $ids) . ')'; - $event->setEventParam('ids', $this->Conn->GetCol($sql)); - } - break; - - // not needed because 'before' does not allow to delete primary cat! - /*case 'after': - // set 1st not deleted category as primary - $sql = 'SELECT COUNT(*) - FROM ' . $object->TableName . ' - WHERE (PrimaryCat = 1) AND (' . $table_info['ForeignKey'] . ' = ' . $table_info['ParentId'] . ')'; - $has_primary = $this->Conn->GetOne($sql); - - if ( !$has_primary ) { - $sql = 'SELECT CategoryId - FROM ' . $object->TableName . ' - WHERE ' . $table_info['ForeignKey'] . ' = ' . $table_info['ParentId']; - $cat_id = $this->Conn->GetOne($sql); - - $sql = 'UPDATE ' . $object->TableName . ' - SET PrimaryCat = 1 - WHERE (' . $table_info['ForeignKey'] . ' = ' . $table_info['ParentId'] . ') AND (CategoryId = ' . $cat_id . ')'; - $this->Conn->Query($sql); - } - break;*/ - } - } - } - - /** * Removes primary mark from cloned category items record * * @param kEvent $event