public function DeleteFavourite(ModuleFavourite_EntityFavourite $oFavourite)
 {
     $sql = "\n\t\t\tDELETE FROM " . Config::Get('db.table.favourite') . " \n\t\t\tWHERE\n\t\t\t\tuser_id = ?d\n\t\t\tAND\n\t\t\t\ttarget_id = ?d\n\t\t\tAND \n\t\t\t\ttarget_type = ?\t\t\t\t\n\t\t";
     if ($this->oDb->query($sql, $oFavourite->getUserId(), $oFavourite->getTargetId(), $oFavourite->getTargetType())) {
         return true;
     }
     return false;
 }
Example #2
0
 public function CanAddFavourite(ModuleFavourite_EntityFavourite $oFavourite, ModuleUser_EntityUser $oUser)
 {
     if ($oFavourite->getTargetType() == "talk") {
         $oTalk = $this->ModuleTalk_GetTalkById($oFavourite->getTargetId());
         if ($oUser->getId() && $oTalk->getTalkUser()) {
             return true;
         }
     } elseif ($oFavourite->getTargetType() == "topic") {
         $oTopic = $this->ModuleTopic_GetTopicById($oFavourite->getTargetId());
         if (in_array($oTopic->getBlogId(), $this->ModuleBlog_GetAccessibleBlogsByUser($oUser)) or $oTopic->getBlog()->getType() == "open") {
             return true;
         }
     } elseif ($oFavourite->getTargetType() == "comment") {
         $oComment = $this->ModuleComment_GetCommentById($oFavourite->getTargetId());
         if (in_array($oComment->getTarget()->getBlogId(), $this->ModuleBlog_GetAccessibleBlogsByUser($oUser)) or $oComment->getTarget()->getBlog()->getType() == "open") {
             return true;
         }
     }
     return false;
 }
 /**
  * Удаляет комментарий из избранного
  *
  * @param  ModuleFavourite_EntityFavourite $oFavourite Объект избранного
  * @return bool
  */
 public function DeleteFavouriteComment(ModuleFavourite_EntityFavourite $oFavourite)
 {
     if ($oFavourite->getTargetType() == 'comment' && ($oComment = $this->Comment_GetCommentById($oFavourite->getTargetId())) && in_array($oComment->getTargetType(), Config::get('module.comment.favourite_target_allow'))) {
         return $this->Favourite_DeleteFavourite($oFavourite);
     }
     return false;
 }
Example #4
0
 /**
  * Удаляет письмо из избранного
  *
  * @param  ModuleFavourite_EntityFavourite $oFavourite	Объект избранного
  * @return bool
  */
 public function DeleteFavouriteTalk(ModuleFavourite_EntityFavourite $oFavourite)
 {
     return $oFavourite->getTargetType() == 'talk' ? $this->Favourite_DeleteFavourite($oFavourite) : false;
 }
 /**
  * Удаляет теги
  *
  * @param ModuleFavourite_EntityFavourite $oFavourite    Объект избранного
  *
  * @return bool
  */
 public function DeleteTags($oFavourite)
 {
     $sql = "\n\t\t\tDELETE FROM ?_favourite_tag\n\t\t\tWHERE\n\t\t\t\tuser_id = ?d\n\t\t\t\tAND\n\t\t\t\ttarget_type = ?\n\t\t\t\tAND\n\t\t\t\ttarget_id = ?d\n\t\t";
     $bResult = $this->oDb->query($sql, $oFavourite->getUserId(), $oFavourite->getTargetType(), $oFavourite->getTargetId());
     return $bResult !== false;
 }
Example #6
0
 /**
  * Обновляет запись об избранном
  *
  * @param ModuleFavourite_EntityFavourite $oFavourite	Объект избранного
  * @return bool
  */
 public function UpdateFavourite(ModuleFavourite_EntityFavourite $oFavourite)
 {
     if (!$oFavourite->getTags()) {
         $oFavourite->setTags('');
     }
     $this->SetFavouriteTags($oFavourite);
     $this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array("favourite_{$oFavourite->getTargetType()}_change_user_{$oFavourite->getUserId()}"));
     $this->Cache_Delete("favourite_{$oFavourite->getTargetType()}_{$oFavourite->getTargetId()}_{$oFavourite->getUserId()}");
     return $this->oMapper->UpdateFavourite($oFavourite);
 }
Example #7
0
 /**
  * Удаляет таргет из избранного
  *
  * @param  ModuleFavourite_EntityFavourite $oFavourite
  * @return bool
  */
 public function DeleteFavourite(ModuleFavourite_EntityFavourite $oFavourite)
 {
     //чистим зависимые кеши
     $this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array("favourite_{$oFavourite->getTargetType()}_change_user_{$oFavourite->getUserId()}"));
     $this->Cache_Delete("favourite_{$oFavourite->getTargetType()}_{$oFavourite->getTargetId()}_{$oFavourite->getUserId()}");
     return $this->oMapper->DeleteFavourite($oFavourite);
 }
 /**
  * Удаляет теги
  *
  * @param ModuleFavourite_EntityFavourite $oFavourite Объект избранного
  * @return bool
  */
 public function DeleteTags($oFavourite)
 {
     $sql = "\n      DELETE FROM " . Config::Get('db.table.favourite_tag') . "\n      WHERE\n        user_id = ?d\n        AND\n        target_type = ?\n        AND\n        target_id = ?d\n    ";
     if ($this->oDb->query($sql, $oFavourite->getUserId(), $oFavourite->getTargetType(), $oFavourite->getTargetId())) {
         return true;
     }
     return false;
 }
 /**
  * Удаляет теги
  *
  * @param ModuleFavourite_EntityFavourite $oFavourite Объект избранного
  * @return bool
  */
 public function DeleteTags($oFavourite)
 {
     $sql = "\n\t\t\tDELETE FROM " . Config::Get('db.table.favourite_tag') . "\n\t\t\tWHERE\n\t\t\t\tuser_id = ?d\n\t\t\t\tAND\n\t\t\t\ttarget_type = ?\n\t\t\t\tAND\n\t\t\t\ttarget_id = ?d\n\t\t";
     $res = $this->oDb->query($sql, $oFavourite->getUserId(), $oFavourite->getTargetType(), $oFavourite->getTargetId());
     return $this->IsSuccessful($res);
 }
Example #10
0
 /**
  * Удаляет комментарий из избранного
  *
  * @param  ModuleFavourite_EntityFavourite $oFavourite
  * @return bool
  */
 public function DeleteFavouriteComment(ModuleFavourite_EntityFavourite $oFavourite)
 {
     if ($oFavourite->getTargetType() == 'comment' && ($oComment = $this->Comment_GetCommentById($oFavourite->getTargetId())) && $oComment->getTargetType() == 'topic') {
         return $this->Favourite_DeleteFavourite($oFavourite);
     }
     return false;
 }