Index: branches/5.3.x/core/units/favorites/favorites_eh.php =================================================================== diff -u -r15483 -r15698 --- branches/5.3.x/core/units/favorites/favorites_eh.php (.../favorites_eh.php) (revision 15483) +++ branches/5.3.x/core/units/favorites/favorites_eh.php (.../favorites_eh.php) (revision 15698) @@ -1,6 +1,6 @@ Application->getUnitOption($event->Prefix, 'ParentPrefix'); + $config = $event->getUnitConfig(); + $parent_prefix = $config->getParentPrefix(); + $parent_object = $this->Application->recallObject($parent_prefix); /* @var $parent_object kDBItem */ - if (!$parent_object->isLoaded() || !$this->Application->CheckPermission('FAVORITES', 0, $parent_object->GetDBField('ParentPath'))) { + if ( !$parent_object->isLoaded() || !$this->Application->CheckPermission('FAVORITES', 0, $parent_object->GetDBField('ParentPath')) ) { $event->status = kEvent::erPERM_FAIL; - return ; + + return; } $user_id = $this->Application->RecallVar('user_id'); $sql = 'SELECT FavoriteId - FROM '.$this->Application->getUnitOption($event->Prefix, 'TableName').' - WHERE (PortalUserId = '.$user_id.') AND (ResourceId = '.$parent_object->GetDBField('ResourceId').')'; + FROM ' . $config->getTableName() . ' + WHERE (PortalUserId = ' . $user_id . ') AND (ResourceId = ' . $parent_object->GetDBField('ResourceId') . ')'; $favorite_id = $this->Conn->GetOne($sql); - $object = $event->getObject(Array('skip_autoload' => true)); + $object = $event->getObject(Array ('skip_autoload' => true)); /* @var $object kDBItem */ - if ($favorite_id) { + if ( $favorite_id ) { $object->Delete($favorite_id); } else { $object->Create(); } - $event->SetRedirectParam('pass', 'm,'.$parent_prefix); + $event->SetRedirectParam('pass', 'm,' . $parent_prefix); } /** @@ -86,25 +89,27 @@ $user_id = $this->Application->RecallVar('user_id'); $object->SetDBField('PortalUserId', $user_id); - $parent_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix'); + $parent_prefix = $event->getUnitConfig()->getParentPrefix(); + $parent_object = $this->Application->recallObject($parent_prefix); /* @var $parent_object kDBItem */ $object->SetDBField('ResourceId', $parent_object->GetDBField('ResourceId')); - $object->SetDBField('ItemTypeId', $this->Application->getUnitOption($parent_prefix, 'ItemType')); + $object->SetDBField('ItemTypeId', $this->Application->getUnitConfig($parent_prefix)->getItemType()); } /** - * [HOOK] Deletes favorite record to item, that is beeing deleted + * [HOOK] Deletes favorite record to item, that is being deleted * * @param kEvent $event */ function OnDeleteFavoriteItem($event) { $main_object = $event->MasterEvent->getObject(); + /* @var $main_object kDBItem */ - $sql = 'DELETE FROM '.$this->Application->getUnitOption($event->Prefix, 'TableName').' - WHERE ResourceId = '.$main_object->GetDBField('ResourceId'); + $sql = 'DELETE FROM ' . $event->getUnitConfig()->getTableName() . ' + WHERE ResourceId = ' . $main_object->GetDBField('ResourceId'); $this->Conn->Query($sql); }