From e5d3de79ee792cea05c1607e0bca0838674b5965 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 Jun 2011 14:56:11 +0000 Subject: [PATCH] New: Subscription/Unsubscription to mailman mailing-list can be done on validate/resiliate in foundation module. --- ChangeLog | 2 + htdocs/adherents/admin/adherent.php | 408 +++++++++--------- htdocs/adherents/class/adherent.class.php | 91 ++-- htdocs/adherents/fiche.php | 16 +- htdocs/includes/modules/modAdherent.class.php | 4 +- 5 files changed, 270 insertions(+), 251 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6e17bee2e39..5314f67397f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -69,6 +69,8 @@ For users: - New: Can add a logo on third parties card. - New: task #11194 : Can delete uploaded photos - New: task #9744 : Add the barcode to select products on Point of Sale module +- New: Subscription/Unsubscription to mailman mailing-list can be done on + validate/resiliate in foundation module. - Fix: Better Postgresql compatibility. - Fix: Numbering module for invoices use same number for invoice and credit note if mask is same. diff --git a/htdocs/adherents/admin/adherent.php b/htdocs/adherents/admin/adherent.php index ac46a47fdaf..16d63f3964d 100644 --- a/htdocs/adherents/admin/adherent.php +++ b/htdocs/adherents/admin/adherent.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2011 Regis Houssin @@ -45,44 +45,44 @@ $typeconst=array('yesno','texte','chaine'); // Action mise a jour ou ajout d'une constante if ($_POST["action"] == 'update' || $_POST["action"] == 'add') { - if (($_POST["constname"]=='ADHERENT_CARD_TYPE' || $_POST["constname"]=='ADHERENT_ETIQUETTE_TYPE') - && $_POST["constvalue"] == -1) $_POST["constvalue"]=''; + if (($_POST["constname"]=='ADHERENT_CARD_TYPE' || $_POST["constname"]=='ADHERENT_ETIQUETTE_TYPE') + && $_POST["constvalue"] == -1) $_POST["constvalue"]=''; if ($_POST["constname"]=='ADHERENT_LOGIN_NOT_REQUIRED') // Invert choice { if ($_POST["constvalue"]) $_POST["constvalue"]=0; else $_POST["constvalue"]=1; } - $const=$_POST["constname"]; - $value=$_POST["constvalue"]; - if (in_array($const,array('ADHERENT_MAIL_VALID','ADHERENT_MAIL_COTIS','ADHERENT_MAIL_RESIL'))) $value=$_POST["constvalue".$const]; - $type=$_POST["consttype"]; - $constnote=isset($_POST["constnote"])?$_POST["constnote"]:''; - $result=dolibarr_set_const($db,$const,$value,$typeconst[$type],0,$constnote,$conf->entity); - if ($result < 0) - { - print $db->error(); - } + $const=$_POST["constname"]; + $value=$_POST["constvalue"]; + if (in_array($const,array('ADHERENT_MAIL_VALID','ADHERENT_MAIL_COTIS','ADHERENT_MAIL_RESIL'))) $value=$_POST["constvalue".$const]; + $type=$_POST["consttype"]; + $constnote=isset($_POST["constnote"])?$_POST["constnote"]:''; + $result=dolibarr_set_const($db,$const,$value,$typeconst[$type],0,$constnote,$conf->entity); + if ($result < 0) + { + print $db->error(); + } } // Action activation d'un sous module du module adherent if ($_GET["action"] == 'set') { - $result=dolibarr_set_const($db, $_GET["name"],$_GET["value"],'',0,'',$conf->entity); - if ($result < 0) - { - print $db->error(); - } + $result=dolibarr_set_const($db, $_GET["name"],$_GET["value"],'',0,'',$conf->entity); + if ($result < 0) + { + print $db->error(); + } } // Action desactivation d'un sous module du module adherent if ($_GET["action"] == 'unset') { - $result=dolibarr_del_const($db,$_GET["name"],$conf->entity); - if ($result < 0) - { - print $db->error(); - } + $result=dolibarr_del_const($db,$_GET["name"],$conf->entity); + if ($result < 0) + { + print $db->error(); + } } @@ -166,17 +166,17 @@ print ''; print ''.$langs->trans("AddSubscriptionIntoAccount").''; if ($conf->banque->enabled) { - print ''; - print $form->selectyesno('constvalue',$conf->global->ADHERENT_BANK_USE,1); - print ''; - print ''; - print ''; + print ''; + print $form->selectyesno('constvalue',$conf->global->ADHERENT_BANK_USE,1); + print ''; + print ''; + print ''; } else { - print ''; - print $langs->trans("WarningModuleNotActive",$langs->transnoentities("Module85Name")).' '.img_warning("",""); - print ''; + print ''; + print $langs->trans("WarningModuleNotActive",$langs->transnoentities("Module85Name")).' '.img_warning("",""); + print ''; } print "\n"; print ''; @@ -188,32 +188,28 @@ print '
'; /* * Mailman */ -if ($conf->global->MAIN_FEATURES_LEVEL >= 1) +$var=!$var; +if ($conf->global->ADHERENT_USE_MAILMAN) { - $var=!$var; - if ($conf->global->ADHERENT_USE_MAILMAN) - { - $lien=img_tick().' '; - $lien.=''.$langs->trans("Disable").''; - // Edition des varibales globales rattache au theme Mailman - $constantes=array('ADHERENT_MAILMAN_LISTS', - 'ADHERENT_MAILMAN_LISTS_COTISANT', - 'ADHERENT_MAILMAN_ADMINPW', - 'ADHERENT_MAILMAN_SERVER', - 'ADHERENT_MAILMAN_URL', - 'ADHERENT_MAILMAN_UNSUB_URL' - ); - print_fiche_titre("Mailman mailing list system",$lien,''); - form_constantes($constantes); - } - else - { - $lien=''.$langs->trans("Activate").''; - print_fiche_titre("Mailman mailing list system",$lien,''); - } - - print "
\n"; + $lien=img_tick().' '; + $lien.=''.$langs->trans("Disable").''; + // Edition des varibales globales + $constantes=array('ADHERENT_MAILMAN_LISTS', + 'ADHERENT_MAILMAN_ADMINPW', + 'ADHERENT_MAILMAN_URL', + 'ADHERENT_MAILMAN_UNSUB_URL' + ); + print_fiche_titre("Mailman mailing list system",$lien,''); + form_constantes($constantes); + print '
'; } +else +{ + $lien=''.$langs->trans("Activate").''; + print_fiche_titre("Mailman mailing list system",$lien,''); + print "
\n"; +} + /* * Spip @@ -221,10 +217,10 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 1) $var=!$var; if ($conf->global->ADHERENT_USE_SPIP) { - $lien=img_tick().' '; - $lien.=''.$langs->trans("Disable").''; - // Edition des varibales globales rattache au theme Mailman - $constantes=array('ADHERENT_USE_SPIP_AUTO', + $lien=img_tick().' '; + $lien.=''.$langs->trans("Disable").''; + // Edition des varibales globales + $constantes=array('ADHERENT_USE_SPIP_AUTO', 'ADHERENT_SPIP_SERVEUR', 'ADHERENT_SPIP_DB', 'ADHERENT_SPIP_USER', @@ -232,14 +228,15 @@ if ($conf->global->ADHERENT_USE_SPIP) ); print_fiche_titre("SPIP CMS",$lien,''); form_constantes($constantes); + print '
'; } else { - $lien=''.$langs->trans("Activate").''; - print_fiche_titre("SPIP - CMS",$lien,''); + $lien=''.$langs->trans("Activate").''; + print_fiche_titre("SPIP - CMS",$lien,''); + print "
\n"; } -print "
\n"; /* * Edition info modele document @@ -252,37 +249,37 @@ $constantes=array( 'ADHERENT_CARD_TEXT_RIGHT', 'ADHERENT_CARD_FOOTER_TEXT' ); -print_fiche_titre($langs->trans("MembersCards"),'',''); + print_fiche_titre($langs->trans("MembersCards"),'',''); -form_constantes($constantes); + form_constantes($constantes); -print '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
'; -print '%DOL_MAIN_URL_ROOT%, %ID%, %PRENOM%, %NOM%, %LOGIN%, %PASSWORD%, '; -print '%SOCIETE%, %ADRESSE%, %CP%, %VILLE%, %PAYS%, %EMAIL%, %NAISS%, %PHOTO%, %TYPE%, '; -print '%YEAR%, %MONTH%, %DAY%'; -//print '%INFOS%'; Deprecated -print '
'; + print '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
'; + print '%DOL_MAIN_URL_ROOT%, %ID%, %PRENOM%, %NOM%, %LOGIN%, %PASSWORD%, '; + print '%SOCIETE%, %ADRESSE%, %CP%, %VILLE%, %PAYS%, %EMAIL%, %NAISS%, %PHOTO%, %TYPE%, '; + print '%YEAR%, %MONTH%, %DAY%'; + //print '%INFOS%'; Deprecated + print '
'; -print '
'; + print '
'; -/* - * Edition info modele document - */ -$constantes=array( + /* + * Edition info modele document + */ + $constantes=array( 'ADHERENT_ETIQUETTE_TYPE' ); -print_fiche_titre($langs->trans("MembersTickets"),'',''); + print_fiche_titre($langs->trans("MembersTickets"),'',''); -form_constantes($constantes); + form_constantes($constantes); -print '
'; + print '
'; -/* - * Edition des variables globales non rattache a un theme specifique - */ -$constantes=array( + /* + * Edition des variables globales non rattache a un theme specifique + */ + $constantes=array( 'ADHERENT_AUTOREGISTER_MAIL_SUBJECT', 'ADHERENT_AUTOREGISTER_MAIL', 'ADHERENT_MAIL_VALID_SUBJECT', @@ -294,137 +291,152 @@ $constantes=array( 'ADHERENT_MAIL_FROM', ); -print_fiche_titre($langs->trans("Other"),'',''); + print_fiche_titre($langs->trans("Other"),'',''); -form_constantes($constantes); + form_constantes($constantes); -print '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
'; -print '%DOL_MAIN_URL_ROOT%, %ID%, %PRENOM%, %NOM%, %LOGIN%, %PASSWORD%,'; -print '%SOCIETE%, %ADRESSE%, %CP%, %VILLE%, %PAYS%, %EMAIL%, %NAISS%, %PHOTO%, %TYPE%'; -//print '%YEAR%, %MONTH%, %DAY%'; // Not supported -//print '%INFOS%'; Deprecated -print '
'; + print '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
'; + print '%DOL_MAIN_URL_ROOT%, %ID%, %PRENOM%, %NOM%, %LOGIN%, %PASSWORD%,'; + print '%SOCIETE%, %ADRESSE%, %CP%, %VILLE%, %PAYS%, %EMAIL%, %NAISS%, %PHOTO%, %TYPE%'; + //print '%YEAR%, %MONTH%, %DAY%'; // Not supported + //print '%INFOS%'; Deprecated + print '
'; -$db->close(); + $db->close(); -print '
'; + print '
'; -llxFooter('$Date$ - $Revision$'); + llxFooter('$Date$ - $Revision$'); -function form_constantes($tableau) -{ - global $db,$bc,$langs,$conf,$_Avery_Labels; - - $form = new Form($db); - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - $var=true; - - $listofparam=array(); - foreach($tableau as $const) // Loop on each param - { - $sql = "SELECT "; - $sql.= "rowid"; - $sql.= ", ".$db->decrypt('name')." as name"; - $sql.= ", ".$db->decrypt('value')." as value"; - $sql.= ", type"; - $sql.= ", note"; - $sql.= " FROM ".MAIN_DB_PREFIX."const"; - $sql.= " WHERE ".$db->decrypt('name')." = '".$const."'"; - $sql.= " AND entity in (0, ".$conf->entity.")"; - $sql.= " ORDER BY name ASC, entity DESC"; - $result = $db->query($sql); - - dol_syslog("List params sql=".$sql); - if ($result) + function form_constantes($tableau) { - $obj = $db->fetch_object($result); // Take first result of select - $var=!$var; + global $db,$bc,$langs,$conf,$_Avery_Labels; - print "\n".''; + $form = new Form($db); - print ""; + print '
'.$langs->trans("Description").''.$langs->trans("Value").'* '.$langs->trans("Action").'
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + $var=true; - // Affiche nom constante - print '\n"; + dol_syslog("List params sql=".$sql); + if ($result) + { + $obj = $db->fetch_object($result); // Take first result of select + $var=!$var; - if ($const == 'ADHERENT_CARD_TYPE' || $const == 'ADHERENT_ETIQUETTE_TYPE') - { - print ''; - } - else - { - print ''; - } - print '"; - print "\n"; - print "\n"; - $i++; + print ""; + + // Affiche nom constante + print '\n"; + + if ($const == 'ADHERENT_CARD_TYPE' || $const == 'ADHERENT_ETIQUETTE_TYPE') + { + print ''; + } + else + { + print ''; + } + print '"; + print "\n"; + print "\n"; + $i++; + } + } + print '
'.$langs->trans("Description").''.$langs->trans("Value").'* '.$langs->trans("Action").'
'; - print ''; - print ''; - print ''; - print ''; - print ''; + $listofparam=array(); + foreach($tableau as $const) // Loop on each param + { + $sql = "SELECT "; + $sql.= "rowid"; + $sql.= ", ".$db->decrypt('name')." as name"; + $sql.= ", ".$db->decrypt('value')." as value"; + $sql.= ", type"; + $sql.= ", note"; + $sql.= " FROM ".MAIN_DB_PREFIX."const"; + $sql.= " WHERE ".$db->decrypt('name')." = '".$const."'"; + $sql.= " AND entity in (0, ".$conf->entity.")"; + $sql.= " ORDER BY name ASC, entity DESC"; + $result = $db->query($sql); - print $langs->trans("Desc".$const) != ("Desc".$const) ? $langs->trans("Desc".$const) : ($obj->note?$obj->note:$const); - print "'; - // List of possible labels (defined into $_Avery_Labels variable set into format_cards.lib.php) - require_once(DOL_DOCUMENT_ROOT.'/lib/format_cards.lib.php'); - $arrayoflabels=array(); - foreach(array_keys($_Avery_Labels) as $codecards) - { - $arrayoflabels[$codecards]=$_Avery_Labels[$codecards]['name']; - } - print $form->selectarray('constvalue',$arrayoflabels,($obj->value?$obj->value:'CARD'),1,0,0); - print ''; - print ''; - print ''; - //print 'aa'.$const; - if (in_array($const,array('ADHERENT_CARD_TEXT','ADHERENT_CARD_TEXT_RIGHT'))) - { - print '\n"; - print ''; - print ''; - } - else if (in_array($const,array('ADHERENT_AUTOREGISTER_MAIL','ADHERENT_MAIL_VALID','ADHERENT_MAIL_COTIS','ADHERENT_MAIL_RESIL'))) - { - require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $doleditor=new DolEditor('constvalue'.$const,$obj->value,'',160,'dolibarr_notes','',false,false,$conf->fckeditor->enabled,5,60); - $doleditor->Create(); + print "\n".''; - print ''; - print ''; - } - else if ($obj->type == 'yesno') - { - print $form->selectyesno('constvalue',$obj->value,1); - print ''; - print ''; - } - else - { - print ''; - print ''; - print ''; - } - print ''; - print '  '; - // print ''.img_delete().''; - print "
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + print $langs->trans("Desc".$const) != ("Desc".$const) ? $langs->trans("Desc".$const) : ($obj->note?$obj->note:$const); + + if ($const=='ADHERENT_MAILMAN_URL') + { + print '. '.$langs->trans("Example").':
'; + //print 'http://lists.domain.com/cgi-bin/mailman/admin/%LISTE%/members?adminpw=%MAILMAN_ADMINPW%&subscribees=%EMAIL%&send_welcome_msg_to_this_batch=1'; + print 'http://lists.domain.com/cgi-bin/mailman/admin/%LISTE%/members/add?subscribees_upload=%EMAIL%&adminpw=%MAILMAN_ADMINPW%&subscribe_or_invite=0&send_welcome_msg_to_this_batch=0¬ification_to_list_owner=0'; + } + if ($const=='ADHERENT_MAILMAN_UNSUB_URL') + { + print '. '.$langs->trans("Example").':
'; + print 'http://lists.domain.com/cgi-bin/mailman/admin/%LISTE%/members/remove?unsubscribees_upload=%EMAIL%&adminpw=%MAILMAN_ADMINPW%&send_unsub_ack_to_this_batch=0&send_unsub_notifications_to_list_owner=0'; + //print 'http://lists.domain.com/cgi-bin/mailman/admin/%LISTE%/members/remove?adminpw=%MAILMAN_ADMINPW%&unsubscribees=%EMAIL%'; + } + + + print "
'; + // List of possible labels (defined into $_Avery_Labels variable set into format_cards.lib.php) + require_once(DOL_DOCUMENT_ROOT.'/lib/format_cards.lib.php'); + $arrayoflabels=array(); + foreach(array_keys($_Avery_Labels) as $codecards) + { + $arrayoflabels[$codecards]=$_Avery_Labels[$codecards]['name']; + } + print $form->selectarray('constvalue',$arrayoflabels,($obj->value?$obj->value:'CARD'),1,0,0); + print ''; + print ''; + print ''; + //print 'aa'.$const; + if (in_array($const,array('ADHERENT_CARD_TEXT','ADHERENT_CARD_TEXT_RIGHT'))) + { + print '\n"; + print ''; + print ''; + } + else if (in_array($const,array('ADHERENT_AUTOREGISTER_MAIL','ADHERENT_MAIL_VALID','ADHERENT_MAIL_COTIS','ADHERENT_MAIL_RESIL'))) + { + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('constvalue'.$const,$obj->value,'',160,'dolibarr_notes','',false,false,$conf->fckeditor->enabled,5,60); + $doleditor->Create(); + + print ''; + print ''; + } + else if ($obj->type == 'yesno') + { + print $form->selectyesno('constvalue',$obj->value,1); + print ''; + print ''; + } + else + { + print ''; + print ''; + print ''; + } + print ''; + print '  '; + // print ''.img_delete().''; + print "
'; } - } - print ''; -} -?> \ No newline at end of file + ?> \ No newline at end of file diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index cb075d5d639..e13fadb44cf 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1142,12 +1142,6 @@ class Adherent extends CommonObject $result=$this->update_end_date($user); if ($result > 0) { - // Rajout du nouveau cotisant dans les listes qui vont bien - if ($conf->global->ADHERENT_MAILMAN_LISTS_COTISANT && ! $this->datefin) - { - $result=$this->add_to_mailman($conf->global->ADHERENT_MAILMAN_LISTS_COTISANT); - } - // Change properties of object (used by triggers) $this->last_subscription_date=$dateop; $this->last_subscription_amount=$montant; @@ -1280,17 +1274,16 @@ class Adherent extends CommonObject /** * Fonction qui ajoute l'adherent au abonnements automatiques * mailing-list, spip, etc... - * @param adht - * @return int <0 si KO, >=0 si OK + * @return int <0 if KO, >0 if OK */ - function add_to_abo($adht) + function add_to_abo() { global $conf; $err=0; // mailman - if ($conf->global->ADHERENT_USE_MAILMAN) + if (! empty($conf->global->ADHERENT_USE_MAILMAN)) { $result=$this->add_to_mailman(); if ($result < 0) @@ -1303,7 +1296,7 @@ class Adherent extends CommonObject if ($conf->global->ADHERENT_USE_SPIP && $conf->global->ADHERENT_USE_SPIP_AUTO) { $result=$this->add_to_spip(); - if(!$result) + if ($result < 0) { $err+=1; } @@ -1323,29 +1316,38 @@ class Adherent extends CommonObject /** * Fonction qui supprime l'adherent des abonnements automatiques * mailing-list, spip, etc... - * @param adht + * @return int <0 if KO, >0 if OK */ - function del_to_abo($adht) + function del_to_abo() { + global $conf; + $err=0; // mailman - if ($conf->global->ADHERENT_USE_MAILMAN) + if (! empty($conf->global->ADHERENT_USE_MAILMAN)) { - if(!$this->del_to_mailman()){ + $result=$this->del_to_mailman(); + if ($result < 0) + { $err+=1; } } if ($conf->global->ADHERENT_USE_SPIP && $conf->global->ADHERENT_USE_SPIP_AUTO) { - if(!$this->del_to_spip()){ + $result=$this->del_to_spip(); + if ($result < 0) + { $err+=1; } } - if ($err>0){ + if ($err) + { // error - return 0; - }else{ + return -$err; + } + else + { return 1; } } @@ -1464,12 +1466,13 @@ class Adherent extends CommonObject } /** - * Fonction qui rajoute l'utilisateur dans mailman - * @return int <0 si KO, >0 si OK + * Subscribe an email to all mailing-lists + * @param listes To force mailing-list (string separated with ,) + * @return int <=0 if KO, >0 if OK */ function add_to_mailman($listes='') { - global $conf,$langs; + global $conf,$langs,$user; dol_syslog(get_class($this)."::add_to_mailman"); @@ -1480,11 +1483,11 @@ class Adherent extends CommonObject return -1; } - if (defined("ADHERENT_MAILMAN_URL") && ADHERENT_MAILMAN_URL != '' && defined("ADHERENT_MAILMAN_LISTS") && ADHERENT_MAILMAN_LISTS != '') + if (! empty($conf->global->ADHERENT_MAILMAN_URL)) { - if ($listes =='') + if ($listes == '' && ! empty($conf->global->ADHERENT_MAILMAN_LISTS)) { - $lists=explode(',',ADHERENT_MAILMAN_LISTS); + $lists=explode(',',$conf->global->ADHERENT_MAILMAN_LISTS); } else { @@ -1508,6 +1511,7 @@ class Adherent extends CommonObject ); $curl_url = preg_replace ($patterns, $replace, $conf->global->ADHERENT_MAILMAN_URL); + dol_syslog("Call URL to subscribe : ".$curl_url); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"$curl_url"); //curl_setopt($ch, CURLOPT_URL,"http://www.j1b.org/"); @@ -1526,7 +1530,7 @@ class Adherent extends CommonObject if (curl_error($ch) > 0) { // error - return 0; + return -2; } curl_close ($ch); @@ -1535,27 +1539,29 @@ class Adherent extends CommonObject } else { - $this->error="Constantes de connexion non definies"; + $this->error="ADHERENT_MAILMAN_URL not defined"; return -1; } } /** - * Fonction qui desinscrit l'utilisateur de toutes les mailing list mailman - * Utilise lors de la resiliation d'adhesion + * Unsubscribe an email from all mailing-lists + * Used when a user is resiliated + * @param listes To force mailing-list (string separated with ,) + * @return int <=0 if KO, >0 if OK */ function del_to_mailman($listes='') { - global $conf; + global $conf,$langs,$user; - if (defined("ADHERENT_MAILMAN_UNSUB_URL") && ADHERENT_MAILMAN_UNSUB_URL != '' && defined("ADHERENT_MAILMAN_LISTS") && ADHERENT_MAILMAN_LISTS != '') + if (! empty($conf->global->ADHERENT_MAILMAN_UNSUB_URL)) { - if ($listes==''){ - $lists=explode(',',ADHERENT_MAILMAN_LISTS); - if (defined("ADHERENT_MAILMAN_LISTS_COTISANT") && ADHERENT_MAILMAN_LISTS_COTISANT !=''){ - $lists=array_merge ($lists,explode(',',ADHERENT_MAILMAN_LISTS_COTISANT)); - } - }else{ + if ($listes=='' && ! empty($conf->global->ADHERENT_MAILMAN_LISTS)) + { + $lists=explode(',',$conf->global->ADHERENT_MAILMAN_LISTS); + } + else + { $lists=explode(',',$listes); } foreach ($lists as $list) @@ -1569,13 +1575,14 @@ class Adherent extends CommonObject '/%MAILMAN_ADMINPW%/' ); $replace = array ( - $list, + trim($list), $this->email, $this->pass, $conf->global->ADHERENT_MAILMAN_ADMINPW ); $curl_url = preg_replace ($patterns, $replace, $conf->global->ADHERENT_MAILMAN_UNSUB_URL); + dol_syslog("Call URL to unsubscribe : ".$curl_url); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"$curl_url"); //curl_setopt($ch, CURLOPT_URL,"http://www.j1b.org/"); @@ -1594,9 +1601,9 @@ class Adherent extends CommonObject $rescode=curl_error($ch); if ($rescode > 0) { - dol_syslog("Error using CURL : ".$rescode); + dol_syslog("Error using CURL : ".$rescode, LOG_ERR); // error - return 0; + return -2; } curl_close ($ch); @@ -1605,8 +1612,8 @@ class Adherent extends CommonObject } else { - $this->error="Constantes de connexion non definies"; - return 0; + $this->error="ADHERENT_MAILMAN_UNSUB_URL not defined"; + return -1; } } diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index d42a7140ec4..bcb6e394ce5 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -522,10 +522,10 @@ if ($user->rights->adherent->creer && $_POST["action"] == 'confirm_valid' && $_P } // Rajoute l'utilisateur dans les divers abonnements (mailman, spip, etc...) - if ($adh->add_to_abo($adht) < 0) + if ($adh->add_to_abo() < 0) { // error - $errmsg.="Echec du rajout de l'utilisateur aux abonnements mailman: ".$adh->error."
\n"; + $errmsg.= $langs->trans("FaildToAddToMailmanList").': '.$adh->error."
\n"; } } else @@ -538,14 +538,14 @@ if ($user->rights->adherent->creer && $_POST["action"] == 'confirm_valid' && $_P if ($user->rights->adherent->supprimer && $_POST["action"] == 'confirm_resign' && $_POST["confirm"] == 'yes') { - $result=$adh->resiliate($user); - $adht = new AdherentType($db); $adht->fetch($adh->typeid); - if ($result >= 0 && ! sizeof($adh->errors)) + $result=$adh->resiliate($user); + + if ($result >= 0 && ! sizeof($adh->errors)) { - if ($adh->email && $_POST["send_mail"]) + if ($adh->email && $_POST["send_mail"]) { $result=$adh->send_an_email($adht->getMailOnResiliate(),$conf->global->ADHERENT_MAIL_RESIL_SUBJECT,array(),array(),array(),"","",0,-1); } @@ -555,10 +555,10 @@ if ($user->rights->adherent->supprimer && $_POST["action"] == 'confirm_resign' & } // supprime l'utilisateur des divers abonnements .. - if (! $adh->del_to_abo($adht)) + if ($adh->del_to_abo() < 0) { // error - $errmsg.="Echec de la suppression de l'utilisateur aux abonnements mailman: ".$adh->error."
\n"; + $errmsg.=$langs->trans("FaildToRemoveFromMailmanList").': '.$adh->error."
\n"; } } else diff --git a/htdocs/includes/modules/modAdherent.class.php b/htdocs/includes/modules/modAdherent.class.php index 1f8f9e5d263..b17d5742b5d 100644 --- a/htdocs/includes/modules/modAdherent.class.php +++ b/htdocs/includes/modules/modAdherent.class.php @@ -82,7 +82,7 @@ class modAdherent extends DolibarrModules $this->const[6] = array("ADHERENT_MAIL_RESIL_SUBJECT","chaine","Résiliation de votre adhésion","Sujet du mail de résiliation"); $this->const[10] = array("ADHERENT_MAILMAN_UNSUB_URL","chaine","http://lists.domain.com/cgi-bin/mailman/admin/%LISTE%/members?adminpw=%MAILMAN_ADMINPW%&user=%EMAIL%","Url de désinscription aux listes mailman"); $this->const[11] = array("ADHERENT_MAILMAN_URL","chaine","http://lists.domain.com/cgi-bin/mailman/admin/%LISTE%/members?adminpw=%MAILMAN_ADMINPW%&send_welcome_msg_to_this_batch=1&subscribees=%EMAIL%","Url pour les inscriptions mailman"); - $this->const[12] = array("ADHERENT_MAILMAN_LISTS","chaine","","Listes auxquelles les nouveaux adhérents sont inscrits"); + $this->const[12] = array("ADHERENT_MAILMAN_LISTS","chaine","","Mailing-list to subscribe new members to"); $this->const[16] = array("ADHERENT_USE_SPIP_AUTO","yesno","","Utilisation de SPIP automatiquement"); $this->const[17] = array("ADHERENT_SPIP_USER","chaine","","Utilisateur de connexion à la base spip"); $this->const[18] = array("ADHERENT_SPIP_PASS","chaine","","Mot de passe de connexion à la base spip"); @@ -95,8 +95,6 @@ class modAdherent extends DolibarrModules $this->const[26] = array("ADHERENT_CARD_FOOTER_TEXT","chaine","Association AZERTY","Texte imprimé sur le bas de la carte adhérent"); $this->const[27] = array("ADHERENT_CARD_TEXT","texte","%PRENOM% %NOM%\r\nMembre ne %ID%\r\n%EMAIL%\r\n%ADRESSE%\r\n%CP% %VILLE%\r\n%PAYS%","Texte imprimé sur la carte adhérent"); $this->const[28] = array("ADHERENT_MAILMAN_ADMINPW","chaine","","Mot de passe Admin des liste mailman"); - $this->const[29] = array("ADHERENT_MAILMAN_SERVER","chaine","","Serveur hébergeant les interfaces d'Admin des listes mailman"); - $this->const[30] = array("ADHERENT_MAILMAN_LISTS_COTISANT","chaine","","Liste(s) auxquelles les nouveaux cotisants sont inscrits automatiquement"); $this->const[31] = array("ADHERENT_BANK_USE_AUTO","yesno","","Insertion automatique des cotisations dans le compte banquaire"); $this->const[32] = array("ADHERENT_BANK_ACCOUNT","chaine","","ID du Compte banquaire utilise"); $this->const[33] = array("ADHERENT_BANK_CATEGORIE","chaine","","ID de la catégorie banquaire des cotisations");