1 | <?php |
---|
2 | |
---|
3 | /* |
---|
4 | * Abomailmans |
---|
5 | * MaZiaR - NetAktiv |
---|
6 | * tech@netaktiv.com |
---|
7 | * Printemps 2007 - 2012 |
---|
8 | * Inspire de Spip-Listes |
---|
9 | * $Id: abomailmans.php 58711 2012-02-20 10:31:13Z kent1@arscenic.info $ |
---|
10 | */ |
---|
11 | |
---|
12 | if (!defined("_ECRIRE_INC_VERSION")) return; |
---|
13 | |
---|
14 | // a utiliser dans le form de son choix ... |
---|
15 | function abomailman_traiter_abonnement($id_liste,$abonnement){ |
---|
16 | $liste_data = sql_fetsel("*","spip_abomailmans","id_abomailman = $id_liste"); |
---|
17 | $sujet=null; |
---|
18 | $dowhat=null; |
---|
19 | $titre=$liste_data['titre']; |
---|
20 | //Si on a les 2 emails |
---|
21 | if($liste_data['email_subscribe'] AND $liste_data['email_unsubscribe']){ |
---|
22 | spip_log("Liste defini par mails","abomailmans"); |
---|
23 | $liste_email = !empty($abonnement)?$liste_data['email_subscribe']:$liste_data['email_unsubscribe']; |
---|
24 | }else{ |
---|
25 | //sinon comme avant |
---|
26 | // 1er cas : c'est une liste MAILMAN ? join et leave etrange !!! |
---|
27 | //ne serait-ce pas plutot subscribe et unsubscribe ? |
---|
28 | if($liste_data['email_sympa'] == '') { |
---|
29 | spip_log("Liste -join ou -leave","abomailmans"); |
---|
30 | $liste_email = explode ("@", $liste_data['email']); |
---|
31 | // abonnement ou desabonement : on rajoute -join ou -leave dans l'email de la liste |
---|
32 | $dowhat = !empty($abonnement)?"-join@":"-leave@"; |
---|
33 | $liste_email = $liste_email[0]."$dowhat".$liste_email[1]; |
---|
34 | } |
---|
35 | // 2eme cas : c'est une liste SYMPA (presence de deux @ à suivre) |
---|
36 | else { |
---|
37 | spip_log("Liste sympa","abomailmans"); |
---|
38 | $proprio_email = $liste_data['email_sympa']; |
---|
39 | $sujet = empty($abonnement)? 'UNSUBSCRIBE ' : 'SUBSCRIBE '; |
---|
40 | $sujet .= $liste_data['email'].' '; |
---|
41 | $sujet .= empty($desabonnement) ? $nom : ''; |
---|
42 | $liste_email = $liste_data['titre']; |
---|
43 | } |
---|
44 | } |
---|
45 | $sujet=isset($sujet)?$sujet:$liste_email; |
---|
46 | $quoifait=!empty($abonnement)?_T("abomailmans:veut_s_abonner"):_T("abomailmans:veut_se_desabonner"); |
---|
47 | $body="$quoifait"."\n ".$titre."(".$liste_data['email'].") \n "._T("abomailmans:envoi_vers")." $liste_email"; |
---|
48 | |
---|
49 | |
---|
50 | return array($titre,$proprio_email,$liste_email, $sujet, $body,$headers); |
---|
51 | } |
---|
52 | |
---|
53 | |
---|
54 | //* Envoi de mail via facteur |
---|
55 | function abomailman_mail($nom, $email, $to_email,$liste_email, $sujet="", $body="", $html="", $headers="") { |
---|
56 | // si $to_mail est plein, c'est Sympa, s'il est vide c'est Mailman et il faut alors utiliser $liste_email |
---|
57 | if (!$to_email) |
---|
58 | $to_email = $liste_email; |
---|
59 | $envoyer_mail = charger_fonction('envoyer_mail','inc/'); |
---|
60 | if($envoyer_mail($to_email, $sujet, $body, $email, $headers)) |
---|
61 | $retour=true; |
---|
62 | else |
---|
63 | $retour=false; |
---|
64 | |
---|
65 | spip_log("abomailman_mail nom $nom, email $email, to_email $to_email, liste_email $liste_email, sujet $sujet, body $body, html $html, headers $headers, retour envoyer_mail : $retour","abomailmans"); |
---|
66 | return $retour ; |
---|
67 | } |
---|
68 | |
---|
69 | |
---|
70 | ?> |
---|