/** * (non-PHPdoc) * @see GamificationRules::scoreOnSaveModel() */ public function scoreOnSaveModel(CEvent $event) { parent::scoreOnSaveModel($event); if (array_key_exists('value', $event->sender->stage->originalAttributeValues) && $event->sender->stage->value == Opportunity::getStageClosedWonValue()) { $scoreType = static::SCORE_TYPE_WIN_OPPORTUNITY; $category = static::SCORE_CATEGORY_WIN_OPPORTUNITY; $gameScore = GameScore::resolveToGetByTypeAndPerson($scoreType, Yii::app()->user->userModel); $gameScore->addValue(); $saved = $gameScore->save(); if (!$saved) { throw new FailedToSaveModelException(); } GamePointUtil::addPointsByPointData(Yii::app()->user->userModel, static::getPointTypeAndValueDataByCategory($category)); } }