Exemplo n.º 1
0
 /**
  * Method the add the reward
  *
  * @param Request $request
  * @return boolean
  * @throws \Exception
  */
 public function success(Request $request)
 {
     $user = $this->getUser4Id($request->getUserId());
     if (!$user) {
         throw new \Exception('User not found');
     }
     // we already added add the reward, so skip this =)
     if ($this->isStatusSuccess($request) && $this->isDonateAlreadyAdded($request)) {
         // no exception, or the other side spam the service ...
         throw new AlreadyAddedException('already added');
     }
     // check if donate should add coins or remove
     $request->setAmount(abs($request->getAmount()));
     $coins = $this->isStatusSuccess($request) ? $request->getAmount() : -$request->getAmount();
     $request->setAmount($coins);
     // save the message if gamebackend-service is unavailable
     $errorMessage = '';
     try {
         $this->coinService->addCoins($user, $coins);
     } catch (\Exception $e) {
         $request->setStatus($request::STATUS_ERROR);
         $errorMessage = $e->getMessage();
     }
     if ($request->isReasonToBan()) {
         $expire = (int) $this->collectionOptions->getConfig()['payment-api']['ban-time'] + time();
         $reason = 'Donate - ChargeBack';
         $this->userBlockService->blockUser($user, $expire, $reason);
     }
     $this->saveDonateLog($request, $user, $errorMessage);
     return true;
 }
Exemplo n.º 2
0
 /**
  * @param int $page
  * @return \PServerCore\Entity\News[]|Paginator
  */
 public function getActiveNews($page = 1)
 {
     $queryBuilder = $this->getNewsQueryBuilder();
     $queryBuilder->where('p.active = :active')->setParameter('active', 1);
     $adapter = new DoctrineAdapter(new ORMPaginator($queryBuilder));
     $paginator = new Paginator($adapter);
     $paginator->setDefaultItemCountPerPage($this->collectionOptions->getConfig()['news']['limit']);
     $paginator->setCurrentPageNumber($page);
     return $paginator;
 }
Exemplo n.º 3
0
 /**
  * Register constructor.
  * @param EntityManager $entityManager
  * @param AdapterInterface $sanCaptcha
  * @param Collection $collection
  */
 public function __construct(EntityManager $entityManager, AdapterInterface $sanCaptcha, Collection $collection)
 {
     parent::__construct();
     $this->entityManager = $entityManager;
     $this->sanCaptcha = $sanCaptcha;
     $this->collection = $collection;
     $this->add(['type' => Form\Element\Csrf::class, 'name' => 'eugzhoe45gh3o49ug2wrtu7gz50']);
     $this->add(['name' => 'username', 'options' => ['label' => 'Username'], 'attributes' => ['placeholder' => 'Username', 'class' => 'form-control', 'type' => 'text', 'required' => true]]);
     $this->add(['name' => 'email', 'options' => ['label' => 'Email'], 'attributes' => ['placeholder' => 'Email', 'class' => 'form-control', 'type' => 'email', 'required' => true]]);
     $this->add(['name' => 'emailVerify', 'options' => ['label' => 'Email Verify'], 'attributes' => ['placeholder' => 'Email Verify', 'class' => 'form-control', 'type' => 'email', 'required' => true]]);
     $this->add(['name' => 'password', 'options' => ['label' => 'Password'], 'attributes' => ['placeholder' => 'Password', 'class' => 'form-control', 'type' => 'password', 'required' => true]]);
     $this->add(['name' => 'passwordVerify', 'options' => ['label' => 'Password Verify'], 'attributes' => ['placeholder' => 'Password Verify', 'class' => 'form-control', 'type' => 'password', 'required' => true]]);
     if ($this->collection->getConfig()['password']['secret_question']) {
         $entityOptions = $this->collection->getEntityOptions();
         $this->add(['name' => 'question', 'type' => 'DoctrineModule\\Form\\Element\\ObjectSelect', 'options' => ['object_manager' => $this->entityManager, 'target_class' => $entityOptions->getSecretQuestion(), 'property' => 'question', 'label' => 'SecretQuestion', 'empty_option' => '-- select --', 'is_method' => true, 'find_method' => ['name' => 'getQuestions']], 'attributes' => ['class' => 'form-control', 'required' => true]]);
         $this->add(['name' => 'answer', 'options' => ['label' => 'SecretAnswer'], 'attributes' => ['placeholder' => 'Answer', 'class' => 'form-control', 'type' => 'text', 'required' => true]]);
     }
     $captcha = new Form\Element\Captcha('captcha');
     $captcha->setCaptcha($this->sanCaptcha)->setOptions(['label' => 'Please verify you are human.'])->setAttributes(['class' => 'form-control', 'type' => 'text', 'required' => true]);
     $this->add($captcha, ['priority' => -90]);
     $submitElement = new Form\Element\Button('submit');
     $submitElement->setLabel('Register')->setAttributes(['class' => 'btn btn-default', 'type' => 'submit']);
     $this->add($submitElement, ['priority' => -100]);
 }
Exemplo n.º 4
0
 /**
  * @return string
  */
 public function getDateTimeFormatTime()
 {
     return $this->collectionOptions->getConfig()['general']['datetime']['format']['time'];
 }
Exemplo n.º 5
0
 /**
  * @return Validator\StriposExists
  */
 public function getStriposValidator()
 {
     return new Validator\StriposExists($this->collection->getConfig(), Validator\StriposExists::TYPE_EMAIL);
 }