private function buildSubscriptions($user_id)
 {
     $ret = [];
     $ret['list'] = Views\Subscription::fetchGamesDetailedByUser($this->pdo, $user_id);
     $ret['gpr'] = 2;
     return $ret;
 }
示例#2
0
 public function renderDetailHry()
 {
     $id = $this->getParam("id");
     $gameType = $this->gameTypes->fetchById($id);
     if (!$gameType) {
         $this->message->warning("Požadovaná hra nebyla nalezena.");
         $this->redirectPars('vypis', 'hry');
     }
     $this->addCss("hra.css");
     $this->addJs('odber_prepinac.js');
     $review = Views\GameRatingExtended::fetchOne($this->pdo, $this->user->user_id, $id);
     // @todo: fetch single subscribed game only
     $this->user->setSubscribedItems(Views\Subscription::fetchGamesByUser($this->pdo, $this->user->user_id));
     $this->template['form_action'] = ['controller' => 'vypis', 'action' => 'hodnotit', 'id' => $id];
     $this->template['g'] = $gameType;
     $this->template['ratings'] = $this->buildRatings($id);
     $this->template['rating'] = ['min' => 1, 'def' => 3, 'max' => 5];
     $this->template['highlight'] = $this->getParam("highlight");
     if ($review) {
         $this->template['rating']['def'] = $review->score;
         $this->template['has_review'] = $review->review;
     }
 }
 private function reservationCreatedSendMail($reservation_id)
 {
     $reservation = $this->reservaions->fetchById($reservation_id);
     if (!$reservation) {
         $this->message->warning("Při pokusu o odeslání upozornění hráčům odebírajícím hru " . $reservation->game_name . " nastala chyba.");
         return;
     }
     $gameType = $this->gameTypes->fetchById($reservation->game_type_id);
     $users = Views\Subscription::fetchUsersByGame($this->pdo, $reservation->game_type_id);
     $dateTime = DatetimeManager::reformat($reservation->reservation_date, DatetimeManager::HUMAN_DATE_ONLY);
     $dateTime .= ' ' . DatetimeManager::reformat($reservation->time_from, DatetimeManager::HUMAN_TIME_ONLY);
     $pars = ['gameName' => $gameType->getFullName(), 'reservationDate' => $dateTime, 'reservationUrl' => $this->urlGen->url(['controller' => 'rezervace', 'action' => 'detail', 'id' => $reservation_id])];
     MailBuilder::openReservationCreated($users, $pars);
 }
示例#4
0
 private function changeSubscribe($new_value)
 {
     if (!$this->user->isLoggedIn()) {
         $this->template['response'] = 'false';
         return;
     }
     $game_type_id = $this->getParam("id");
     $user_id = $this->user->user_id;
     Views\Subscription::remove($this->pdo, $user_id, $game_type_id);
     if ($new_value) {
         Views\Subscription::insert($this->pdo, $user_id, $game_type_id);
     }
     $new_sub_count = count(Views\Subscription::fetchUsersByGame($this->pdo, $game_type_id));
     $this->template['response'] = $new_sub_count;
 }
 public function doPoslatMail()
 {
     $gid = $this->getParam('game_type_id', INPUT_POST);
     $subject = $this->getParam('subject', INPUT_POST);
     $body = $this->getParam('mail_body', INPUT_POST);
     $users = $gid == self::ALL_USERS_GT_ID ? Views\UserExtended::fetchAll($this->pdo) : Views\Subscription::fetchUsersByGame($this->pdo, $gid);
     $result = MailSender::send($users, $body, $subject);
     if ($result['result']) {
         $this->message->success($result['message']);
     } else {
         $this->message->danger($result['message']);
     }
     $this->redirectPars('sprava', $this->getDefaultAction());
 }