diff --git a/htdocs/adherent.class.php b/htdocs/adherent.class.php index 416b9a9ea2e..7424da3db11 100644 --- a/htdocs/adherent.class.php +++ b/htdocs/adherent.class.php @@ -578,48 +578,153 @@ class Adherent } /* - * Ajoute le user aux mailing-list + * Ajoute le user aux differents abonneents automatiques + * (mailing-list, spip, glasnost etc etc ..) * */ - Function add_to_list($email,$list) + Function add_to_abo() { - + $err=0; + // mailman + if (defined("MAIN_USE_MAILMAN") && MAIN_USE_MAILMAN == 1) + { + if(!$this->add_to_mailman()){ + $err+=1; + } + } + if ($err>0){ + // error + return 0; + }else{ + return 1; + } + } + + /* + * supprime le user des differents abonnements automatiques + * (mailing-list, spip, glasnost etc etc ..) + * + */ + Function del_to_abo() + { + $err=0; + // mailman + if (defined("MAIN_USE_MAILMAN") && MAIN_USE_MAILMAN == 1) + { + if(!$this->del_to_mailman()){ + $err+=1; + } + } + if ($err>0){ + // error + return 0; + }else{ + return 1; + } } /* * * */ - Function add_to_mailman($email,$list,$mailmandir) + Function add_to_mailman() { - if (!file_exists($mailmandir)) { - mkdir($mailmandir, 0777); - } - if (!file_exists("$mailmandir/$list")) { - mkdir("$mailmandir/$list", 0777); - } - if (!file_exists("$mailmandir/$list/subscribe")) { - mkdir("$mailmandir/$list/subscribe", 0777); - } - if (!file_exists("$mailmandir/$list/subscribe/$email")) { - touch("$mailmandir/$list/subscribe/$email"); - } + if (defined("MAIN_MAILMAN_URL") && MAIN_MAILMAN_URL != '' && defined("MAIN_MAILMAN_LISTS") && MAIN_MAILMAN_LISTS != '') + { + $lists=explode(',',MAIN_MAILMAN_LISTS); + foreach ($lists as $list) + { + // on remplace dans l'url le nom de la liste ainsi + // que l'email et le mot de passe + $patterns = array ( + '/%LISTE%/', + '/%EMAIL%/', + '/%PASS%/' + ); + $replace = array ( + $list, + $this->email, + $this->pass + ); + $curl_url = preg_replace ($patterns, $replace, MAIN_MAILMAN_URL); + + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL,"$curl_url"); + //curl_setopt($ch, CURLOPT_URL,"http://www.j1b.org/"); + curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); + curl_setopt($ch, CURLOPT_FAILONERROR, 1); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); + curl_setopt($ch, CURLOPT_TIMEOUT, 5); + //curl_setopt($ch, CURLOPT_POST, 0); + //curl_setopt($ch, CURLOPT_POSTFIELDS, "a=3&b=5"); + //--- Start buffering + //ob_start(); + $result=curl_exec ($ch); + logfile($result); + //--- End buffering and clean output + //ob_end_clean(); + if (curl_error($ch) > 0) + { + // error + return 0; + } + curl_close ($ch); + + } + return 1; + }else{ + return 0; + } } - Function del_to_mailman($email,$list,$mailmandir) + Function del_to_mailman() { - if (!file_exists($mailmandir)) { - mkdir($mailmandir, 0777); - } - if (!file_exists("$mailmandir/$list")) { - mkdir("$mailmandir/$list", 0777); - } - if (!file_exists("$mailmandir/$list/unsubscribe")) { - mkdir("$mailmandir/$list/unsubscribe", 0777); - } - if (!file_exists("$mailmandir/$list/unsubscribe/$email")) { - touch("$mailmandir/$list/unsubscribe/$email"); - } + if (defined("MAIN_MAILMAN_UNSUB_URL") && MAIN_MAILMAN_UNSUB_URL != '' && defined("MAIN_MAILMAN_LISTS") && MAIN_MAILMAN_LISTS != '') + { + $lists=explode(',',MAIN_MAILMAN_LISTS); + foreach ($lists as $list) + { + // on remplace dans l'url le nom de la liste ainsi + // que l'email et le mot de passe + $patterns = array ( + '/%LISTE%/', + '/%EMAIL%/', + '/%PASS%/' + ); + $replace = array ( + $list, + $this->email, + $this->pass + ); + $curl_url = preg_replace ($patterns, $replace, MAIN_MAILMAN_UNSUB_URL); + + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL,"$curl_url"); + //curl_setopt($ch, CURLOPT_URL,"http://www.j1b.org/"); + curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); + curl_setopt($ch, CURLOPT_FAILONERROR, 1); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); + curl_setopt($ch, CURLOPT_TIMEOUT, 5); + //curl_setopt($ch, CURLOPT_POST, 0); + //curl_setopt($ch, CURLOPT_POSTFIELDS, "a=3&b=5"); + //--- Start buffering + //ob_start(); + $result=curl_exec ($ch); + logfile($result); + //--- End buffering and clean output + //ob_end_clean(); + if (curl_error($ch) > 0) + { + // error + return 0; + } + curl_close ($ch); + + } + return 1; + }else{ + return 0; + } } } ?> diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index a76ba60e586..c2dbe77dac6 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -30,6 +30,7 @@ require($GLOBALS["DOCUMENT_ROOT"]."/paiement.class.php"); $db = new Db(); $adho = new AdherentOptions($db); +$errmsg=''; if ($HTTP_POST_VARS["action"] == 'cotisation') { @@ -104,6 +105,14 @@ if ($HTTP_POST_VARS["action"] == 'confirm_valid' && $HTTP_POST_VARS["confirm"] = { $adh->send_an_email($adh->email,$conf->adherent->email_valid,$conf->adherent->email_valid_subject); } + // rajoute l'utilisateur dans les divers abonnements .. + if (!$adh->add_to_abo()) + { + // error + $errmsg="echec du rajout de l'utilisateur aux mailing-lists"; + } + + /* if ($conf->adherent->use_mailman == 1) { foreach ($conf->adherent->mailman_lists as $key) @@ -111,7 +120,7 @@ if ($HTTP_POST_VARS["action"] == 'confirm_valid' && $HTTP_POST_VARS["confirm"] = $adh->add_to_mailman($adh->email,$key,$conf->adherent->mailman_dir); } } - + */ } if ($HTTP_POST_VARS["action"] == 'confirm_resign' && $HTTP_POST_VARS["confirm"] == yes) @@ -122,6 +131,14 @@ if ($HTTP_POST_VARS["action"] == 'confirm_resign' && $HTTP_POST_VARS["confirm"] $adh->send_an_email($adh->email,$conf->adherent->email_resil,$conf->adherent->email_resil_subject); + // supprime l'utilisateur des divers abonnements .. + if (!$adh->del_to_abo()) + { + // error + $errmsg="echec du rajout de l'utilisateur aux mailing-lists"; + } + + /* if ($conf->adherent->use_mailman == 1) { foreach ($conf->adherent->mailman_lists as $key) @@ -129,6 +146,7 @@ if ($HTTP_POST_VARS["action"] == 'confirm_resign' && $HTTP_POST_VARS["confirm"] $adh->del_to_mailman($adh->email,$key,$conf->adherent->mailman_dir); } } + */ } @@ -139,6 +157,14 @@ llxHeader(); /* Création d'une fiche */ /* */ /* ************************************************************************** */ +if ($errmsg != ''){ + print ''; + + print ''; + print "\n"; + // print "$errmsg\n"; + print '
Erreur dans l\'execution du formulaire
$errmsg
'; +} // fetch optionals attributes and labels $adho->fetch_optionals(); diff --git a/htdocs/conf/conf.class.php3.sample b/htdocs/conf/conf.class.php3.sample index eb9eff3465b..626c2998f35 100644 --- a/htdocs/conf/conf.class.php3.sample +++ b/htdocs/conf/conf.class.php3.sample @@ -192,9 +192,6 @@ class ServiceConf { class AdherentConf { Function AdherentConf() { $this->enabled = 0; - $this->use_mailman = 1; - $this->mailman_dir = "/home/httpd/adherents.j1b.org/htdocs/adherents/ml/mailman"; - $this->mailman_lists = array('lists1','list2'); $this->email_new = "Merci de votre inscription. Votre adhesion devrait etre rapidement validee.\nVoici le rappel des coordonnees que vous avez rentrees (toute information erronee entrainera la non validation de votre inscription) :\n\n%INFO%\n\nVous pouvez a tout moment, grace a votre login et mot de passe, modifier vos coordonnees a l'adresse suivante :\n%SERVEUR%public/adherents/\n\n"; $this->email_new_subject = 'Vos coordonnees sur %SERVEUR%'; $this->email_edit = "Voici le rappel des coordonnees que vous avez modifiees (toute information erronee entrainera la non validation de votre inscription) :\n\n%INFO%\n\nVous pouvez a tout moment, grace a votre login et mot de passe, modifier vos coordonnees a l'adresse suivante :\n%SERVEUR%public/adherents/\n\n"; diff --git a/htdocs/lib/functions.inc.php3 b/htdocs/lib/functions.inc.php3 index 70ea54eea65..7a42aa7a35a 100644 --- a/htdocs/lib/functions.inc.php3 +++ b/htdocs/lib/functions.inc.php3 @@ -1,5 +1,6 @@ + * Copyright (C) 2003 Jean-Louis Bergamo * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -637,4 +638,37 @@ function tab_count($basename,$bc1,$bc2,$ftc) { $db->close(); } + +/* + * logfile : permet de logguer dans un fichier + * cette fonction ne fonctionenra que si et seulement si le fichier de + * la constante globale MAIN_DEBUG existe et vaut 1 + */ +function logfile($str,$log="/var/log/dolibarr/dolibarr.log") +{ + if (defined("MAIN_DEBUG") && MAIN_DEBUG ==1) + { + if (!file_exists($log)) + { + if (!$file=fopen($log,"w")) + { + return 0; + } + } + else + { + if (!$file=fopen($log,"a+")) + { + return 0; + } + } + $logentry=date("[d/M/Y:H:i:s] ").$str."\n"; + if(!fwrite($file,$logentry)) { + fclose($file); + return 0; + } + fclose($file); + return 1; + } +} ?> diff --git a/htdocs/main.inc.php3 b/htdocs/main.inc.php3 index 1f85d375ce4..7a0027ff415 100644 --- a/htdocs/main.inc.php3 +++ b/htdocs/main.inc.php3 @@ -112,18 +112,7 @@ if (defined("MAIN_MAIL_NEW_SUBJECT")) { $conf->adherent->email_new_subject=MAIN_MAIL_NEW_SUBJECT; } -if (defined("MAIN_MAILMAN_DIR")) -{ - $conf->adherent->mailman_dir=MAIN_MAILMAN_DIR; -} -if (defined("MAIN_MAILMAN_LISTS")) -{ - $conf->adherent->mailman_lists=explode(',',MAIN_MAILMAN_DIR); -} -if (defined("MAIN_USE_MAILMAN")) -{ - $conf->adherent->use_mailman=MAIN_USE_MAILMAN; -} + /* */ if(!isset($application_lang)) diff --git a/mysql/data/data.sql b/mysql/data/data.sql index 44b97f24c02..a422b424ae6 100644 --- a/mysql/data/data.sql +++ b/mysql/data/data.sql @@ -52,8 +52,10 @@ INSERT INTO llx_const (name, value, type, note) VALUES ('MAIN_MAIL_NEW_SUBJECT', INSERT INTO llx_const (name, value, type, note) VALUES ('MAIN_MAIL_EDIT_SUBJECT','Votre fiche a ete editee sur %SERVEUR%','chaine','Sujet du mail d\'edition'); INSERT INTO llx_const (name, value, type, note) VALUES ('MAIN_USE_MAILMAN','1','yesno','Utilisation de Mailman'); -INSERT INTO llx_const (name, value, type, note) VALUES ('MAIN_MAILMAN_LIST','lists1,lists2','chaine','Les listes sur lesquelles inscrire les adherents'); -INSERT INTO llx_const (name, value, type, note) VALUES ('MAIN_MAILMAN_DIR','/home/httpd/adherents.j1b.org/htdocs/adherents/ml/mailman','chaine','Repertoire dans lequel les nouveaux adherents aux listes sont ecris'); +INSERT INTO llx_const (name, value, type, note) VALUES ('MAIN_MAILMAN_UNSUB_URL','http://lists.ipsyn.net/cgi-bin/mailman/handle_opts/%LISTE%/%EMAIL%?upw=%PASS%&unsub=Unsubscribe','chaine','Url de desinscription aux listes mailman'); +INSERT INTO llx_const (name, value, type, note) VALUES ('MAIN_MAILMAN_URL','http://lists.ipsyn.net/cgi-bin/mailman/subscribe/%LISTE%/?email=%EMAIL%&pw=%PASS%&pw-conf=%PASS%','chaine','url pour les inscriptions mailman'); +INSERT INTO llx_const (name, value, type, note) VALUES ('MAIN_MAILMAN_LISTS','test-test,test-test2','chaine','Listes auxquelles inscrire les nouveaux adherents'); +INSERT INTO llx_const (name, value, type, note) VALUES ('MAIN_DEBUG','1','yesno','Debug ..'); -- -- Constantes diff --git a/scripts/adherents/mailman/adh2list.pl b/scripts/adherents/mailman/adh2list.pl index e744a8b81b0..0a7637fb30e 100755 --- a/scripts/adherents/mailman/adh2list.pl +++ b/scripts/adherents/mailman/adh2list.pl @@ -16,6 +16,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# ce script prend l'intergralite des adherents valide et les mets dans +# une mailing-liste. ce script est utilie si l'on souhaite avoir une +# mailing-liste avec uniquement les adherents valides. + use DBI; use strict; # get the command line option