Skip to content
This repository was archived by the owner on Oct 6, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'))) {
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
55 changes: 52 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/InsaLan/TournamentBundle/Controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
60 changes: 59 additions & 1 deletion src/InsaLan/TournamentBundle/Controller/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}


Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -1042,4 +1098,6 @@ private function populateTournamentCode(Entity\Match $m)
"extra" => $m->getId(),
"pass" => md5('insalan_match_#'.$m->getId().'_'.$round)));
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
</p>
</div>


{% if tournament.loginType == "Autre" %}
<a class="btn btn-danger ctrl grid-2 pull-left" href="{{ path('insalan_tournament_user_setplayer', {tournament: tournament.id}) }}">Annuler</a>
{% else %}
<a class="btn btn-danger ctrl grid-2 pull-left" href="{{ path('insalan_tournament_user_index') }}">Annuler</a>
{% endif %}
<a class="btn btn-primary ctrl grid-4 pull-left" href="{{ path('insalan_tournament_user_createteam', {tournament: tournament.id}) }}">Créer</a>
<a class="btn btn-primary ctrl grid-4 pull-left" href="{{ path('insalan_tournament_user_existingteam', {tournament: tournament.id}) }}">Rejoindre</a>
<br class="clear">
Expand Down
43 changes: 36 additions & 7 deletions src/InsaLan/TournamentBundle/Resources/views/User/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
<header>
<h2><span class="pull-left">Inscriptions aux tournois</span><span class="pull-right"><a href="{{ path('insalan_user_default_index') }}" class="btn2" style="font-size: 0.5em">&#x2699;Mon profil</a></span><br class="clear"></h2>
</header>

{% for participant in participants %}

<div class="frame {% if participant.validated == 2 %} frame-success
{% else %} frame-warning {% endif %}">
<header class="full">
Expand All @@ -20,7 +19,7 @@
{{ participant.tournament.name }} -
{% if participant.participantType == 'team' %} Équipe {% endif %}
{{ participant.name }}
{% if participant.participantType == 'team' %}
{% if participant.participantType == 'team' and participant.captain.user is defined%}
{% if participant.captain.user == app.user %} <a href="{{ path('insalan_tournament_user_editteam', {teamId: participant.id}) }}"><small style="font-size: 50%">[Modifier mon équipe]</small></a> {% endif %}
{% endif %}
</div>
Expand All @@ -44,7 +43,7 @@
<span>{{ p.gameName }}
{% if participant.captain == p %}
<span style="color: #FFB300">&#x1f451;</span>
{% elseif participant.captain.user == app.user and participant.tournament.isOpenedNow %}
{% elseif participant.captain is not null and participant.captain.user == app.user and participant.tournament.isOpenedNow %}
<a href="{{ path('insalan_tournament_user_promotecaptain', {teamId: participant.id, playerId: p.id}) }}" class="btn2" style="font-size: 0.8em">
&#x1f451; Passer capitaine
</a>
Expand All @@ -70,6 +69,7 @@
</div></li>
{% endif %}
</ul>

{% endif %}{# paticipantType == 'team' #}
{% if participant.participantType == 'player' and participant.manager is not null %}
<ul class="shift" style="list-style-type:none">
Expand All @@ -84,7 +84,7 @@
</div></li>
</ul>
{% endif %}

<br class="clear">

{% if participant.validated == 1 %}
Expand All @@ -102,6 +102,8 @@
{% if participant.participantType == 'player' %}
Votre participation sera validée après paiement.
{% endif %}


<br />
{% if participant.tournament.isFull() %}
<strong>Attention, ce tournoi est complet.</strong>
Expand All @@ -110,10 +112,37 @@
{% endif %}
{% endif %}
</div>

{% if participant.participantType == 'team' and validatedTeams[participant.id] is defined %}
{% if voipData[participant.id] is null or voipData[participant.id] is not defined or voipData[participant.id].notFound is defined%}
<a class="btn btn-primary" href="{{ path('insalan_tournament_user_addvoip', {id: participant.id,voip: 'mumble'}) }}">Demander un serveur Mumble</a>
<a class="btn btn-primary" href="{{ path('insalan_tournament_user_addvoip', {id: participant.id,voip: 'teamspeak'}) }}">Demander un serveur Teamspeak</a>
{% else %}
<div>
{% if voipData[participant.id].adminPassword is defined %}
Un serveur Mumble est disponible pour votre équipe !
<ul class="shift" style="list-style-type:none">
<li>Adresse ip : {{voip_ip}}</li>
<li>Mot de passe : {{voipData[participant.id].serverPassword}}</li>
{% if participant.captain is defined and participant.captain.user == app.user %}
<li> Mot de passe admin : {{voipData[participant.id].adminPassword}} </li>
{% endif %}
</ul>
{% else %}
Un serveur Teamspeak est disponible pour votre équipe !
<ul class="shift" style="list-style-type:none">
<li>Adresse ip : {{voip_ip}}</li>
<li>Port : {{voipData[participant.id].port}}</li>
<li>Token : {{voipData[participant.id].token}}</li>
</ul>
{% endif %}
</div>
{% endif %}
{% endif %}
{% if participant.manager is not null and participant.manager.user == app.user %}
{# 2-button layout #}{% if participant.tournament.isOpenedNow %}
{% if participant.participantType == 'team' %}


<a class="btn btn-danger ctrl grid-5 pull-left" href="{{ path('insalan_tournament_manager_leaveteam', {teamId: participant.id}) }}">Annuler</a>
{% elseif participant.participantType == 'player' %}
<a class="btn btn-danger ctrl grid-5 pull-left" href="{{ path('insalan_tournament_manager_leave', {tournament: participant.tournament.id}) }}">Annuler</a>
Expand Down Expand Up @@ -151,7 +180,7 @@
{% endif %}{# endif not a manager #}
<br class="clear">
</div>

{% endfor %}

<div class="frame frame-active">
Expand Down
2 changes: 1 addition & 1 deletion src/InsaLan/UserBundle/Controller/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use OAuth2\GrantType\AuthorizationCode;

class DefaultController extends Controller
{
{

/**
* @Route("/")
Expand Down