コード例 #1
0
ファイル: actions.class.php プロジェクト: rayku/rayku
 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');
 }
コード例 #2
0
ファイル: BaseUserAwardsPeer.php プロジェクト: rayku/rayku
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      UserAwards $value A UserAwards object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(UserAwards $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }