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;
17 * Envoyer les notifications consecutives a l'envoi d'un message
18 * (ie passage en statut=publie)
21 * @param int $id_message
22 * @param array $options
24 function notifications_instituermessage_dist($quoi, $id_message, $options=array()){
26 // ne devrait jamais se produire
27 if ($options['statut'] == $options['statut_ancien']) {
28 spip_log("statut inchange",'notifications');
32 if ($options['statut']=='publie'){
33 include_spip('inc/messages');
34 $type = sql_getfetsel('type','spip_messages','id_message='.intval($id_message));
35 $vue = "notifications/message_{$type}_publie";
36 if (trouver_fond($vue)){
37 $envoyer_mail = charger_fonction('envoyer_mail','inc'); // pour nettoyer_titre_email
38 $texte = recuperer_fond($vue,array('id_message'=>$id_message));
40 // recuperer tous les emails des auteurs qui ont recu le message dans leur boite
41 // si c'est une annonce generale, on envoie a tout le monde
42 include_spip('inc/messages');
45 "statut!='5poubelle'",
46 sql_in('statut',messagerie_statuts_destinataires_possibles())
48 // pour une annonce : tous ceux qui recoivent des messages
49 if ($type!=='affich'){
50 $ids = sql_allfetsel('id_auteur','spip_auteurs_liens',"objet='message' AND id_objet=".intval($id_message));
51 $ids = array_map('reset',$ids);
52 $where[] = sql_in('id_auteur',$ids);
54 $emails = sql_allfetsel('email',"spip_auteurs",$where);
55 $emails = array_map('reset',$emails);
57 include_spip('inc/notifications');
58 notifications_envoyer_mails($emails,$texte);