<?php require_once './eagle/utils/Downloader.php'; require_once './eagle/utils/FileReader.php'; require_once './eagle/utils/Auth.php'; require_once './eagle/models/Comment.php'; require_once './eagle/models/Defense.php'; require_once './eagle/models/PitScouting.php'; $app->group('/team', function () { $this->get('/{url:.*\\/}', function ($req, $res, $args) { header('Location:/team/' . trim($args['url'], '/')); exit; }); $this->get('/{team:[0-9]{1,4}}', function ($req, $res, $args) { Auth::redirectIfNotLoggedIn(); $team = FileReader::getTeam($args['team']); if (!$team) { Downloader::getTeam($args['team']); header('Refresh:0'); } $events = FileReader::getEventsForTeam($args['team']); if (!$events) { Downloader::getEventsForTeam($args['team']); header('Refresh:0'); } $comments = Comment::where('team_id', $team->team_number); $defense = Defense::where('team_id', $args['team'])->orderBy('id', 'desc')->first(); $defenses = array(); $author = $defense ? $defense->author : false; if ($defense) { $defenses['Low Bar'] = $defense->low_bar;
require_once './eagle/utils/Auth.php'; require_once './eagle/utils/FileReader.php'; require_once './eagle/models/Comment.php'; $app->group('/comment', function () { $this->get('/{url:.*\\/}', function ($req, $res, $args) { header('Location:/event/' . trim($args['url'], '/')); exit; }); $this->get('/new', function ($req, $res, $args) { Auth::redirectIfNotLoggedIn(); $this->view->render($res, 'newComment.html', ['title' => 'New Comment', 'user' => Auth::getLoggedInUser()]); }); $this->post('/new', function ($req, $res, $args) { Auth::redirectIfNotLoggedIn(); $comment = new Comment(); $comment->user_id = Auth::getLoggedInUser()->id; $comment->author = Auth::getLoggedInUser()->name; $comment->team_id = $_POST['teamId']; $comment->notes = $_POST['notes']; $comment->save(); header('Location:/comment/' . $_POST['teamId']); exit; }); $this->get('/{team:[0-9]{1,4}}', function ($req, $res, $args) { Auth::redirectIfNotLoggedIn(); $comments = Comment::where('team_id', $args['team'])->get(); $title = 'Comments for ' . $args['team']; $this->view->render($res, 'teamComments.html', ['title' => $title, 'comments' => $comments, 'team' => FileReader::getTeam($args['team']), 'user' => Auth::getLoggedInUser()]); }); });