public function executeAwardPurchaseSave() { if ($this->getRequest()->getMethod() == sfRequest::POST) { $awardcount = htmlentities($this->getRequestParameter('awardcount')); $this->user = $this->getUser()->getRaykuUser(); if ($awardcount > 0) { $limit = sfConfig::get('app_items_award_limit'); $amount = $awardcount * sfConfig::get('app_items_award_price'); if ($this->user->getPoints() > $amount) { $c = new Criteria(); $c->add(UserAwardsPeer::USER_ID, $this->user->getId()); $user_award = UserAwardsPeer::doSelectOne($c); if ($user_award) { $user_award->setAwards($awardcount + $user_award->getAwards()); $user_award->save(); } else { $user_award = new UserAwards(); $user_award->setAwards($awardcount); $user_award->setUserId($this->user->getId()); $user_award->save(); } $this->user->setPoints($this->user->getPoints() - $amount); $this->user->save(); $this->msg = "Profile icon has been successfully added to your profile."; } } else { $this->msg = " Wrong input"; } } else { $this->msg = "Unauthorized access."; } $this->setTemplate('checkout'); }