Пример #1
0
 public function notification()
 {
     $isAllowed = Util\Auth::isAuthorized($this->signedUser, 'member');
     $json = [];
     $json['result'] = \Rebond\Core\ResultType::ERROR;
     if (!$isAllowed) {
         $json['message'] = Util\Lang::lang('accessNonAuthorized');
         return json_encode($json);
     }
     $options = [];
     $options['where'][] = 'notification.has_read = false';
     $options['where'][] = 'notification.match_id = 0';
     $options['where'][] = 'notification.created_date > NOW() - INTERVAL ' . \Own\Bus\Engine::DAY * 28 . ' HOUR';
     $options['order'][] = 'notification.created_date DESC';
     $notifications = \Own\Bus\Notification\Data::loadAllByPlayerId($this->player->getId(), $options);
     $options = [];
     $options['where'][] = 'notification.has_read = true';
     $options['where'][] = 'notification.match_id = 0';
     $options['where'][] = 'notification.created_date > NOW() - INTERVAL ' . \Own\Bus\Engine::DAY * 28 . ' HOUR';
     $options['order'][] = 'notification.created_date DESC';
     $oldNotifications = \Own\Bus\Notification\Data::loadAllByPlayerId($this->player->getId(), $options);
     $result = \Own\Bus\Notification\Data::updateReadByPlayerId($this->player->getId());
     $json['result'] = $result;
     $tpl = new Util\Template(Util\Template::MODULE, ['bus', 'notification']);
     $tpl->set('items', $notifications);
     $tpl->set('oldItems', $oldNotifications);
     $json['html'] = $tpl->render('listing');
     $json['result'] = \Rebond\Core\ResultType::SUCCESS;
     return json_encode($json);
 }