summaryrefslogtreecommitdiff
path: root/appli_3_alpha_old/app/include/je.inc.php
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2018-06-30 11:10:17 +0200
committerLudovic Pouzenc <ludovic@pouzenc.fr>2018-06-30 11:10:17 +0200
commit1269889704386de951d7f91eb169eb1e1bb36cc0 (patch)
treeff0b0fbcf5d6cc6cb769ef25924721e348f339a5 /appli_3_alpha_old/app/include/je.inc.php
parentc93c261a461c9a2359bdcd75f7136fcb05237106 (diff)
download2007-AWOR-1269889704386de951d7f91eb169eb1e1bb36cc0.tar.gz
2007-AWOR-1269889704386de951d7f91eb169eb1e1bb36cc0.tar.bz2
2007-AWOR-1269889704386de951d7f91eb169eb1e1bb36cc0.zip
Sous-dossier app entre old4 et old5
Diffstat (limited to 'appli_3_alpha_old/app/include/je.inc.php')
-rw-r--r--appli_3_alpha_old/app/include/je.inc.php175
1 files changed, 175 insertions, 0 deletions
diff --git a/appli_3_alpha_old/app/include/je.inc.php b/appli_3_alpha_old/app/include/je.inc.php
new file mode 100644
index 0000000..e902a1a
--- /dev/null
+++ b/appli_3_alpha_old/app/include/je.inc.php
@@ -0,0 +1,175 @@
+<?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 Appartenir WHERE idL=$idL;");
+ $result = mysql_query("DELETE FROM Liste WHERE idL=$idL;");
+ }
+
+ function list_new($listname,$idP,$isPrivate)
+ {
+ $result = mysql_query("INSERT INTO Liste (libelleL,estPrivee,idP_Createur) VALUES ('$listname','$isPrivate',$idP)") or die (mysql_error());
+ if (mysql_affected_rows() > 0)
+ {
+ return (mysql_insert_id());
+ }
+ }
+
+ function list_modif($idL,$tabParticipant)
+ {
+ $result = mysql_query("SELECT P.idP,P.courrielP FROM Appartenir A, 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 Appartenir (idP,idL) VALUES ($pers,$idL);");
+ }
+
+ }
+
+ function list_remove_pers ($tabPers,$idL)
+ {
+
+ foreach ($tabPers as $pers)
+ {
+ $result = mysql_query("DELETE FROM 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 Personne WHERE courrielP = '$persMail'");
+ if (mysql_num_rows($result)>0)
+ {
+ $row = mysql_fetch_array($result);
+ return ($row['idP']);
+ }
+ else
+ {
+ $result = mysql_query("INSERT INTO Personne (courrielP,loginP) VALUES ('$persMail','$persMail')");
+ return (mysql_insert_id());
+ }
+
+ return (0);
+ }
+
+
+
+ //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 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";
+
+ }
+?> \ No newline at end of file