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 '
| Erreur dans l\'execution du formulaire | '; + print "
|---|
| $errmsg |