From fe0053d3232c1c732e3da147739101b4313c2ba9 Mon Sep 17 00:00:00 2001
From: ARNO* <arno@rezo.net>
Date: Thu, 27 Nov 2003 11:34:26 +0000
Subject: [PATCH] Modification de l'export calendrier

---
 ecrire/lang/spip_fr.php3 |   5 +-
 ecrire/message.php3      |   2 +-
 ecrire/synchro.php3      |  29 ++-
 spip_cal.php3            | 388 ++++++++++++++++++++++++++++-----------
 4 files changed, 310 insertions(+), 114 deletions(-)

diff --git a/ecrire/lang/spip_fr.php3 b/ecrire/lang/spip_fr.php3
index 30808a008f..2fb0f9a765 100644
--- a/ecrire/lang/spip_fr.php3
+++ b/ecrire/lang/spip_fr.php3
@@ -171,8 +171,10 @@ $GLOBALS[$GLOBALS['idx_lang']] = array(
 
 
 // C
-'calendrier_synchro' => 'Si vous utilisez un logiciel d\'agenda compatible <b>iCal</b> (Apple iCal, Mozilla Calendar, Ximian Evolution, KOrganizer...), vous pouvez le synchroniser avec l\'actualit&eacute; de ce site.',
+'calendrier_synchro' => 'Si vous utilisez un logiciel d\'agenda compatible <b>iCal</b> (Apple iCal, Mozilla Calendar, Ximian Evolution, KOrganizer...), vous pouvez le synchroniser avec l\'actualit&eacute; Žditoriale de ce site.',
 'calendrier_synchro_lien' => 'R&eacute;cup&eacute;rer le fichier <i>iCal</i><br>(Ximian Evolution, KOrganizer...)',
+'calendrier_synchro_prive' => 'Le calendrier suivant, &agrave; usage strictement personnel, vous informe de l\'activit&eacute; &eacute;ditoriale priv&eacute;e de ce site (t&acirc;ches et rendez-vous personnels, articles et br&egrave;ves propos&eacute;s...).',
+'calendrier_synchro_public' => 'Le calendrier suivant vous permet de suivre l\'activit&eacute; publique de ce site (articles et br&egrave;ves publi&eacute;s).',
 'calendrier_synchro_sync' => 'Synchroniser le fichier <i>iCal</i><br> (Mozilla Calendar, Apple iCal...)',
 // D
 'date_avant_jc' => 'av. J.C.',
@@ -710,6 +712,7 @@ exige d\'avoir un acc&egrave;s FTP au site Web.',
 'info_mail_fournisseur' => 'vous@fournisseur.com',
 'info_maximum' => 'maximum&nbsp;:',
 'info_message' => 'Message du',
+'info_message_2' => 'MESSAGE',
 'info_message_efface' => 'MESSAGE EFFAC&Eacute;',
 'info_message_en_redaction' => 'Vos messages en cours de r&eacute;daction',
 'info_message_supprime' => 'MESSAGE SUPPRIM&Eacute;',
diff --git a/ecrire/message.php3 b/ecrire/message.php3
index fc9f321c86..c2d5bcc62b 100644
--- a/ecrire/message.php3
+++ b/ecrire/message.php3
@@ -148,7 +148,7 @@ while($row = spip_fetch_array($result_message)) {
 	debut_droite();
 
 	if ($type == 'normal') {
-		$le_type = "MESSAGE".aide ("messut");
+		$le_type = _T('info_message_2').aide ("messut");
 		$la_couleur = "#0A9C60";
 		$couleur_fond = "#BDF0DB";
 	}
diff --git a/ecrire/synchro.php3 b/ecrire/synchro.php3
index 0367303078..561ba88c05 100644
--- a/ecrire/synchro.php3
+++ b/ecrire/synchro.php3
@@ -61,18 +61,39 @@ debut_droite();
 
 		echo _T("calendrier_synchro");
 
+	
+		echo debut_cadre_enfonce();
+		echo _T("calendrier_synchro_prive");
+
 		echo "<div>&nbsp;</div>";
 		
 		echo "<div style='float: left; width: 200px;'>";
-		icone_horizontale (_T("calendrier_synchro_lien"), "$adresse_site/spip_cal.php3?id=$connect_id_auteur&cle=".afficher_low_sec($connect_id_auteur,'ical'), "calendrier-24.gif");
+			icone_horizontale (_T("calendrier_synchro_lien"), "$adresse_site/spip_cal.php3?id=$connect_id_auteur&cle=".afficher_low_sec($connect_id_auteur,'ical'), "calendrier-24.gif");
 		echo "</div>";
 	
 		echo "<div style='float: right; width: 200px;'>";
+			$webcal = ereg_replace("http.?://", "webcal://", $adresse_site);
+			icone_horizontale (_T("calendrier_synchro_sync"), "$webcal/spip_cal.php3?id=$connect_id_auteur&cle=".afficher_low_sec($connect_id_auteur,'ical'), "calendrier-24.gif");
+		echo "</div>";
+		echo fin_cadre_enfonce();
+
+
+
+		echo debut_cadre_enfonce();
+		echo _T("calendrier_synchro_public");
+
+		echo "<div>&nbsp;</div>";
 		
-		$webcal = ereg_replace("http.?://", "webcal://", $adresse_site);
-		
-		icone_horizontale (_T("calendrier_synchro_sync"), "$webcal/spip_cal.php3?id=$connect_id_auteur&cle=".afficher_low_sec($connect_id_auteur,'ical'), "calendrier-24.gif");
+		echo "<div style='float: left; width: 200px;'>";
+			icone_horizontale (_T("calendrier_synchro_lien"), "$adresse_site/spip_cal.php3?type=public", "calendrier-24.gif");
 		echo "</div>";
+	
+		echo "<div style='float: right; width: 200px;'>";
+			$webcal = ereg_replace("http.?://", "webcal://", $adresse_site);
+			icone_horizontale (_T("calendrier_synchro_sync"), "$webcal/spip_cal.php3?type=public", "calendrier-24.gif");
+		echo "</div>";
+		echo fin_cadre_enfonce();
+
 
 
 	echo fin_cadre_relief();
diff --git a/spip_cal.php3 b/spip_cal.php3
index bec7e4e9f4..0fca1b81c7 100644
--- a/spip_cal.php3
+++ b/spip_cal.php3
@@ -47,141 +47,313 @@ if (verifier_low_sec($id_auteur, $cle, 'ical')) {
 	if ($row = spip_fetch_array($result)) {
 		$id_utilisateur=$row['id_auteur'];
 		$nom_utilisateur=$row['nom'];
+		$statut_utilisateur=$row['statut'];
 		$nom_utilisateur = filtrer_ical(unicode2charset(charset2unicode($nom_utilisateur, $charset, 1), 'utf-8'));
 	}
 }
 
-if (!$id_utilisateur) {
-	die ("Interdit");
-}	
 
+//@header ("content-type:text/calendar");
 
-@header ("content-type:text/calendar");
 
-ligne ("BEGIN:VCALENDAR");
-ligne ("CALSCALE:GREGORIAN");
-ligne ("X-WR-CALNAME;VALUE=TEXT:$nom_site / $nom_utilisateur");
-ligne ("X-WR-RELCALID:cal$id_utilisateur @ $adresse_site");
-ligne ("VERSION:2.0");
+if ($type == "public") {
+	ligne ("BEGIN:VCALENDAR");
+	ligne ("CALSCALE:GREGORIAN");
+	ligne ("X-WR-CALNAME;VALUE=TEXT:$nom_site");
+	ligne ("X-WR-RELCALID:$adresse_site");
 
-
-	// rendez-vous
-	$result_messages=spip_query("SELECT messages.* FROM spip_messages AS messages, spip_auteurs_messages AS lien WHERE ((lien.id_auteur='$id_utilisateur' AND lien.id_message=messages.id_message) OR messages.type='affich') AND messages.rv='oui' AND messages.statut='publie' GROUP BY messages.id_message ORDER BY messages.date_heure");
-	while($row=spip_fetch_array($result_messages)){
-		$id_message=$row['id_message'];
-		$date_heure=$row["date_heure"];
-		$date_heure_fin=$row["date_fin"];
-		//$titre=typo($row["titre"]);
-		$titre = filtrer_ical($row["titre"]);
-		$texte = filtrer_ical($row["texte"]);
-		$type=$row["type"];
-
-		if ($type == "affich") {
-			$titre = "[$nom_site] $titre";
-		}
-		
-		ligne ("BEGIN:VEVENT");
-		if ($type == "normal") {
-			$result_auteurs=spip_query("SELECT auteurs.* FROM spip_auteurs AS auteurs, spip_auteurs_messages AS lien WHERE (lien.id_message='$id_message' AND lien.id_auteur=auteurs.id_auteur)");
-			while($row_auteur=spip_fetch_array($result_auteurs)){
-				$id_auteur=$row_auteur['id_auteur'];
-				$nom_auteur=$row_auteur['nom'];
-				$email = $row_auteur ['email'];
-				$nom_auteur = filtrer_ical($nom_auteur);
-
-				if ($id_auteur != $id_utilisateur) $titre = $titre." - ".$nom_auteur;
-				
-				if ($id_auteur == $id_utilisateur) ligne ("ORGANIZER:$nom_auteur <$email>");
-				else  ligne ("ATTENDEE:$nom_auteur <$email>");
-			}
-		}
-		ligne ("SUMMARY:".$titre);
-		ligne ("DESCRIPTION:$texte");
-		ligne ("UID:mess$id_message @ $adresse_site");
-		ligne ("DTSTAMP:".date ("Ymd\THis", mktime (heures($date_heure),minutes($date_heure),0,mois($date_heure),jour($date_heure),annee($date_heure))));
-		ligne ("DTSTART:".date ("Ymd\THis", mktime (heures($date_heure),minutes($date_heure),0,mois($date_heure),jour($date_heure),annee($date_heure))));
-		if ($date_heure_fin > $date_heure) ligne ("DTEND:".date ("Ymd\THis", mktime (heures($date_heure_fin),minutes($date_heure_fin),0,mois($date_heure_fin),jour($date_heure_fin),annee($date_heure_fin))));
-		ligne ("CATEGORIES:$type");
-		ligne("URL:$adresse_site/ecrire/message.php3?id_message=$id_message");
-		
-		ligne ("END:VEVENT");
-		
-	}
-
-	// todo
-	$result_messages=spip_query("SELECT messages.* FROM spip_messages AS messages, spip_auteurs_messages AS lien WHERE lien.id_auteur='$id_utilisateur' AND lien.id_message=messages.id_message AND messages.type='pb' AND messages.rv!='oui' AND messages.statut='publie' GROUP BY messages.id_message ORDER BY messages.date_heure");
-	while($row=spip_fetch_array($result_messages)){
-		$id_message=$row['id_message'];
-		$date_heure=$row["date_heure"];
-		$titre = filtrer_ical($row["titre"]);
-		$texte = filtrer_ical($row["texte"]);
-		$type=$row["type"];
-
-		if ($type == "affich") {
-			$titre = "[$nom_site] $titre";
-		}
-		
-		ligne ("BEGIN:VTODO");
-		ligne ("SUMMARY:".$titre);
-		ligne ("DESCRIPTION:$texte");
-		ligne ("UID:mess$id_message @ $adresse_site");
-		ligne ("DTSTAMP:".date ("Ymd\THis", mktime (heures($date_heure),minutes($date_heure),0,mois($date_heure),jour($date_heure),annee($date_heure))));
-		ligne ("DTSTART:".date ("Ymd\THis", mktime (heures($date_heure),minutes($date_heure),0,mois($date_heure),jour($date_heure),annee($date_heure))));
-		ligne ("CATEGORIES:$type");
-		ligne("URL:$adresse_site/ecrire/message.php3?id_message=$id_message");
-		ligne ("END:VTODO");
-		
-	}
-
-
-
-
-	// Articles et breves proposes
-	$result_articles = spip_query("SELECT id_article, titre, date FROM spip_articles WHERE statut = 'prop'");
+	// Articles et breves publies
+	$result_articles = spip_query("SELECT id_article, titre, date FROM spip_articles WHERE statut = 'publie'");
 	while($row=spip_fetch_array($result_articles)){
 		$id_article=$row['id_article'];
-		$titre = filtrer_ical(_T('info_article_propose').": ".$row['titre']);
+		$titre = filtrer_ical(_T('info_article_publie').": ".$row['titre']);
 		$date_heure = $row['date'];
-		ligne ("BEGIN:VTODO");
+		ligne ("BEGIN:VEVENT");
 		ligne ("SUMMARY:[$nom_site] $titre ");
 		ligne ("UID:article$id_article @ $adresse_site");
-		ligne ("DTSTAMP:".date ("Ymd\THis", mktime (heures($date_heure),minutes($date_heure),0,mois($date_heure),jour($date_heure),annee($date_heure))));
-		ligne ("DTSTART:".date ("Ymd\THis", mktime (heures($date_heure),minutes($date_heure),0,mois($date_heure),jour($date_heure),annee($date_heure))));
-		ligne ("CATEGORIES:article");
-		ligne("URL:$adresse_site/ecrire/articles.php3?id_article=$id_article");
-		ligne ("END:VTODO");
+				ligne ("DTSTAMP:".date ("Ymd\THis", mktime (heures($date_heure),minutes($date_heure),0,mois($date_heure),jour($date_heure),annee($date_heure))));
+				ligne ("DTSTART:".date ("Ymd\THis", mktime (heures($date_heure),minutes($date_heure),0,mois($date_heure),jour($date_heure),annee($date_heure))));
+				ligne ("DTEND:".date ("Ymd\THis", mktime (heures($date_heure),minutes($date_heure)+30,0,mois($date_heure),jour($date_heure),annee($date_heure))));
+		ligne ("CATEGORIES:".filtrer_ical(_T('titre_breve_publiee')));
+		ligne("URL:$adresse_site/spip_redirect.php3?id_article=$id_article");
+		ligne("STATUS:CONFIRMED");
+		ligne ("END:VEVENT");
 	}
-	$result_articles = spip_query("SELECT id_breve, titre, date_heure FROM spip_breves WHERE statut = 'prop'");
+	$result_articles = spip_query("SELECT id_breve, titre, date_heure FROM spip_breves WHERE statut = 'publie'");
 	while($row=spip_fetch_array($result_articles)){
 		$id_breve=$row['id_breve'];
-		$titre = filtrer_ical(_T('item_breve_proposee').": ".$row['titre']);
+		$titre = filtrer_ical(_T('titre_breve_publiee').": ".$row['titre']);
 		$date_heure = $row['date_heure'];
-		ligne ("BEGIN:VTODO");
+		ligne ("BEGIN:VEVENT");
 		ligne ("SUMMARY:[$nom_site] $titre");
 		ligne ("UID:breve$id_breve @ $adresse_site");
-		ligne ("DTSTAMP:".date ("Ymd\THis", mktime (heures($date_heure),minutes($date_heure),0,mois($date_heure),jour($date_heure),annee($date_heure))));
-		ligne ("DTSTART:".date ("Ymd\THis", mktime (heures($date_heure),minutes($date_heure),0,mois($date_heure),jour($date_heure),annee($date_heure))));
-		ligne ("CATEGORIES:breve");
-		ligne("URL:$adresse_site/ecrire/breves_voir.php3?id_breve=$id_breve");
-		ligne ("END:VTODO");
+				ligne ("DTSTAMP:".date ("Ymd\THis", mktime (heures($date_heure),minutes($date_heure),0,mois($date_heure),jour($date_heure),annee($date_heure))));
+				ligne ("DTSTART:".date ("Ymd\THis", mktime (heures($date_heure),minutes($date_heure),0,mois($date_heure),jour($date_heure),annee($date_heure))));
+				ligne ("DTEND:".date ("Ymd\THis", mktime (heures($date_heure),minutes($date_heure)+30,0,mois($date_heure),jour($date_heure),annee($date_heure))));
+		ligne ("CATEGORIES:".filtrer_ical(_T('titre_breve_publiee')));
+		ligne("URL:$adresse_site/spip_redirect.php3?id_breve=$id_breve");
+		ligne("STATUS:CONFIRMED");
+		ligne ("END:VEVENT");
 	}
+	ligne ("END:VCALENDAR");
+}
+
+
 
 
+if ($id_utilisateur) {
+	if (!$type) {
+		ligne ("BEGIN:VCALENDAR");
+		ligne ("CALSCALE:GREGORIAN");
+		ligne ("X-WR-CALNAME;VALUE=TEXT:$nom_site / $nom_utilisateur");
+		ligne ("X-WR-RELCALID:cal$id_utilisateur @ $adresse_site");
+	
+	
+		// rendez-vous
+		$result_messages=spip_query("SELECT messages.* FROM spip_messages AS messages, spip_auteurs_messages AS lien WHERE ((lien.id_auteur='$id_utilisateur' AND lien.id_message=messages.id_message) OR messages.type='affich') AND messages.rv='oui' AND messages.statut='publie' GROUP BY messages.id_message ORDER BY messages.date_heure");
+		while($row=spip_fetch_array($result_messages)){
+			$id_message=$row['id_message'];
+			$date_heure=$row["date_heure"];
+			$date_heure_fin=$row["date_fin"];
+			//$titre=typo($row["titre"]);
+			$titre = filtrer_ical($row["titre"]);
+			$texte = filtrer_ical($row["texte"]);
+			$type=$row["type"];
+	
+			if ($type == 'normal') {
+				$le_type = filtrer_ical(_T('info_message_2'));
+				$result_auteurs=spip_query("SELECT auteurs.* FROM spip_auteurs AS auteurs, spip_auteurs_messages AS lien WHERE (lien.id_message='$id_message' AND lien.id_auteur=auteurs.id_auteur)");
+				while($row_auteur=spip_fetch_array($result_auteurs)){
+					$id_auteur=$row_auteur['id_auteur'];
+					$nom_auteur=$row_auteur['nom'];
+					$email = $row_auteur ['email'];
+					$nom_auteur = filtrer_ical($nom_auteur);
+	
+					if ($id_auteur != $id_utilisateur) $titre = $titre." - ".$nom_auteur;
+					
+					if ($id_auteur == $id_utilisateur) ligne ("ORGANIZER:$nom_auteur <$email>");
+					else  ligne ("ATTENDEE:$nom_auteur <$email>");
+				}
+			}
+			else if ($type == 'pb') {
+				$le_type = filtrer_ical(_T('info_pense_bete'));
+			}
+			else if ($type == 'affich') {
+				$le_type = filtrer_ical(_T('info_annonce'));
+				$titre = "[$nom_site] $titre";
+			}
+	
+			ligne ("BEGIN:VEVENT");
+			ligne ("SUMMARY:".$titre);
+			ligne ("DESCRIPTION:$texte");
+			ligne ("UID:mess$id_message @ $adresse_site");
+			ligne ("DTSTAMP:".date ("Ymd\THis", mktime (heures($date_heure),minutes($date_heure),0,mois($date_heure),jour($date_heure),annee($date_heure))));
+			ligne ("DTSTART:".date ("Ymd\THis", mktime (heures($date_heure),minutes($date_heure),0,mois($date_heure),jour($date_heure),annee($date_heure))));
+			if ($date_heure_fin > $date_heure) ligne ("DTEND:".date ("Ymd\THis", mktime (heures($date_heure_fin),minutes($date_heure_fin),0,mois($date_heure_fin),jour($date_heure_fin),annee($date_heure_fin))));
+			ligne ("CATEGORIES:$le_type");
+			ligne("URL:$adresse_site/ecrire/message.php3?id_message=$id_message");
+			
+			ligne ("END:VEVENT");
+			
+		}
+	
+		// todo
+		$result_messages=spip_query("SELECT messages.* FROM spip_messages AS messages, spip_auteurs_messages AS lien WHERE lien.id_auteur='$id_utilisateur' AND lien.id_message=messages.id_message AND messages.type='pb' AND messages.rv!='oui' AND messages.statut='publie' GROUP BY messages.id_message ORDER BY messages.date_heure");
+		while($row=spip_fetch_array($result_messages)){
+			$id_message=$row['id_message'];
+			$date_heure=$row["date_heure"];
+			$titre = filtrer_ical($row["titre"]);
+			$texte = filtrer_ical($row["texte"]);
+			$type=$row["type"];
+	
+			if ($type == 'normal') {
+				$le_type = filtrer_ical(_T('info_message_2'));
+				$result_auteurs=spip_query("SELECT auteurs.* FROM spip_auteurs AS auteurs, spip_auteurs_messages AS lien WHERE (lien.id_message='$id_message' AND lien.id_auteur=auteurs.id_auteur)");
+				while($row_auteur=spip_fetch_array($result_auteurs)){
+					$id_auteur=$row_auteur['id_auteur'];
+					$nom_auteur=$row_auteur['nom'];
+					$email = $row_auteur ['email'];
+					$nom_auteur = filtrer_ical($nom_auteur);
+	
+					if ($id_auteur != $id_utilisateur) $titre = $titre." - ".$nom_auteur;
+					
+					if ($id_auteur == $id_utilisateur) ligne ("ORGANIZER:$nom_auteur <$email>");
+					else  ligne ("ATTENDEE:$nom_auteur <$email>");
+				}
+			}
+			else if ($type == 'pb') {
+				$le_type = filtrer_ical(_T('info_pense_bete'));
+			}
+			else if ($type == 'affich') {
+				$le_type = filtrer_ical(_T('info_annonce'));
+				$titre = "[$nom_site] $titre";
+			}
+			
+			ligne ("BEGIN:VTODO");
+			ligne ("SUMMARY:".$titre);
+			ligne ("DESCRIPTION:$texte");
+			ligne ("UID:mess$id_message @ $adresse_site");
+			ligne ("DTSTAMP:".date ("Ymd\THis", mktime (heures($date_heure),minutes($date_heure),0,mois($date_heure),jour($date_heure),annee($date_heure))));
+			ligne ("DTSTART:".date ("Ymd\THis", mktime (heures($date_heure),minutes($date_heure),0,mois($date_heure),jour($date_heure),annee($date_heure))));
+			ligne ("CATEGORIES:$le_type");
+			ligne("URL:$adresse_site/ecrire/message.php3?id_message=$id_message");
+			ligne ("END:VTODO");
+			
+		}
+	
+		// Articles et breves proposes
+		$result_articles = spip_query("SELECT id_article, titre, date FROM spip_articles WHERE statut = 'prop'");
+		while($row=spip_fetch_array($result_articles)){
+			$id_article=$row['id_article'];
+			$titre = filtrer_ical(_T('info_article_propose').": ".$row['titre']);
+			$date_heure = $row['date'];
+			$nb_articles ++;
+			ligne ("BEGIN:VEVENT");
+			ligne ("SUMMARY:[$nom_site] $titre ");
+			ligne ("UID:article$id_article @ $adresse_site");
+			ligne ("DTSTAMP:".date ("Ymd\THis", mktime (heures($date_heure),minutes($date_heure),0,mois($date_heure),jour($date_heure),annee($date_heure))));
+			ligne ("DTSTART;VALUE=DATE:".date ("Ymd", mktime (heures($date_heure),minutes($date_heure),0,mois($date_heure),jour($date_heure),annee($date_heure))));
+			ligne ("CATEGORIES:".filtrer_ical(_T('info_article_propose')));
+			ligne("URL:$adresse_site/ecrire/articles.php3?id_article=$id_article");
+			ligne ("END:VEVENT");
+		}
+		$result_articles = spip_query("SELECT id_breve, titre, date_heure FROM spip_breves WHERE statut = 'prop'");
+		while($row=spip_fetch_array($result_articles)){
+			$id_breve=$row['id_breve'];
+			$titre = filtrer_ical(_T('item_breve_proposee').": ".$row['titre']);
+			$date_heure = $row['date_heure'];
+			$nb_breves++;
+			ligne ("BEGIN:VEVENT");
+			ligne ("SUMMARY:[$nom_site] $titre ");
+			ligne ("UID:breve$id_breve @ $adresse_site");
+			ligne ("DTSTAMP:".date ("Ymd\THis", mktime (heures($date_heure),minutes($date_heure),0,mois($date_heure),jour($date_heure),annee($date_heure))));
+			ligne ("DTSTART;VALUE=DATE:".date ("Ymd", mktime (heures($date_heure),minutes($date_heure),0,mois($date_heure),jour($date_heure),annee($date_heure))));
+			ligne ("CATEGORIES:".filtrer_ical(_T('item_breve_proposee')));
+			ligne("URL:$adresse_site/ecrire/breves_voir.php3?id_breve=$id_breve");
+			ligne ("END:VEVENT");
+
+		}
+
+		if ($nb_articles + $nb_breves > 0) {
+			if ($nb_articles > 0) $titre_prop[] = filtrer_ical(_T('info_articles_proposes')).": ".$nb_articles;
+			if ($nb_breves > 0) $titre_prop[] = filtrer_ical(_T('info_breves_valider')).": ".$nb_breves;
+			$titre = join($titre_prop," / ");
+			ligne ("BEGIN:VTODO");
+			ligne ("SUMMARY:[$nom_site] $titre");
+			ligne ("UID:prop @ $adresse_site");
+			
+			$today=getdate(time());
+			$jour = $today["mday"];
+			$mois=$today["mon"];
+			$annee=$today["year"];
+			ligne ("DTSTAMP:".date ("Ymd\THis", mktime (12,0,0,$mois,$jour,$annee)));
+			ligne ("DTSTART:".date ("Ymd\THis", mktime (12,0,0,$mois,$jour,$annee)));
+			ligne ("CATEGORIES:".filtrer_ical(_T('icone_a_suivre')));
+			ligne("URL:$adresse_site/ecrire/");
+			ligne ("END:VTODO");
+		}
+
 
+		// Nouveaux messages
+		
+		$result_messages = spip_query("SELECT * FROM spip_messages AS messages, spip_auteurs_messages AS lien WHERE lien.id_auteur=$id_utilisateur AND vu='non' AND statut='publie' AND type='normal' AND lien.id_message=messages.id_message");
+		while($row=spip_fetch_array($result_messages)){
+			$id_message=$row['id_message'];
+			$date_heure=$row["date_heure"];
+			$titre = filtrer_ical($row["titre"]);
+			$texte = filtrer_ical($row["texte"]);
+			$type=$row["type"];
+	
+			if ($type == 'normal') {
+				$le_type = filtrer_ical(_T('info_message_2'));
+				$result_auteurs=spip_query("SELECT auteurs.* FROM spip_auteurs AS auteurs, spip_auteurs_messages AS lien WHERE (lien.id_message='$id_message' AND lien.id_auteur=auteurs.id_auteur)");
+				while($row_auteur=spip_fetch_array($result_auteurs)){
+					$id_auteur=$row_auteur['id_auteur'];
+					$nom_auteur=$row_auteur['nom'];
+					$email = $row_auteur ['email'];
+					$nom_auteur = filtrer_ical($nom_auteur);
+	
+					if ($id_auteur != $id_utilisateur) $titre = $nom_auteur." - ".$titre;
+					
+					if ($id_auteur == $id_utilisateur) ligne ("ORGANIZER:$nom_auteur <$email>");
+					else  ligne ("ATTENDEE:$nom_auteur <$email>");
+				}
+			}
+			else if ($type == 'pb') {
+				$le_type = filtrer_ical(_T('info_pense_bete'));
+			}
+			else if ($type == 'affich') {
+				$le_type = filtrer_ical(_T('info_annonce'));
+				$titre = "[$nom_site] $titre";
+			}
+			
+			ligne ("BEGIN:VTODO");
+			ligne ("SUMMARY:".$titre);
+			ligne ("DESCRIPTION:$texte");
+			ligne ("UID:nouv_mess$id_message @ $adresse_site");
+			ligne ("DTSTAMP:".date ("Ymd\THis", mktime (heures($date_heure),minutes($date_heure),0,mois($date_heure),jour($date_heure),annee($date_heure))));
+			ligne ("DTSTART:".date ("Ymd\THis", mktime (heures($date_heure),minutes($date_heure),0,mois($date_heure),jour($date_heure),annee($date_heure))));
+			ligne ("CATEGORIES:$le_type");
+			ligne("URL:$adresse_site/ecrire/message.php3?id_message=$id_message");
+			ligne ("END:VTODO");
+			
+		}
+		
+		// Messages de forum a valider
+		if ($statut_utilisateur == "0minirezo") {
+
+			$query_forum = "SELECT * FROM spip_forum WHERE statut = 'prop'";
+			$result_forum = spip_query($query_forum);
+	
+			while($row=spip_fetch_array($result_forum)){
+				$nb_forum ++;
+			
+				$id_forum=$row['id_forum'];
+				$date_heure = $row['date_heure'];
+				$titre = filtrer_ical($row['titre']);
+				$texte = filtrer_ical($row['texte']);
+				$auteur = filtrer_ical($row['auteur']);
+				$email_auteur = filtrer_ical($row['email_auteur']);
+				if ($email_auteur) $email_auteur = "<$email_auteur>";
+				
+				ligne ("BEGIN:VEVENT");
+				ligne ("SUMMARY:[$nom_site / ".filtrer_ical(_T('icone_forum_suivi'))."] $titre ");
+				ligne ("DESCRIPTION:$texte\r$auteur $email_auteur");
+				ligne ("UID:forum$id_forum @ $adresse_site");
+				ligne ("DTSTAMP:".date ("Ymd\THis", mktime (heures($date_heure),minutes($date_heure),0,mois($date_heure),jour($date_heure),annee($date_heure))));
+				ligne ("DTSTART:".date ("Ymd\THis", mktime (heures($date_heure),minutes($date_heure),0,mois($date_heure),jour($date_heure),annee($date_heure))));
+				ligne ("DTEND:".date ("Ymd\THis", mktime (heures($date_heure),minutes($date_heure)+30,0,mois($date_heure),jour($date_heure),annee($date_heure))));
+				ligne ("CATEGORIES:".filtrer_ical(_T('icone_forum_suivi')));
+				ligne("URL:$adresse_site/ecrire/controle_forum.php3");
+				ligne ("END:VEVENT");
+	
+	
+				
+			}
 
-/*ligne ("BEGIN:VEVENT");
-	DTSTAMP:20031121T064748Z
-	SUMMARY:L.A. Clippers @ Kings Preseason \nW 101-82\n 
-	LOCATION:
-	UID:4FF899AA-1BE0-11D8-8939-000A959A2EA8-RID
-	DTSTART;TZID=US/Pacific:20031007T190000
-	DURATION:PT3H
-ligne ("END:VEVENT");
-*/
+			if ($nb_forum > 0) {
+				ligne ("BEGIN:VTODO");
+				ligne ("SUMMARY:[$nom_site] "._T('icone_forum_suivi').": $nb_forum");
+				ligne ("UID:forum @ $adresse_site");
+				
+				$today=getdate(time());
+				$jour = $today["mday"];
+				$mois=$today["mon"];
+				$annee=$today["year"];
+				ligne ("DTSTAMP:".date ("Ymd\THis", mktime (12,0,0,$mois,$jour,$annee)));
+				ligne ("DTSTART:".date ("Ymd\THis", mktime (12,0,0,$mois,$jour,$annee)));
+				ligne ("CATEGORIES:".filtrer_ical(_T('icone_forum_suivi')));
+				ligne("URL:$adresse_site/ecrire/controle_forum.php3");
+				ligne ("END:VTODO");
+			}
+		}
 
 
-ligne ("END:VCALENDAR");
 
+	
+		ligne ("END:VCALENDAR");
+	}
+}
 
 
 ?>
\ No newline at end of file
-- 
GitLab