Ejemplo n.º 1
0
 /**
  * 
  * @param type $cnt - кол-во очков
  * @param type $data - данные, которые нужно сохранить, чтобы потом декодировать текст
  * @param type $silently - признак, нужно ли посылать пользователю уведомление о выдаче этих очков
  */
 public function givePoints($cnt, $data = null, $silently = false)
 {
     $pointDo = UserPointsBean::inst()->givePoints($this->userId, $this->reasonId, $cnt, $data);
     if (!$silently && $pointDo instanceof UserPointDO) {
         $this->givenPoints[] = $pointDo;
     }
 }
Ejemplo n.º 2
0
 public function getUserCanOpenCellsCnt($userId = null)
 {
     $userId = AuthManager::extractUserId($userId);
     //1. Сколько у пользователя очков?
     $pointsCnt = UserPointsBean::inst()->getPointsCnt($userId);
     if ($pointsCnt <= 0) {
         return 0;
     }
     //2. Сколько ячеек данный пользователь уже открыл?
     $canOpen = $pointsCnt - $this->getUserOwnedCellsCnt($userId);
     if ($canOpen <= 0) {
         return 0;
     }
     //3. Вернём минимум из того, что пользователь может открыть и того, сколько всего ячеек осталось
     return min($canOpen, $this->getFreeCellsCnt());
 }
Ejemplo n.º 3
0
 /**
  * Метод загружает все очки, выданные пользователю
  */
 public function getAllUserPoints(PsUser $user)
 {
     return UserPointsBean::inst()->getAllUserPoints($user->getId());
 }