-
Notifications
You must be signed in to change notification settings - Fork 0
/
vote_ajax.php
111 lines (89 loc) · 3.38 KB
/
vote_ajax.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
session_start();
// Includes
include_once('controleur/includes/config.php');
include_once('controleur/includes/fonctions.php');
$bdd = connexionbdd(); // On se connecte à la base de données
$id_user = htmlspecialchars($_SESSION['membre_id']); // Recuperation id de l'utilisateur
?>
<div id="inserer_vote">
<?php
$potin_courant['id_Potin'] = $_GET['num_potin'];
?>
<?php
include_once('modele/infos_potin.php');
include_once('modele/requetes_vote.php');
if(deja_vote($potin_courant['id_Potin'], $id_user, $bdd)) // si on a déjà voté
{
echo '<p>Vous avez déjà voté !</p>';
$afficher_resultat = true;
}
else if($id_user == auteur_du_potin($potin_courant['id_Potin'], $bdd)) // Si on est l'auteur du potin
{
echo '<p>Vous êtes l\'auteur de ce potin</p>';
$afficher_resultat = true;
}
else // On peut voter
{
include('vue/affichage_potin/formulaire_de_vote.php');
$afficher_resultat = false;
}
?>
</div>
<div class="modal-body contenu-centre">
<?php
if($afficher_resultat)
{
include_once('modele/infos_potin.php');
$concernes_dans_potin = concernes_potin($potin_courant['id_Potin'], $bdd); // On cherche tous les utilisateurs concernes
foreach ($concernes_dans_potin as $key => $value) {
if(deja_vote($potin_courant['id_Potin'], $value, $bdd) > 0) // Si le concerne courant a voté
{
include_once('modele/infos_user.php');
$concerne_courant = infos_user($value, $bdd);
echo 'L\'avis de '.$concerne_courant['prenom'].' : ';
$vote_concerne_courant = vote_user($potin_courant['id_Potin'], $value, $bdd);
if($vote_concerne_courant == -1)
{
echo 'C\'est faux !';
}
else if($vote_concerne_courant == 0)
{
echo 'Je n\' ai pas d\'avis.';
}
else if($vote_concerne_courant == 1)
{
echo 'Je l\'admets, c\'est vrai.';
}
echo '<br>';
}
}
echo '<br>';
$resultat_votes = resultat_vote($potin_courant['id_Potin'], $bdd);
include('vue/affichage_potin/barre_votes.php');
if($resultat_votes == 'non_disponible') // Si il n'y a pas eu assez de votes
{
echo '<p>Trop peu de personnes ont voté pour déterminer la véracité de ce potin.</p>';
}
else if($resultat_votes == 'sur')
{
echo '<p>C\'est sûr !</p>';
}
else if($resultat_votes == 'possible')
{
echo '<p>C\'est possible</p>';
}
else if($resultat_votes == 'surement_faux')
{
echo '<p>Ce potin est sûrement faux</p>';
}
else if($resultat_votes == 'faux')
{
echo '<p>Ce n\'est pas vrai</p>';
}
else if($resultat_votes == 'calomnie')
{
echo '<p>Ce n\' est que pure calomnie !</p>';
}
}
?>