diff --git a/app/AppKernel.php b/app/AppKernel.php index d0e15713..aef38214 100644 --- a/app/AppKernel.php +++ b/app/AppKernel.php @@ -48,6 +48,7 @@ public function registerBundles() new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(), new InsaLan\ApiBundle\InsaLanApiBundle(), + new Sensio\Bundle\BuzzBundle\SensioBuzzBundle(), ); if (in_array($this->getEnvironment(), array('dev', 'test'))) { diff --git a/composer.json b/composer.json index 29018f0d..3267a977 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,8 @@ "payum/paypal-express-checkout-nvp": "0.12.*", "lexik/maintenance-bundle": "^2.0", "ehesp/steam-login": "^1.1", - "adoy/oauth2": "^1.3" + "adoy/oauth2": "^1.3", + "sensio/buzz-bundle": "dev-master" }, "require-dev": { "sensio/generator-bundle": "~2.3", diff --git a/composer.lock b/composer.lock index 2c086a72..1dbbb171 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "668e06fc279563871fb30e8b34afdc2f", - "content-hash": "b601f9840b26ff0a74e339c38eff3277", + "hash": "7d0c0f7f821d3ce155721943059ae312", + "content-hash": "771275d92c115e03dc2745dc5b65b7cf", "packages": [ { "name": "adoy/oauth2", @@ -2668,6 +2668,54 @@ ], "time": "2012-12-21 11:40:51" }, + { + "name": "sensio/buzz-bundle", + "version": "dev-master", + "target-dir": "Sensio/Bundle/BuzzBundle", + "source": { + "type": "git", + "url": "https://github.com/sensiolabs/SensioBuzzBundle.git", + "reference": "ad7c722f755471b80f5c9c7dd703b2975f8a518b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sensiolabs/SensioBuzzBundle/zipball/ad7c722f755471b80f5c9c7dd703b2975f8a518b", + "reference": "ad7c722f755471b80f5c9c7dd703b2975f8a518b", + "shasum": "" + }, + "require": { + "kriswallsmith/buzz": "> 0.6", + "php": ">=5.3.2" + }, + "type": "symfony-bundle", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-0": { + "Sensio\\Bundle\\BuzzBundle": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marc Weistroff", + "email": "marc.weistroff@sensio.com" + } + ], + "description": "Bundle around the Buzz HTTP client", + "homepage": "https://github.com/sensio/SensioBuzzBundle", + "keywords": [ + "buzz", + "http client" + ], + "time": "2016-03-15 10:06:41" + }, { "name": "sensio/distribution-bundle", "version": "v3.0.36", @@ -4713,7 +4761,8 @@ "knplabs/knp-markdown-bundle": 20, "paquettg/leaguewrap": 20, "payum/payum-bundle": 0, - "payum/offline": 0 + "payum/offline": 0, + "sensio/buzz-bundle": 20 }, "prefer-stable": false, "prefer-lowest": false, diff --git a/src/InsaLan/TournamentBundle/Controller/AdminController.php b/src/InsaLan/TournamentBundle/Controller/AdminController.php index 35b1bc18..4727b40f 100644 --- a/src/InsaLan/TournamentBundle/Controller/AdminController.php +++ b/src/InsaLan/TournamentBundle/Controller/AdminController.php @@ -30,7 +30,11 @@ public function indexAction($id = null) $tournaments = $em->getRepository('InsaLanTournamentBundle:Tournament')->findAll(); $a = array(null => ''); foreach ($tournaments as $t) { - $a[$t->getId()] = $t->getName(); + + if($t->getTournamentOpen()->format("Y") == date("Y")) { + $a[$t->getId()] = $t->getName(); + } + } $form = $this->createFormBuilder() diff --git a/src/InsaLan/TournamentBundle/Controller/UserController.php b/src/InsaLan/TournamentBundle/Controller/UserController.php index d88a9f1b..d0ca86ba 100644 --- a/src/InsaLan/TournamentBundle/Controller/UserController.php +++ b/src/InsaLan/TournamentBundle/Controller/UserController.php @@ -70,8 +70,38 @@ public function indexAction() { if(!$in) $tournaments[] = $t; } + $validatedTeams = []; + $voipData = []; + $buzz = $this->container->get('buzz'); + $buzz->getClient()->setVerifyPeer(false); + $buzz->getClient()->setVerifyHost(false); + + foreach($participants as $p) { + if($p->getParticipantType() == 'team') { + $canAddMumble = true; + foreach($p->getPlayers() as $player) { + if(!$player->isOk()) { + $canAddMumble = true; + break; + } + } + if($canAddMumble) { + try { + $r = $buzz->get($this->container->getParameter('voip_service_adress').'container/'.$p->getId()); + $voipData[$p->getId()] = $r->getContent(); + $voipData[$p->getId()] = json_decode($voipData[$p->getId()]); + } catch(Exception $e) { + + } + + $validatedTeams[$p->getId()] = true; + } + } + } + + - return array('tournaments' => $tournaments, 'participants' => $participants); + return array('tournaments' => $tournaments, 'participants' => $participants, 'validatedTeams' => $validatedTeams, 'voipData' => $voipData, 'voip_ip' => $this->container->getParameter('voip_service_ip_adress')); } @@ -936,6 +966,32 @@ public function roundAddReplayAction(Request $request, Entity\Participant $team, return array("form" => $form->createView()); } + + /** + * Add a replay to a round of the tournament + * The replay is an uploaded file + * @Route("/tournament/team/{id}/voip") + * @Template() + */ + public function addVOIPAction(Request $request, Entity\Participant $team) + { + $type = 'MUMBLE'; + if($request->query->get('voip') == 'mumble') { + $type = 'MUMBLE'; + + } + else if($request->query->get('voip') == 'teamspeak') { + $type = 'TEAMSPEAK'; + + } + $buzz = $this->container->get('buzz'); + $buzz->getClient()->setVerifyPeer(false); + $buzz->getClient()->setVerifyHost(false); + $params = array('team' => $team->getId(), 'type' => $type); + $r = $buzz->put('https://localhost:8000/create', array('Content-Type' => 'application/json'),json_encode($params)); + + return $this->redirect($this->generateUrl('insalan_tournament_user_index')); + } /** PRIVATE **/ protected function usernameSet($em, $usr, $player, $request, $tournament) { @@ -1042,4 +1098,6 @@ private function populateTournamentCode(Entity\Match $m) "extra" => $m->getId(), "pass" => md5('insalan_match_#'.$m->getId().'_'.$round))); } + + } diff --git a/src/InsaLan/TournamentBundle/Resources/views/Part/ChoiceTeamActive.html.twig b/src/InsaLan/TournamentBundle/Resources/views/Part/ChoiceTeamActive.html.twig index 1db3a881..07c0911d 100644 --- a/src/InsaLan/TournamentBundle/Resources/views/Part/ChoiceTeamActive.html.twig +++ b/src/InsaLan/TournamentBundle/Resources/views/Part/ChoiceTeamActive.html.twig @@ -15,12 +15,13 @@
+ {% if tournament.loginType == "Autre" %} Annuler {% else %} Annuler {% endif %} - + Créer Rejoindre