示例#1
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;
 }
 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);
 }
 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());
 }