Beispiel #1
0
 public function setUserContentRating($iUserId, $iTranslateRate)
 {
     $oPeriod = Period::getCurrentPeriod();
     $oUser = UserTable::getInstance()->findOneById($iUserId);
     if (!($oContentRating = $oUser->hasRateTranslate($this->getId()))) {
         $oContentRating = new ContentRating();
         $oContentRating->setContentId($this->getId());
         $oContentRating->setPeriodId($oPeriod->getId());
         $oContentRating->setUserId($iUserId);
     }
     $oContentRating->setContentRating($iTranslateRate);
     $oContentRating->save();
     $aArticles = ContentRatingTable::getInstance()->getRatesByArticle($this->getId(), $oPeriod->getId());
     $iSum = 0;
     foreach ($aArticles as $oRating) {
         $iSum += $oRating->getContentRating();
     }
     $this->setContRate($iSum / $aArticles->count());
     $this->save();
 }