Esempio n. 1
0
 public function testSeasonFind()
 {
     Model::connect();
     $s = Season::create('second', false, 'http://example.org/foo2');
     $s->save();
     $s2 = Season::by_id($s->id);
     $this->assertEquals($s2->id, $s->id);
     $this->assertEquals($s2->name, 'second');
     $this->assertEquals($s2->visible, false);
     $this->assertEquals($s2->_is_new, false);
     $this->assertEquals($s->baseurl, 'http://example.org/foo2');
 }
Esempio n. 2
0
<?php

namespace bmtmgr;

require_once dirname(__DIR__) . '/src/common.php';
utils\csrf_protect();
$u = user\check_current();
$u->require_perm('admin');
utils\require_get_params(['club_id', 'season_id']);
utils\require_post_params(['firstname', 'lastname', 'gender']);
$season = Season::by_id($_GET['season_id']);
$club = User::by_id($_GET['club_id']);
$name = \sprintf('%s, %s', $_POST['lastname'], $_POST['firstname']);
$textid = \str_replace(' ', '_', $club->name . '-' . $_POST['firstname'] . ' ' . $_POST['lastname']);
try {
    $player = Player::create($season->id, $club->id, $textid, $name, $_POST['gender']);
    $player->save();
} catch (utils\DuplicateEntryException $e) {
    render_ajax_error(sprintf('Ein Spieler mit der Id "%s" existiert bereits', $textid));
    exit;
}
render_ajax('season/' . $season->id . '/club/' . $club->id . '/', ['player' => $player]);
Esempio n. 3
0
<?php

namespace bmtmgr;

require_once dirname(__DIR__) . '/src/common.php';
utils\csrf_protect();
$u = user\check_current();
$u->require_perm('admin');
utils\require_post_params(['name', 'season_id']);
$season = Season::by_id($_POST['season_id']);
try {
    $tournament = Tournament::create($season, $_POST['name']);
    $tournament->save();
} catch (utils\DuplicateEntryException $e) {
    render_ajax_error('Ein Turnier mit dem Namen "' . $_POST['name'] . '" existiert bereits');
    exit;
}
render_ajax('t/' . $tournament->id . '/', ['season' => $season, 'tournament' => $tournament]);
Esempio n. 4
0
 public function get_season()
 {
     return Season::by_id($this->season_id);
 }