3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
6 * Copyright (c) 2001-2014 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
9 * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
10 * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
11 \***************************************************************************/
13 if (!defined("_ECRIRE_INC_VERSION")) return;
16 * Construitre l'email personalise de notification d'un forum
19 * @param string $email
20 * @param array $contexte
23 function inc_email_notification_forum_dist ($t, $email, $contexte=array()) {
24 static $contextes_store = array();
26 if(!isset($contextes_store[$t['id_forum']])){
28 $id_forum = $t['id_forum'];
30 if ($t['statut'] == 'prive') # forum prive
33 $url = generer_url_entite($t['id_objet'], $t['objet'], '', 'forum'.$id_forum, false);
35 else if ($t['statut'] == 'privrac') # forum general
37 $url = generer_url_ecrire('forum').'#forum'.$id_forum;
39 else if ($t['statut'] == 'privadm') # forum des admins
41 $url = generer_url_ecrire('forum','quoi=admin').'#forum'.$id_forum;
43 else if ($t['statut'] == 'publie') # forum publie
45 $url = generer_url_entite($id_forum, 'forum');
47 else # forum modere, spam, poubelle direct ....
49 $url = generer_url_ecrire('controler_forum', "debut_id_forum=".$id_forum);
53 spip_log("forum $id_forum sans referent",'notifications');
57 include_spip('inc/filtres');
58 $t['titre_source'] = generer_info_entite($t['id_objet'], $t['objet'], 'titre');
63 // detecter les url des liens du forum
64 // pour la moderation (permet de reperer les SPAMS avec des liens caches)
65 // il faut appliquer le traitement de raccourci car sinon on rate des liens sous forme [->..] utilises par les spammeurs !
66 include_spip("public/interfaces");
67 $table_objet = "forum";
70 foreach ($t as $champ=>$v){
71 $champ = strtoupper($champ);
72 $traitement = (isset($GLOBALS['table_des_traitements'][$champ])?
$GLOBALS['table_des_traitements'][$champ]:null);
73 if (is_array($traitement)
74 AND (isset($traitement[$table_objet]) OR isset($traitement[0]))){
75 $traitement = $traitement[isset($traitement[$table_objet]) ?
$table_objet : 0];
76 $traitement = str_replace('%s', "'".texte_script($v)."'", $traitement);
77 eval("\$v = $traitement;");
80 $links = $links +
extraire_balises($v,'a');
82 $links = extraire_attribut($links,'href');
83 $links = implode("\n",$links);
86 $contextes_store[$t['id_forum']] = $t;
89 $fond = "notifications/forum_poste";
90 if (isset($contexte['fond'])){
91 $fond = $contexte['fond'];
92 unset($contexte['fond']);
94 $t = array_merge($contextes_store[$t['id_forum']],$contexte);
95 // Rechercher eventuellement la langue du destinataire
96 if (NULL !== ($l = sql_getfetsel('lang', 'spip_auteurs', "email=" . sql_quote($email))))
99 $parauteur = (strlen($t['auteur']) <= 2) ?
'' :
100 (" " ._T('forum_par_auteur', array(
101 'auteur' => $t['auteur'])
103 ($t['email_auteur'] ?
' <' . $t['email_auteur'] . '>' : ''));
105 $titre = textebrut(typo($t['titre_source']));
107 $forum_poste_par = _T(
108 $t['objet']=='article'?
'forum:forum_poste_par':'forum:forum_poste_par_generique',
109 array('parauteur' => $parauteur, 'titre' => $titre, 'objet'=>$t['objet'])
113 $forum_poste_par = _T('forum:forum_poste_par_court',array('parauteur' => $parauteur));
115 $t['par_auteur'] = $forum_poste_par;
117 $envoyer_mail = charger_fonction('envoyer_mail','inc'); // pour nettoyer_titre_email
118 $corps = recuperer_fond($fond,$t);