summaryrefslogtreecommitdiff
path: root/beta_accents/app/include/je.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'beta_accents/app/include/je.inc.php')
-rw-r--r--beta_accents/app/include/je.inc.php244
1 files changed, 244 insertions, 0 deletions
diff --git a/beta_accents/app/include/je.inc.php b/beta_accents/app/include/je.inc.php
new file mode 100644
index 0000000..dcbb75e
--- /dev/null
+++ b/beta_accents/app/include/je.inc.php
@@ -0,0 +1,244 @@
+<?php
+require_once ('include/connect.inc.php');
+
+ function traiter_formulaire_valider_modif_personnes()
+ {
+ //Vérification a faire pour savoir si c'est bien le propriétaire ?!! $_SESSION['session_idP']
+ $tabParticipant = array();
+ if (isset($_GET['dataParticipants'])) $tabParticipant = $_GET['dataParticipants'];
+ $idL=-1;
+ if (!isset($_GET['idL']) && isset($_GET['listname']))
+ {
+ if (isset($_GET['isPrivate'])) $isPrivate = 'oui'; else $isPrivate = 'non';
+ $idL = list_new($_GET['listname'],$_GET['idP'],$isPrivate);
+ }
+ else {$idL = $_GET['idL'];}
+
+ if ($idL != -1) list_modif($idL,$tabParticipant);
+ }
+
+ function traiter_formulaire_delete_list()
+ {
+ //Vérification a faire pour savoir si c'est bien le propriétaire ?!! $_SESSION['session_idP']
+ if (isset($_GET['idL'])) list_delete($_GET['idL']);
+ }
+
+ function list_delete($idL)
+ {
+ $result = mysql_query("DELETE FROM AWOR_Appartenir WHERE idL=$idL;");
+ $result = mysql_query("DELETE FROM AWOR_Liste WHERE idL=$idL;");
+ }
+
+ function list_new($listname,$idP,$isPrivate)
+ {
+ $result = mysql_query("INSERT INTO AWOR_Liste (libelleL,estPrivee,idP_Createur) VALUES ('$listname','$isPrivate',$idP)") or die (mysql_error());
+ if (mysql_affected_rows() > 0)
+ {
+ return (mysql_insert_id());
+ }
+ return (false);
+ }
+
+ function list_modif($idL,$tabParticipant)
+ {
+ $result = mysql_query("SELECT P.idP,P.courrielP FROM AWOR_Appartenir A, AWOR_Personne P WHERE P.idP = A.idP AND A.idL=$idL") or die (mysql_error());
+ if (mysql_num_rows($result)>=0)
+ {
+ //Fabrication des trois tableaux
+ $tabOldPers = array();
+ $tabOldPersMail = array();
+ $tabNewPers = array();
+ if (!empty($tabParticipant)) $tabNewPers = $tabParticipant;
+ for($i=0;$i<mysql_num_rows($result);$i++)
+ {
+ $row = mysql_fetch_array($result);
+ $tabOldPers[$i] = $row[0];
+ $tabOldPersMail[$i] = $row[1];
+ }
+ //Boucle permettant de mettre a NULL les élements identiques aux deux tableaux
+ $i = 0;
+ while ($i < count($tabOldPers))
+ {
+ $exist=false;
+ for ($j=0;$j<count($tabNewPers);$j++)
+ {
+ if (($tabOldPers[$i] == $tabNewPers[$j]) or ($tabOldPersMail[$i] == $tabNewPers[$j]))
+ {
+ $exist = true;
+ $tabNewPers[$j]=NULL;
+ }
+ }
+ if ($exist)
+ {
+ $tabOldPers[$i]=NULL;
+ $tabOldPersMail[$i]=NULL;
+ }
+ $i++;
+ }
+ }
+
+ //Construction du tableau des participants a ajouter
+ $tabAdd = array();
+ foreach ($tabNewPers as $pers)
+ {
+ //Si c'est une adresse Mail : Inscription + Ajout Sinon Ajour simplement
+ if (!stristr($pers,'@')===false)
+ {
+ $tabAdd[] = new_pers($pers);
+ }
+ else
+ {
+ if ($pers != NULL) $tabAdd[] = $pers;
+ }
+ }
+ //Enleve les redondances d'idP
+ $tabAdd=array_unique($tabAdd);
+ //Envoie a la fonction d'ajout de personne
+ list_add_pers($tabAdd,$idL);
+
+ //Construction du tableau des participants a ajouter
+ $tabRemove = array();
+ foreach ($tabOldPers as $pers)
+ {
+ if ($pers != NULL) $tabRemove[] = $pers;
+ }
+ //Envoie a la fonction de suppression de personne
+ list_remove_pers($tabRemove,$idL);
+
+ }
+
+ function list_add_pers ($tabPers,$idL)
+ {
+ foreach ($tabPers as $pers)
+ {
+ $result=mysql_query("INSERT INTO AWOR_Appartenir (idP,idL) VALUES ($pers,$idL);");
+ }
+
+ }
+
+ function list_remove_pers ($tabPers,$idL)
+ {
+
+ foreach ($tabPers as $pers)
+ {
+ $result = mysql_query("DELETE FROM AWOR_Appartenir WHERE idP=$pers AND idL=$idL;");
+ }
+
+ }
+
+
+ //Fonction Inscription qui prends en parametre une adresse mail $persMail et qui retourne l'id de la perssonne (s'il elle existe)
+ // ou Insert une personne et retourne son identifiant
+ function new_pers ($persMail)
+ {
+ $result = mysql_query("SELECT idP,courrielP FROM AWOR_Personne WHERE courrielP = '$persMail'");
+ if (mysql_num_rows($result)>0)
+ {
+ $row = mysql_fetch_array($result);
+ return ($row['idP']);
+ }
+ else
+ {
+ $result = mysql_query("INSERT INTO AWOR_Personne (courrielP,loginP,nomP) VALUES ('$persMail','$persMail','$persMail')");
+ return (mysql_insert_id());
+ }
+
+ return (false);
+ }
+
+
+
+ //Fonction qui affiche toutes les liste public ainsi que les liste privée possédées par idP
+ function generate_html_array_list ($idP)
+ {
+ $result = mysql_query("SELECT idL,libelleL,estPrivee,idP_Createur FROM AWOR_Liste WHERE idP_Createur=$idP OR estPrivee='non' ORDER BY estPrivee,libelleL");
+ echo "<table>\n<tr>\n<th>Supprimer</th>\n<th>Type</th>\n<th>Libell&eacute;</th>\n</tr>\n";
+ if (mysql_num_rows($result)>0)
+ {
+
+ for($i=0;$i<mysql_num_rows($result);$i++)
+ {
+ $row = mysql_fetch_array($result);
+ echo "<tr>\n<td>";
+ if ($row['estPrivee'] == 'oui' || $row['idP_Createur']==$idP) echo "<a href=\"#\" onclick=\"loadid('popdeletelist.php?idL=".$row[0]."','popdeletelist',true);popon('popdeletelist')\"><img src=\"images/supprimer.png\" alt=\"Supprimer ".$row[1]."\" /></a></td>\n" ; else echo "</td>\n";
+ if ($row['estPrivee'] == 'oui') echo "<td>estPriv&eacute;e" ; else echo "<td>Public";
+ echo "</td>\n<td>";
+ echo "<a href=\"#\" onclick=\"loadid('poppersonne.php?idL=".$row['idL']."&amp;idP_orga=".$idP."','poppersonne',true);popon('poppersonne')\">";
+ echo $row['libelleL'];
+ echo "</a></td>\n";
+ echo "</tr>\n";
+ }
+
+ }
+ echo "</table>\n";
+
+ }
+
+ function traiter_formulaire_commentaire()
+ {
+ if ($_GET['txtCommentaire'] != "")
+ {
+ require_once ('include/connect.inc.php');
+ if (isset($_GET['idR']))
+ {
+ $query="UPDATE AWOR_Repondre SET commentaireReponse ='".$_GET['txtCommentaire']."' WHERE idR=".$_GET['idR']." AND idP=".$_SESSION['session_idP'];
+ $result = @mysql_query($query);
+ if ( ! $result || ( mysql_affected_rows() !== 1 ) )
+ {
+ $query="INSERT INTO AWOR_Repondre(idR,idP,commentaireReponse) VALUES (".$_GET['idR'].", ".$_SESSION['session_idP'].", '".$_GET['txtCommentaire']."')";
+
+ $result = mysql_query($query);
+ if ( ! $result || ( mysql_affected_rows() !== 1 ))
+ {
+ echo $query;
+ echo "Erreur BD\n";
+ return;
+ }
+ }
+ }
+ }
+ else
+ {
+ $query="DELETE FROM AWOR_Repondre WHERE idR=".$_GET['idR']." AND idP=".$_SESSION['session_idP'];
+ $result = mysql_query($query);
+ }
+ }
+
+ // Modifiée par Ludo pour les problèmes de vriables de session et pour d'autres détails :
+ // S'il n'y a pas de commentaire, on affiche le tableau vide
+ function generate_html_reunion_commentaires($idR)
+ {
+ $idP = $_SESSION['session_idP'];
+ echo '<table cellspacing="0" class="commentaires" summary="Liste des commentaires laissés pour les personnes conviées à cette réunion">';
+ echo '<thead>';
+ echo '<tr>';
+ echo "<th>Commentaires <a href=\"#\" onclick=\"loadid('popcommentaire.php?idR=".$idR."&amp;idP=".$idP."','popcommentaire',true);popon('popcommentaire');\">(Editer votre commentaire)</a></th>";
+ echo '</tr>';
+ echo '</thead>';
+ $requete = "SELECT P.nomP,P.prenomP,P.courrielP,R.commentaireReponse FROM AWOR_Repondre R,AWOR_Personne P WHERE P.idP = R.idP AND R.idR = '".$idR."'";
+ //echo "DEBUG : requete : $requete\n";
+ $resultat = mysql_query($requete);
+ if($resultat != false)
+ {
+ if(mysql_num_rows($resultat) > 0)
+ {
+ while($pers = mysql_fetch_array($resultat))
+ {
+ echo '<tr><td>';
+ if ($pers["nomP"] !== "" || $pers["prenomP"] !== "") echo $pers["nomP"] . " " . $pers["prenomP"]; else echo $row["courrielP"];
+ echo " : ".$pers["commentaireReponse"]."</td></tr>\n";
+
+ }
+ }
+ else
+ {
+ echo "<tr><td>Aucun commentaire pour le moment.</td></tr>\n";
+ }
+ }
+
+ echo '</table>';
+
+ }
+
+
+?> \ No newline at end of file