Index: trunk/core/units/favorites/favorites_eh.php =================================================================== diff -u -N --- trunk/core/units/favorites/favorites_eh.php (revision 8435) +++ trunk/core/units/favorites/favorites_eh.php (revision 0) @@ -1,91 +0,0 @@ - Array('subitem' => true), - ); - $this->permMapping = array_merge($this->permMapping, $permissions); - } - - /** - * Adds/removes item from favorites - * - * @param kEvent $event - */ - function OnFavoriteToggle(&$event) - { - $parent_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix'); - $parent_object =& $this->Application->recallObject($parent_prefix); - /* @var $parent_object kDBItem */ - - if (!$parent_object->isLoaded() || !$this->Application->CheckPermission('FAVORITES', 0, $parent_object->GetDBField('ParentPath'))) { - $event->status = erPERM_FAIL; - 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').')'; - $favorite_id = $this->Conn->GetOne($sql); - - $object =& $event->getObject(Array('skip_autoload' => true)); - /* @var $object kDBItem */ - - if ($favorite_id) { - $object->Delete($favorite_id); - } - else { - $object->Create(); - } - - $event->SetRedirectParam('pass', 'm,'.$parent_prefix); - } - - /** - * Prepares Favorite record fields - * - * @param kEvent $event - */ - function OnBeforeItemCreate(&$event) - { - $object =& $event->getObject(); - /* @var $object kDBItem */ - - $user_id = $this->Application->RecallVar('user_id'); - $object->SetDBField('PortalUserId', $user_id); - - $parent_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix'); - $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')); - } - - /** - * [HOOK] Deletes favorite record to item, that is beeing deleted - * - * @param kEvent $event - */ - function OnDeleteFavoriteItem(&$event) - { - $main_object =& $event->MasterEvent->getObject(); - - $sql = 'DELETE FROM '.$this->Application->getUnitOption($event->Prefix, 'TableName').' - WHERE ResourceId = '.$main_object->GetDBField('ResourceId'); - $this->Conn->Query($sql); - } - -} - - -?> \ No newline at end of file