Exemple #1
0
 /**
  * Insertion d'un nouveau vote et rafraichissement des votes
  *
  * @return array liste des configurations.
  */
 public function save(Rating $rating, $artId, $vote, $ipClient)
 {
     $rating->setIpClient($ipClient);
     $ip = '%' . $rating->getIpClient() . ',%';
     $sql = "select * from ratings WHERE article_id = ? AND used_ips NOT LIKE ?";
     $row = $this->getDb()->fetchAssoc($sql, array($artId, $ip));
     if ($row) {
         $rating->Addvote($vote);
         $ratingData = array('number_votes' => $rating->getNumberVotes(), 'total_points' => $rating->getTotalPoints(), 'used_ips' => '' . $rating->getUsedIps() . $rating->getIpClient() . ',');
         $this->getDb()->update('ratings', $ratingData, array('article_id' => $rating->getArticleId()));
     }
     return $rating;
 }
 /**
  * Converts an Rate object into an associative array for JSON encoding
  *
  * @param Rate $rating Rating object
  *
  * @return array Associative array whose fields are the rating properties.
  */
 private function buildRateArray(Rating $rating)
 {
     $datas = array("widget_id" => $rating->getArticleId(), "number_votes" => $rating->getNumberVotes(), "total_points" => $rating->getTotalPoints(), "dec_avg" => $rating->getDecAvg(), "whole_avg" => $rating->getWholeAvg());
     return $datas;
 }