[SPIP][PLUGINS] v3.0-->v3.2
[lhc/web/www.git] / www / ecrire / notifications / instituerarticle.php
1 <?php
2 /*
3 * Plugin Notifications
4 * (c) 2009 SPIP
5 * Distribue sous licence GPL
6 *
7 */
8
9
10 if (!defined('_ECRIRE_INC_VERSION')) {
11 return;
12 }
13
14 // Fonction appelee par divers pipelines
15 // http://code.spip.net/@notifications_instituerarticle_dist
16 function notifications_instituerarticle_dist($quoi, $id_article, $options) {
17
18 // ne devrait jamais se produire
19 if ($options['statut'] == $options['statut_ancien']) {
20 spip_log('statut inchange', 'notifications');
21
22 return;
23 }
24
25 include_spip('inc/texte');
26
27 $modele = '';
28 if ($options['statut'] == 'publie') {
29 if ($GLOBALS['meta']['post_dates'] == 'non'
30 and strtotime($options['date']) > time()
31 ) {
32 $modele = 'notifications/article_valide';
33 } else {
34 $modele = 'notifications/article_publie';
35 }
36 }
37
38 if ($options['statut'] == 'prop' and $options['statut_ancien'] != 'publie') {
39 $modele = 'notifications/article_propose';
40 }
41
42 if ($modele) {
43 $destinataires = array();
44 if ($GLOBALS['meta']['suivi_edito'] == 'oui') {
45 $destinataires = explode(',', $GLOBALS['meta']['adresse_suivi']);
46 }
47
48
49 $destinataires = pipeline(
50 'notifications_destinataires',
51 array(
52 'args' => array('quoi' => $quoi, 'id' => $id_article, 'options' => $options),
53 'data' => $destinataires
54 )
55 );
56
57 $texte = email_notification_article($id_article, $modele);
58 notifications_envoyer_mails($destinataires, $texte);
59 }
60 }