| Line 39... |
Line 39... |
| 39 |
$this->verifierIdentificationUtilisateur($utilisateur);
|
39 |
$this->verifierIdentificationUtilisateur($utilisateur);
|
| 40 |
$this->utilisateurId = $utilisateur['id_utilisateur'];
|
40 |
$this->utilisateurId = $utilisateur['id_utilisateur'];
|
| Line 41... |
Line 41... |
| 41 |
|
41 |
|
| 42 |
// la suppression est autorisée pour le propriétaire et l'admin sur un commentaire ou une proposition
|
42 |
// la suppression est autorisée pour le propriétaire et l'admin sur un commentaire ou une proposition
|
| 43 |
// qui n'a jamais été commentée en retour
|
43 |
// qui n'a jamais été commentée en retour
|
| - |
|
44 |
if ($this->etreCommentaireSansEnfant() && $this->etreUtilisateurAutorise() &&
|
| 44 |
if ($this->etreCommentaireSansEnfant() && $this->etreUtilisateurAutorise()) {
|
45 |
$this->nePasEtreDeterminationInitiale()) {
|
| 45 |
$this->supprimerCommentaire();
|
46 |
$this->supprimerCommentaire();
|
| 46 |
$this->supprimerVotesAssocies();
|
47 |
$this->supprimerVotesAssocies();
|
| Line 47... |
Line 48... |
| 47 |
}
|
48 |
}
|
| Line 54... |
Line 55... |
| 54 |
if ($utilisateur == null) {
|
55 |
if ($utilisateur == null) {
|
| 55 |
$msg = "Ce service nécessite d'être identifié.";
|
56 |
$msg = "Ce service nécessite d'être identifié.";
|
| 56 |
throw new Exception($msg, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
|
57 |
throw new Exception($msg, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
|
| 57 |
}
|
58 |
}
|
| 58 |
}
|
59 |
}
|
| - |
|
60 |
|
| - |
|
61 |
private function nePasEtreDeterminationInitiale() {
|
| - |
|
62 |
$idCommentaireP = $this->bdd->proteger($this->commentaireId);
|
| - |
|
63 |
$requete = 'SELECT * '.
|
| - |
|
64 |
'FROM del_commentaire '.
|
| - |
|
65 |
"WHERE id_commentaire = $idCommentaireP ".
|
| - |
|
66 |
"AND (proposition_initiale = 1 OR proposition_retenue = 1) ".
|
| - |
|
67 |
' -- '.__FILE__.' : '.__LINE__;
|
| - |
|
68 |
$resultats = $this->bdd->recupererTous($requete);
|
| - |
|
69 |
if (!empty($resultats)) {
|
| - |
|
70 |
$msg = "Impossible de supprimer la proposition initiale ou la proposition retenue.";
|
| - |
|
71 |
throw new Exception($msg, RestServeur::HTTP_CODE_ERREUR);
|
| - |
|
72 |
}
|
| - |
|
73 |
return true;
|
| - |
|
74 |
}
|
| Line 59... |
Line 75... |
| 59 |
|
75 |
|
| 60 |
private function etreCommentaireSansEnfant() {
|
76 |
private function etreCommentaireSansEnfant() {
|
| 61 |
$idCommentaireP = $this->bdd->proteger($this->commentaireId);
|
77 |
$idCommentaireP = $this->bdd->proteger($this->commentaireId);
|
| 62 |
$requete = 'SELECT * '.
|
78 |
$requete = 'SELECT * '.
|