/**
  * Добавляет голосование
  *
  * @param ModuleVote_EntityVote $oVote	Объект голосования
  * @return bool
  */
 public function AddVote(ModuleVote_EntityVote $oVote)
 {
     $sql = "INSERT INTO " . Config::Get('db.table.vote') . " \n\t\t\t(target_id,\n\t\t\ttarget_type,\n\t\t\tuser_voter_id,\n\t\t\tvote_direction,\n\t\t\tvote_value,\t\t\t\n\t\t\tvote_date,\n\t\t\tvote_ip\n\t\t\t)\n\t\t\tVALUES(?d, ?, ?d, ?d, ?f, ?, ?)\n\t\t";
     if ($this->oDb->query($sql, $oVote->getTargetId(), $oVote->getTargetType(), $oVote->getVoterId(), $oVote->getDirection(), $oVote->getValue(), $oVote->getDate(), $oVote->getIp()) === 0) {
         return true;
     }
     return false;
 }
Exemple #2
0
 /**
  * Добавляет голосование
  *
  * @param ModuleVote_EntityVote $oVote	Объект голосования
  * @return bool
  */
 public function AddVote(ModuleVote_EntityVote $oVote)
 {
     if (!$oVote->getIp()) {
         $oVote->setIp(func_getIp());
     }
     if ($this->oMapper->AddVote($oVote)) {
         $this->Cache_Delete("vote_{$oVote->getTargetType()}_{$oVote->getTargetId()}_{$oVote->getVoterId()}");
         $this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array("vote_update_{$oVote->getTargetType()}_{$oVote->getVoterId()}"));
         return true;
     }
     return false;
 }
Exemple #3
0
 /**
  * Добавляет голосование
  *
  * @param ModuleVote_EntityVote $oVote    Объект голосования
  *
  * @return bool
  */
 public function AddVote(ModuleVote_EntityVote $oVote)
 {
     if (!$oVote->getIp()) {
         $oVote->setIp(F::GetUserIp());
     }
     if ($this->oMapper->AddVote($oVote)) {
         E::ModuleCache()->Delete("vote_{$oVote->getTargetType()}_{$oVote->getTargetId()}_{$oVote->getVoterId()}");
         E::ModuleCache()->CleanByTags(array("vote_update_{$oVote->getTargetType()}_{$oVote->getVoterId()}", "vote_update_{$oVote->getTargetType()}_{$oVote->getTargetId()}", "vote_update_{$oVote->getTargetType()}"));
         return true;
     }
     return false;
 }
Exemple #4
0
 public function AddVote(ModuleVote_EntityVote $oVote)
 {
     if (!$oVote->getIp()) {
         $oVote->setIp(func_getIp());
     }
     if ($this->oMapper->AddVote($oVote)) {
         $this->Cache_Delete("vote_{$oVote->getTargetType()}_{$oVote->getTargetId()}_{$oVote->getVoterId()}");
         $this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array("vote_update_{$oVote->getTargetType()}_{$oVote->getVoterId()}"));
         if (in_array($oVote->getTargetType(), array('topic', 'comment', 'user'))) {
             $oAction = Engine::GetEntity("PluginFeedbacks_ModuleFeedbacks_EntityAction");
             $oAction->setUserIdFrom($oVote->getVoterId());
             $oAction->setId(null);
             $oAction->setAddDatetime(time());
             $oAction->setDestinationObjectId($oVote->getTargetId());
             if ($oVote->getTargetType() == 'topic') {
                 $oTopic = $this->Topic_GetTopicById($oVote->getTargetId());
                 $oAction->setUserIdTo($oTopic->getUserId());
                 if ($oVote->getDirection() > 0) {
                     $oAction->setActionType('VoteTopic');
                 }
                 if ($oVote->getDirection() < 0) {
                     $oAction->setActionType('VoteDownTopic');
                 }
                 if ($oVote->getDirection() == 0) {
                     $oAction->setActionType('VoteAbstainTopic');
                 }
             }
             if ($oVote->getTargetType() == 'comment') {
                 $oComment = $this->Comment_GetCommentById($oVote->getTargetId());
                 $oAction->setUserIdTo($oComment->getUserId());
                 if ($oVote->getDirection() > 0) {
                     $oAction->setActionType('VoteComment');
                 } else {
                     $oAction->setActionType('VoteDownComment');
                 }
             }
             if ($oVote->getTargetType() == 'user') {
                 $oAction->setUserIdTo($oVote->getTargetId());
                 if ($oVote->getDirection() > 0) {
                     $oAction->setActionType('VoteUser');
                 } else {
                     $oAction->setActionType('VoteDownUser');
                 }
             }
             return true;
             $this->PluginFeedbacks_Feedbacks_SaveAction($oAction);
         }
         return true;
     }
     return false;
 }
Exemple #5
0
 /**
  * Добавляет голосование
  *
  * @param ModuleVote_EntityVote $oVote    Объект голосования
  *
  * @return bool
  */
 public function AddVote(ModuleVote_EntityVote $oVote)
 {
     $sql = "INSERT INTO ?_vote\n\t\t\t(target_id,\n\t\t\ttarget_type,\n\t\t\tuser_voter_id,\n\t\t\tvote_direction,\n\t\t\tvote_value,\n\t\t\tvote_date,\n\t\t\tvote_ip\n\t\t\t)\n\t\t\tVALUES(?d, ?, ?d, ?d, ?f, ?, ?)\n\t\t";
     $xResult = $this->oDb->query($sql, $oVote->getTargetId(), $oVote->getTargetType(), $oVote->getVoterId(), $oVote->getDirection(), $oVote->getValue(), $oVote->getDate(), $oVote->getIp());
     return $xResult !== false;
 }