public function setUserTranslateRating($iUserId, $iTranslateRate) { $oPeriod = Period::getCurrentPeriod(); $oUser = UserTable::getInstance()->findOneById($iUserId); if (!($oContentRating = $oUser->hasRateContent($this->getId()))) { $oContentRating = new ContentRating(); $oContentRating->setContentId($this->getId()); $oContentRating->setPeriodId($oPeriod->getId()); $oContentRating->setUserId($iUserId); } $oContentRating->setTranslateRating($iTranslateRate); $oContentRating->save(); $aArticles = ContentRatingTable::getInstance()->getRatesByArticle($this->getId(), $oPeriod->getId()); $iSum = 0; foreach ($aArticles as $oRating) { $iSum += $oRating->getTranslateRating(); } $this->setTransRate($iSum / $aArticles->count()); $this->save(); }