コード例 #1
0
ファイル: game.php プロジェクト: radiosilence/trouble
 protected function _edit()
 {
     $t = $this->_template;
     $t->add('_jsapps', 'game_form');
     $storage = \Core\Storage::container()->get_storage('Game');
     $mapper = \Trouble\Game::mapper()->attach_storage($storage);
     try {
         if ($this->_args['game_id']) {
             $t->title = "Edit Game";
             $game = $this->_game;
             $this->_auth->check_admin('game', $game->id);
             $game->form_start_date = $game->start_date->format('Y-m-d');
             $game->form_end_date = $game->end_date->format('Y-m-d');
             $t->administration = $this->_administration($game);
             $t->vouchers = $this->_vouchers($game);
         } else {
             $t->title = "Game Creation";
             $t->new = True;
             $game = \Trouble\Game::create($_POST, True);
         }
         $t->game = $game;
         return $t->render('forms/game.php');
     } catch (\Core\AuthDeniedError $e) {
         throw new \Core\HTTPError(401, "Editing Game");
     } catch (\Core\AuthNotLoggedInError $e) {
         throw new \Core\HTTPError(401, "Editing Game");
     }
 }