summaryrefslogtreecommitdiff
path: root/beta_accents/app/include/ical.inc.php
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2018-06-30 11:37:30 +0200
committerLudovic Pouzenc <ludovic@pouzenc.fr>2018-06-30 11:37:30 +0200
commit5dac82f52f45ad27f16ec2ff63ee75e2f39ef942 (patch)
tree62cf671332976c83024139fc4c22009b382d45ff /beta_accents/app/include/ical.inc.php
parent34795da1b6bd714df0d5dce93558e04b2bb8a287 (diff)
download2007-AWOR-5dac82f52f45ad27f16ec2ff63ee75e2f39ef942.tar.gz
2007-AWOR-5dac82f52f45ad27f16ec2ff63ee75e2f39ef942.tar.bz2
2007-AWOR-5dac82f52f45ad27f16ec2ff63ee75e2f39ef942.zip
Renommage pour diff de beta_old1 vers beta_accents
Diffstat (limited to 'beta_accents/app/include/ical.inc.php')
-rw-r--r--beta_accents/app/include/ical.inc.php68
1 files changed, 68 insertions, 0 deletions
diff --git a/beta_accents/app/include/ical.inc.php b/beta_accents/app/include/ical.inc.php
new file mode 100644
index 0000000..0d858e3
--- /dev/null
+++ b/beta_accents/app/include/ical.inc.php
@@ -0,0 +1,68 @@
+<?php
+/*
+ * Fonction de génération d'iCal
+ */
+
+// Constantes d'erreur
+define("ERR_ICAL_NO_DATA", -1);
+define("ERR_ICAL_SQL_ERROR", -2);
+
+ function generationIcal($idP, &$iCal_name, &$iCal_content, &$errmsg)
+{
+ require_once('connect.inc.php');
+ $query = 'SELECT DISTINCT R.idR,R.objetR,P.courrielP,UNIX_TIMESTAMP(C.dateHeure),C.duree,R.lieuR,R.ordreJourR,L.idL'
+ . ' FROM AWOR_Liste L,AWOR_Reunion R,AWOR_Appartenir A,AWOR_Creneau C,AWOR_Personne P'
+ . " WHERE ((A.idP = $idP AND A.idL = L.idL) OR R.idP_Orga = $idP)"
+ . ' AND R.idL = L.idL AND C.idC = R.idC_Fixe AND P.idP = R.idP_Orga'
+ . ' AND C.dateHeure > NOW() ';
+ if ( ! $result = @mysql_query($query) )
+ {
+ // Cas d'erreur
+ $errmsg =mysql_generate_errmsg();
+ return ERR_ICAL_SQL_ERROR;
+ }
+ else
+ {
+ if (mysql_num_rows($result)<1)
+ {
+ return ERR_ICAL_NO_DATA;
+ }
+ else
+ {
+ $time = time();
+ $iCal_name = "iCal_${idP}_${time}.ics";
+ $iCal_content = "BEGIN:VCALENDAR\r\n" . "VERSION:2.0\r\n";
+ while ( list($idR, $objetR, $courrielP, $dateDeb, $duree, $lieuR, $ordreJourR, $idL) = mysql_fetch_array($result) )
+ {
+ // TODO : Il est probablement judicieux d'ajouter à l'UID un timestamp unix !!!!!
+ $iCal_content .= "BEGIN:VEVENT\r\n" . "UID:awor_${idP}.${idR}\r\n" . "SUMMARY:$objetR ($courrielP)\r\n";
+ $iCal_content .= 'DTSTART:' . date('Ymd\THis', $dateDeb) . "\r\n";
+ $iCal_content .= 'DTEND:' . date('Ymd\THis', $dateDeb+60*$duree) . "\r\n";
+ $iCal_content .= "LOCATION:$lieuR\r\n";
+ $iCal_content .= "DESCRIPTION:$ordreJourR\r\n";
+
+ $query = 'SELECT P.courrielP FROM AWOR_Appartenir A,AWOR_Personne P' . " WHERE A.idP=P.idP AND A.idL='$idL'";
+ if ( ! $result = mysql_query($query) )
+ {
+ // Cas d'erreur
+ $errmsg =mysql_generate_errmsg();
+ $ret=ERR_ICAL_SQL_ERROR;
+ break;
+ }
+ else
+ {
+ while ( list($mail_autres) = mysql_fetch_array($result) )
+ {
+ $iCal_content .= "ATTENDEE:mailto:$mail_autres\r\n";
+ }
+ }
+ // TODO : vérifier la pertinance de la variable utilisée
+ $iCal_content .= 'URL:http://' . $_SERVER['HTTP_HOST'] . "\r\n";
+ $iCal_content .= "END:VEVENT\r\n";
+ }
+ $iCal_content .= "END:VCALENDAR\r\n";
+ return 0;
+ }
+ }
+}
+?> \ No newline at end of file