diff --git a/ChangeLog b/ChangeLog index b7545eea13e..3273f75ad78 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16,6 +16,8 @@ For users: - New: Enhance default style. - New: Can edit and resiliate member status from list. - New: Can insert links into elements lines. Also reported into PDF. +- New: When a member is validated, we can subscribe to mailing-lists + according to its type. - Fix: No images into product description lines as PDF generation does not work with this. diff --git a/htdocs/adherents/admin/mailman.php b/htdocs/adherents/admin/mailman.php index 81f1a2e32f9..a2bb43a906a 100644 --- a/htdocs/adherents/admin/mailman.php +++ b/htdocs/adherents/admin/mailman.php @@ -33,6 +33,7 @@ require_once(DOL_DOCUMENT_ROOT."/core/lib/mailmanspip.lib.php"); $langs->load("admin"); $langs->load("members"); +$langs->load("mailmanspip"); if (! $user->admin) accessforbidden(); @@ -40,7 +41,8 @@ if (! $user->admin) accessforbidden(); $type=array('yesno','texte','chaine'); $action = GETPOST("action"); - +$testsubscribeemail = GETPOST("testsubscribeemail"); +$testunsubscribeemail = GETPOST("testunsubscribeemail"); /* * Actions @@ -51,16 +53,7 @@ if ($action == 'update' || $action == 'add') { $constname=GETPOST("constname"); $constvalue=GETPOST("constvalue"); - - if (($constname=='ADHERENT_CARD_TYPE' || $constname=='ADHERENT_ETIQUETTE_TYPE') && $constvalue == -1) $constvalue=''; - if ($constname=='ADHERENT_LOGIN_NOT_REQUIRED') // Invert choice - { - if ($constvalue) $constvalue=0; - else $constvalue=1; - } - - if (in_array($constname,array('ADHERENT_MAIL_VALID','ADHERENT_MAIL_COTIS','ADHERENT_MAIL_RESIL'))) $constvalue=$_POST["constvalue".$constname]; - $consttype=$_POST["consttype"]; + $consttype=GETPOST("consttype"); $constnote=GETPOST("constnote"); $res=dolibarr_set_const($db,$constname,$constvalue,$type[$consttype],0,$constnote,$conf->entity); @@ -79,7 +72,7 @@ if ($action == 'update' || $action == 'add') // Action activation d'un sous module du module adherent if ($action == 'set') { - $result=dolibarr_set_const($db, $_GET["name"],$_GET["value"],'',0,'',$conf->entity); + $result=dolibarr_set_const($db, $_GET["name"], $_GET["value"], '', 0, '', $conf->entity); if ($result < 0) { dol_print_error($db); @@ -89,13 +82,60 @@ if ($action == 'set') // Action desactivation d'un sous module du module adherent if ($action == 'unset') { - $result=dolibarr_del_const($db,$_GET["name"],$conf->entity); + $result=dolibarr_del_const($db, $_GET["name"], $conf->entity); if ($result < 0) { dol_print_error($db); } } +if (($action == 'testsubscribe' || $action == 'testunsubscribe') && ! empty($conf->global->ADHERENT_USE_MAILMAN)) +{ + $email=GETPOST($action.'email'); + if (! isValidEmail($email)) + { + $langs->load("errors"); + $mesg='
'.$langs->trans("ErrorBadEMail",$email).'
'; + } + else + { + include_once(DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php'); + $mailmanspip=new MailmanSpip($db); + + $object=new stdClass(); + $object->email=$email; + $object->pass=$email; + /*$object->element='member'; + $object->type='Preferred Partners'; */ + + if ($action == 'testsubscribe') + { + $result=$mailmanspip->add_to_mailman($object); + if ($result < 0) + { + $error++; + $mesg='
'.$mailmanspip->error.'
'; + } + else + { + $mesg='MailmanCreationSuccess'; + } + } + if ($action == 'testunsubscribe') + { + $result=$mailmanspip->del_to_mailman($object); + if ($result < 0) + { + $error++; + $mesg='
'.$mailmanspip->error.'
'; + } + else + { + $mesg='MailmanDeletionSuccess'; + } + } + } +} /* @@ -125,8 +165,11 @@ dol_htmloutput_mesg($mesg); $var=!$var; if ($conf->global->ADHERENT_USE_MAILMAN) { - $lien=img_picto($langs->trans("Active"),'tick').' '; - $lien.=''.$langs->trans("Disable").''; + //$lien=img_picto($langs->trans("Active"),'tick').' '; + $lien=''; + //$lien.=$langs->trans("Disable"); + $lien.=img_picto($langs->trans("Activated"),'switch_on'); + $lien.=''; // Edition des varibales globales $constantes=array( 'ADHERENT_MAILMAN_ADMINPW', @@ -162,13 +205,30 @@ if ($conf->global->ADHERENT_USE_MAILMAN) } else { - $lien=''.$langs->trans("Activate").''; + $lien=''; + //$lien.=img_$langs->trans("Activate") + $lien.=img_picto($langs->trans("Disabled"),'switch_off'); + $lien.=''; print_fiche_titre("Mailman mailing list system",$lien,''); - print "
\n"; } dol_fiche_end(); +if ($conf->global->ADHERENT_USE_MAILMAN) +{ + print '
'; + print ''; + print $langs->trans("TestSubscribe").'
'; + print $langs->trans("EMail").'
'; + print '
'; + print '
'; + print ''; + print $langs->trans("TestUnSubscribe").'
'; + print $langs->trans("EMail").'
'; + print '
'; +} + + llxFooter(); $db->close(); diff --git a/htdocs/adherents/admin/spip.php b/htdocs/adherents/admin/spip.php index 6cbd8ee1344..e540f4d1f30 100644 --- a/htdocs/adherents/admin/spip.php +++ b/htdocs/adherents/admin/spip.php @@ -124,8 +124,11 @@ dol_htmloutput_mesg($mesg); $var=!$var; if ($conf->global->ADHERENT_USE_SPIP) { - $lien=img_picto($langs->trans("Active"),'tick').' '; - $lien.=''.$langs->trans("Disable").''; + //$lien=img_picto($langs->trans("Active"),'tick').' '; + $lien=''; + //$lien.=$langs->trans("Disable"); + $lien.=img_picto($langs->trans("Activated"),'switch_on'); + $lien.=''; // Edition des varibales globales $constantes=array( 'ADHERENT_SPIP_SERVEUR', @@ -140,9 +143,11 @@ if ($conf->global->ADHERENT_USE_SPIP) } else { - $lien=''.$langs->trans("Activate").''; + $lien=''; + //$lien.=$langs->trans("Activate"); + $lien.=img_picto($langs->trans("Disabled"),'switch_off'); + $lien.=''; print_fiche_titre("SPIP - CMS",$lien,''); - print "
\n"; } diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 0c777a90c29..2722454a934 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1347,8 +1347,8 @@ class Adherent extends CommonObject /** - * Fonction qui ajoute l'adherent au abonnements automatiques - * mailing-list, spip, etc. + * Fonction qui ajoute l'adherent au abonnements automatiques mailing-list, spip, etc. + * TODO Move this into member creation trigger (trigger of mailmanspip module) * * @return int <0 if KO, >0 if OK */ @@ -1356,12 +1356,15 @@ class Adherent extends CommonObject { global $conf; + include_once(DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php'); + $mailmanspip=new MailmanSpip($db); + $err=0; // mailman if (! empty($conf->global->ADHERENT_USE_MAILMAN)) { - $result=$this->add_to_mailman(); + $result=$mailmanspip->add_to_mailman($this); if ($result < 0) { $err+=1; @@ -1371,7 +1374,7 @@ class Adherent extends CommonObject // spip if ($conf->global->ADHERENT_USE_SPIP && $conf->mailmanspip->enabled) { - $result=$this->add_to_spip(); + $result=$mailmanspip->add_to_spip($this); if ($result < 0) { $err+=1; @@ -1390,8 +1393,8 @@ class Adherent extends CommonObject /** - * Fonction qui supprime l'adherent des abonnements automatiques - * mailing-list, spip, etc. + * Fonction qui supprime l'adherent des abonnements automatiques mailing-list, spip, etc. + * TODO Move this into member deletion trigger (trigger of mailmanspip module) * * @return int <0 if KO, >0 if OK */ @@ -1399,11 +1402,15 @@ class Adherent extends CommonObject { global $conf; + include_once(DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php'); + $mailmanspip=new MailmanSpip($db); + $err=0; + // mailman if (! empty($conf->global->ADHERENT_USE_MAILMAN)) { - $result=$this->del_to_mailman(); + $result=$mailmanspip->del_to_mailman($this); if ($result < 0) { $err+=1; @@ -1412,7 +1419,7 @@ class Adherent extends CommonObject if ($conf->global->ADHERENT_USE_SPIP && $conf->mailmanspip->enabled) { - $result=$this->del_to_spip(); + $result=$mailmanspip->del_to_spip($this); if ($result < 0) { $err+=1; @@ -1430,281 +1437,6 @@ class Adherent extends CommonObject } - /** - * Fonction qui donne les droits redacteurs dans spip - * - * @return int =0 if KO, >0 if OK - */ - function add_to_spip() - { - dol_syslog(get_class($this)."::add_to_spip"); - - if (defined("ADHERENT_USE_SPIP") && ADHERENT_USE_SPIP ==1 && - defined('ADHERENT_SPIP_SERVEUR') && ADHERENT_SPIP_SERVEUR != '' && - defined('ADHERENT_SPIP_USER') && ADHERENT_SPIP_USER != '' && - defined('ADHERENT_SPIP_PASS') && ADHERENT_SPIP_PASS != '' && - defined('ADHERENT_SPIP_DB') && ADHERENT_SPIP_DB != '' - ) - { - require_once(DOL_DOCUMENT_ROOT."/core/lib/security2.lib.php"); - $mdpass=dol_hash($this->pass); - $htpass=crypt($this->pass,makesalt()); - $query = "INSERT INTO spip_auteurs (nom, email, login, pass, htpass, alea_futur, statut) VALUES(\"".$this->firstname." ".$this->lastname."\",\"".$this->email."\",\"".$this->login."\",\"$mdpass\",\"$htpass\",FLOOR(32000*RAND()),\"1comite\")"; - - $mydb=getDoliDBInstance('mysql',ADHERENT_SPIP_SERVEUR,ADHERENT_SPIP_USER,ADHERENT_SPIP_PASS,ADHERENT_SPIP_DB,ADHERENT_SPIP_PORT); - - if (! $mydb->ok) - { - $this->error=$mydb->lasterror(); - return 0; - } - - $result = $mydb->query($query); - if ($result) - { - $mydb->close(); - return 1; - } - else - { - $this->error=$mydb->lasterror(); - return 0; - } - } - } - - /** - * Fonction qui enleve les droits redacteurs dans spip - * - * @return int =0 if KO, >0 if OK - */ - function del_to_spip() - { - if (defined("ADHERENT_USE_SPIP") && ADHERENT_USE_SPIP ==1 && - defined('ADHERENT_SPIP_SERVEUR') && ADHERENT_SPIP_SERVEUR != '' && - defined('ADHERENT_SPIP_USER') && ADHERENT_SPIP_USER != '' && - defined('ADHERENT_SPIP_PASS') && ADHERENT_SPIP_PASS != '' && - defined('ADHERENT_SPIP_DB') && ADHERENT_SPIP_DB != '' - ) - { - $query = "DELETE FROM spip_auteurs WHERE login='".$this->login."'"; - - $mydb=getDoliDBInstance('mysql',ADHERENT_SPIP_SERVEUR,ADHERENT_SPIP_USER,ADHERENT_SPIP_PASS,ADHERENT_SPIP_DB,ADHERENT_SPIP_PORT); - - $result = $mydb->query($query); - if ($result) - { - $mydb->close(); - return 1; - } - else - { - $this->error=$mydb->error(); - return 0; - } - } - } - - /** - * Fonction qui dit si cet utilisateur est un redacteur existant dans spip - * - * @return int 1=exists, 0=does not exists, -1=error - */ - function is_in_spip() - { - if (defined("ADHERENT_USE_SPIP") && ADHERENT_USE_SPIP ==1 && - defined('ADHERENT_SPIP_SERVEUR') && ADHERENT_SPIP_SERVEUR != '' && - defined('ADHERENT_SPIP_USER') && ADHERENT_SPIP_USER != '' && - defined('ADHERENT_SPIP_PASS') && ADHERENT_SPIP_PASS != '' && - defined('ADHERENT_SPIP_DB') && ADHERENT_SPIP_DB != '') - { - $query = "SELECT login FROM spip_auteurs WHERE login='".$this->login."'"; - - $mydb=getDoliDBInstance('mysql',ADHERENT_SPIP_SERVEUR,ADHERENT_SPIP_USER,ADHERENT_SPIP_PASS,ADHERENT_SPIP_DB,ADHERENT_SPIP_PORT); - - if ($mydb->ok) - { - $result = $mydb->query($query); - - if ($result) - { - if ($mydb->num_rows($result)) - { - // nous avons au moins une reponse - $mydb->close($result); - return 1; - } - else - { - // nous n'avons pas de reponse => n'existe pas - $mydb->close($result); - return 0; - } - } - else - { - $this->error=$mydb->error(); - return -1; - } - } - else - { - $this->error="Echec de connexion avec les identifiants ".ADHERENT_SPIP_SERVEUR." ".ADHERENT_SPIP_USER." ".ADHERENT_SPIP_PASS." ".ADHERENT_SPIP_DB; - return -1; - } - } - } - - /** - * Subscribe an email to all mailing-lists - * - * @param array $listes To force mailing-list (string separated with ,) - * @return int <=0 if KO, >0 if OK - */ - function add_to_mailman($listes='') - { - global $conf,$langs,$user; - - dol_syslog(get_class($this)."::add_to_mailman"); - - if (! function_exists("curl_init")) - { - $langs->load("errors"); - $this->error=$langs->trans("ErrorFunctionNotAvailableInPHP","curl_init"); - return -1; - } - - if (! empty($conf->global->ADHERENT_MAILMAN_URL)) - { - if ($listes == '' && ! empty($conf->global->ADHERENT_MAILMAN_LISTS)) - { - $lists=explode(',',$conf->global->ADHERENT_MAILMAN_LISTS); - } - else - { - $lists=explode(',',$listes); - } - 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%/', - '/%PASSWORD%/', - '/%MAILMAN_ADMINPW%/' - ); - $replace = array ( - $list, - $this->email, - $this->pass, - $conf->global->ADHERENT_MAILMAN_ADMINPW - ); - $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/"); - 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 - $result=curl_exec($ch); - dol_syslog($result); - //--- End buffering and clean output - if (curl_error($ch) > 0) - { - // error - return -2; - } - curl_close($ch); - - } - return 1; - } - else - { - $this->error="ADHERENT_MAILMAN_URL not defined"; - return -1; - } - } - - /** - * Unsubscribe an email from all mailing-lists - * Used when a user is resiliated - * - * @param array $listes To force mailing-list (string separated with ,) - * @return int <=0 if KO, >0 if OK - */ - function del_to_mailman($listes='') - { - global $conf,$langs,$user; - - if (! empty($conf->global->ADHERENT_MAILMAN_UNSUB_URL)) - { - if ($listes=='' && ! empty($conf->global->ADHERENT_MAILMAN_LISTS)) - { - $lists=explode(',',$conf->global->ADHERENT_MAILMAN_LISTS); - } - else - { - $lists=explode(',',$listes); - } - 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%/', - '/%PASSWORD%/', - '/%MAILMAN_ADMINPW%/' - ); - $replace = array ( - 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/"); - 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 - $result=curl_exec($ch); - dol_syslog($result); - //--- End buffering and clean output - $rescode=curl_error($ch); - if ($rescode > 0) - { - dol_syslog("Error using CURL : ".$rescode, LOG_ERR); - // error - return -2; - } - curl_close($ch); - - } - return 1; - } - else - { - $this->error="ADHERENT_MAILMAN_UNSUB_URL not defined"; - return -1; - } - } - /** * Return label of a civility of a contact * @@ -1790,10 +1522,10 @@ class Adherent extends CommonObject } /** - * Retourne le libelle du statut d'un adherent (brouillon, valide, resilie) + * Retourne le libelle du statut d'un adherent (brouillon, valide, resilie) * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label */ function getLibStatut($mode=0) { @@ -1801,13 +1533,13 @@ class Adherent extends CommonObject } /** - * Renvoi le libelle d'un statut donne + * Renvoi le libelle d'un statut donne * - * @param int $statut Id statut - * @param int $need_subscription 1 si type adherent avec cotisation, 0 sinon - * @param timestamp $date_end_subscription Date fin adhesion - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label + * @param int $statut Id statut + * @param int $need_subscription 1 si type adherent avec cotisation, 0 sinon + * @param timestamp $date_end_subscription Date fin adhesion + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label */ function LibStatut($statut,$need_subscription,$date_end_subscription,$mode=0) { diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index 7740adcbbe3..3757de048f3 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -604,6 +604,7 @@ if ($user->rights->adherent->supprimer && $action == 'confirm_resign') } } +// SPIP Management if ($user->rights->adherent->supprimer && $action == 'confirm_del_spip' && $confirm == 'yes') { if (! count($object->errors)) @@ -1167,16 +1168,16 @@ if ($rowid && $action != 'edit') // Cree un tableau formulaire $formquestion=array(); - if ($object->email) $formquestion[0]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => ($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL?true:false)); - $ret=$form->form_confirm("fiche.php?rowid=$rowid",$langs->trans("ValidateMember"),$langs->trans("ConfirmValidateMember"),"confirm_valid",$formquestion,1); - if ($ret == 'html') print '
'; + if ($object->email) $formquestion[]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => ($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL?true:false)); + if ($conf->global->ADHERENT_USE_MAILMAN) { $langs->load("mailmanspip"); $formquestion[]=array('type'=>'other','label'=>$langs->transnoentitiesnoconv("SynchroMailManEnabled"),'value'=>''); } + if ($conf->global->ADHERENT_USE_SPIP) { $langs->load("mailmanspip"); $formquestion[]=array('type'=>'other','label'=>$langs->transnoentitiesnoconv("SynchroSpipEnabled"),'value'=>''); } + print $form->formconfirm("fiche.php?rowid=".$rowid,$langs->trans("ValidateMember"),$langs->trans("ConfirmValidateMember"),"confirm_valid",$formquestion,1); } // Confirm send card by mail if ($action == 'sendinfo') { - $ret=$form->form_confirm("fiche.php?rowid=$rowid",$langs->trans("SendCardByMail"),$langs->trans("ConfirmSendCardByMail",$object->email),"confirm_sendinfo",'',0,1); - if ($ret == 'html') print '
'; + print $form->formconfirm("fiche.php?rowid=".$rowid,$langs->trans("SendCardByMail"),$langs->trans("ConfirmSendCardByMail",$object->email),"confirm_sendinfo",'',0,1); } // Confirm resiliate @@ -1536,7 +1537,10 @@ if ($rowid && $action != 'edit') // Action SPIP if ($conf->mailmanspip->enabled && $conf->global->ADHERENT_USE_SPIP) { - $isinspip=$object->is_in_spip(); + include_once(DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php'); + $mailmanspip=new MailmanSpip($db); + + $isinspip=$mailmanspip->is_in_spip($object); if ($isinspip == 1) { print "id&action=del_spip\">".$langs->trans("DeleteIntoSpip")."\n"; diff --git a/htdocs/langs/ar_SA/companies.lang b/htdocs/langs/ar_SA/companies.lang index dcc36b46eaa..08eca262f42 100644 --- a/htdocs/langs/ar_SA/companies.lang +++ b/htdocs/langs/ar_SA/companies.lang @@ -9,7 +9,6 @@ // START - Lines generated via autotranslator.php tool. // Reference language: en_US CHARSET=UTF-8 -ErrorBadEMail=البريد الإلكتروني ل ٪ من الخطأ ErrorCompanyNameAlreadyExists=اسم الشركة ل ٪ موجود بالفعل. اختيار آخر. ErrorPrefixAlreadyExists=بادئة ٪ ق موجود بالفعل. اختيار آخر. ErrorSetACountryFirst=المجموعة الأولى في البلد diff --git a/htdocs/langs/da_DK/companies.lang b/htdocs/langs/da_DK/companies.lang index 50be5b2ab41..f23e1266254 100644 --- a/htdocs/langs/da_DK/companies.lang +++ b/htdocs/langs/da_DK/companies.lang @@ -11,7 +11,6 @@ // START - Lines generated via autotranslator.php tool. // Reference language: en_US CHARSET=UTF-8 -ErrorBadEMail=E-Mail %s er forkert ErrorCompanyNameAlreadyExists=Firmanavn %s eksisterer allerede. Vælg en anden. ErrorPrefixAlreadyExists=Prefix %s eksisterer allerede. Vælg en anden. ErrorSetACountryFirst=Indstil land første diff --git a/htdocs/langs/de_AT/companies.lang b/htdocs/langs/de_AT/companies.lang index b72bfc1dd1a..88127732472 100644 --- a/htdocs/langs/de_AT/companies.lang +++ b/htdocs/langs/de_AT/companies.lang @@ -6,7 +6,6 @@ CHARSET=UTF-8 -ErrorBadEMail=Email-Adresse %s ist ungültig ErrorCompanyNameAlreadyExists=Firmenname %s bereits vorhanden. Bitte wählen Sie einen anderen. ErrorPrefixAlreadyExists=Präfix %s bereits vorhanden. Bitte wählen Sie einen anderen. ErrorSetACountryFirst=Wählen sie zuerst das Land diff --git a/htdocs/langs/en_US/mailmanspip.lang b/htdocs/langs/en_US/mailmanspip.lang new file mode 100644 index 00000000000..8ecec45c79a --- /dev/null +++ b/htdocs/langs/en_US/mailmanspip.lang @@ -0,0 +1,8 @@ +# Dolibarr language file - fr_FR - mailmanspip +CHARSET=UTF-8 +TestSubscribe=Pour tester l'inscription aux listes mailman +TestUnSubscribe=Pour tester la désincritpion aux listes mailman +MailmanCreationSuccess=Appel de l'url de création dans mailman avec succès +MailmanCreationSuccess=Appel de l'url de suppression de mailman avec succès +SynchroMailManEnabled=Une alimentation de Mailman sera réalisée +SynchroSpipEnabled=Une alimentation de Spip sera réalisée \ No newline at end of file diff --git a/htdocs/langs/fa_IR/companies.lang b/htdocs/langs/fa_IR/companies.lang index 5bd25aa2247..dfaa6dd9ddb 100644 --- a/htdocs/langs/fa_IR/companies.lang +++ b/htdocs/langs/fa_IR/companies.lang @@ -9,7 +9,6 @@ // START - Lines generated via autotranslator.php tool. // Reference language: en_US CHARSET=UTF-8 -ErrorBadEMail=البريد الإلكتروني ل ٪ من الخطأ ErrorCompanyNameAlreadyExists=اسم الشركة ل ٪ موجود بالفعل. اختيار آخر. ErrorPrefixAlreadyExists=بادئة ٪ ق موجود بالفعل. اختيار آخر. ErrorSetACountryFirst=المجموعة الأولى في البلد diff --git a/htdocs/langs/fi_FI/companies.lang b/htdocs/langs/fi_FI/companies.lang index e744f2a9a40..73d88348a02 100644 --- a/htdocs/langs/fi_FI/companies.lang +++ b/htdocs/langs/fi_FI/companies.lang @@ -9,7 +9,6 @@ // START - Lines generated via autotranslator.php tool. // Reference language: en_US CHARSET=UTF-8 -ErrorBadEMail=EMail %s on väärä ErrorCompanyNameAlreadyExists=Yrityksen nimi %s on jo olemassa. Valitse toinen. ErrorPrefixAlreadyExists=Etunumero %s on jo olemassa. Valitse toinen. ErrorSetACountryFirst=Aseta ensin maa diff --git a/htdocs/langs/fr_FR/mailmanspip.lang b/htdocs/langs/fr_FR/mailmanspip.lang new file mode 100644 index 00000000000..8ecec45c79a --- /dev/null +++ b/htdocs/langs/fr_FR/mailmanspip.lang @@ -0,0 +1,8 @@ +# Dolibarr language file - fr_FR - mailmanspip +CHARSET=UTF-8 +TestSubscribe=Pour tester l'inscription aux listes mailman +TestUnSubscribe=Pour tester la désincritpion aux listes mailman +MailmanCreationSuccess=Appel de l'url de création dans mailman avec succès +MailmanCreationSuccess=Appel de l'url de suppression de mailman avec succès +SynchroMailManEnabled=Une alimentation de Mailman sera réalisée +SynchroSpipEnabled=Une alimentation de Spip sera réalisée \ No newline at end of file diff --git a/htdocs/langs/it_IT/companies.lang b/htdocs/langs/it_IT/companies.lang index 176990c5a8f..97fe3d9606f 100644 --- a/htdocs/langs/it_IT/companies.lang +++ b/htdocs/langs/it_IT/companies.lang @@ -86,7 +86,6 @@ DolibarrLogin =Dolibarr login EditCompany =Modifica società EditContact =Modifica contatto/indirizzo EditDeliveryAddress =Modifica indirizzo di consegna -ErrorBadEMail =L'email %s è sbagliata ErrorCompanyNameAlreadyExists =Il nome %s esiste già. Scegline un altro. ErrorPrefixAlreadyExists =Prefisso %s già esistente. Scegline un altro. ErrorSetACountryFirst =Impostare prima il paese diff --git a/htdocs/langs/nb_NO/companies.lang b/htdocs/langs/nb_NO/companies.lang index ec245c66ea5..287d2e2c08e 100644 --- a/htdocs/langs/nb_NO/companies.lang +++ b/htdocs/langs/nb_NO/companies.lang @@ -1,6 +1,5 @@ # Dolibarr language file - no_NB - companies CHARSET=UTF-8 -ErrorBadEMail=E-post %s er feil ErrorCompanyNameAlreadyExists=Firmanavnet %s finnes allerede. Velg et annet! ErrorPrefixAlreadyExists=Prefix %s finnes allered. Velg et annet! ErrorSetACountryFirst=Angi land først diff --git a/htdocs/langs/nl_BE/companies.lang b/htdocs/langs/nl_BE/companies.lang index 2f72f5175c4..bb5513ea6d5 100644 --- a/htdocs/langs/nl_BE/companies.lang +++ b/htdocs/langs/nl_BE/companies.lang @@ -1,6 +1,5 @@ # Dolibarr language file - nl_BE - companies CHARSET=UTF-8 -ErrorBadEMail=EMail %s is verkeerd ErrorCompanyNameAlreadyExists=Bedrijfsnaam %s bestaat reeds. Kies een andere naam. ErrorPrefixAlreadyExists=Prefix %s bestaat reeds. Kies een ander prefix. ErrorSetACountryFirst=Kies het land eerst diff --git a/htdocs/langs/pl_PL/companies.lang b/htdocs/langs/pl_PL/companies.lang index 6f96471db2a..52f9532a120 100644 --- a/htdocs/langs/pl_PL/companies.lang +++ b/htdocs/langs/pl_PL/companies.lang @@ -11,7 +11,6 @@ // START - Lines generated via autotranslator.php tool. // Reference language: en_US CHARSET=UTF-8 -ErrorBadEMail=EMail %s jest błędna ErrorCompanyNameAlreadyExists=Nazwa firmy %s już istnieje. Wybierz inną. ErrorPrefixAlreadyExists=Prefiks %s już istnieje. Wybierz inną. ErrorSetACountryFirst=Ustaw kraj pierwszy diff --git a/htdocs/langs/pt_BR/companies.lang b/htdocs/langs/pt_BR/companies.lang index 2cdef4cf6e5..0e529520a3c 100644 --- a/htdocs/langs/pt_BR/companies.lang +++ b/htdocs/langs/pt_BR/companies.lang @@ -1,6 +1,5 @@ # Dolibarr language file - pt_BR rev. 0.0 - companies CHARSET=UTF-8 -ErrorBadEMail=e-mail %s não está correto ErrorCompanyNameAlreadyExists=o Nome da emprea %s já existe. Indique outro. ErrorPrefixAlreadyExists=o Prefixooo %s já existe. Indique outro. ErrorSetACountryFirst=Defina em primeiro localização o país diff --git a/htdocs/langs/pt_PT/companies.lang b/htdocs/langs/pt_PT/companies.lang index 5b1c39e7651..91805d518c6 100644 --- a/htdocs/langs/pt_PT/companies.lang +++ b/htdocs/langs/pt_PT/companies.lang @@ -1,6 +1,5 @@ # Dolibarr language file - pt_PT - companies CHARSET=UTF-8 -ErrorBadEMail=e-mail %s não está correcto ErrorCompanyNameAlreadyExists=o Nome da emprea %s já existe. Indique outro. ErrorPrefixAlreadyExists=o Prefixo %s já existe. Indique outro. ErrorSetACountryFirst=Defina em primeiro localização o país diff --git a/htdocs/langs/ro_RO/companies.lang b/htdocs/langs/ro_RO/companies.lang index 9e834de164e..cdcc483288e 100644 --- a/htdocs/langs/ro_RO/companies.lang +++ b/htdocs/langs/ro_RO/companies.lang @@ -9,7 +9,6 @@ // START - Lines generated via autotranslator.php tool. // Reference language: en_US CHARSET=UTF-8 -ErrorBadEMail=Email %s este greşit ErrorCompanyNameAlreadyExists=Numele companiei %s există deja. Alegeţi un altul. ErrorPrefixAlreadyExists=Prefix %s există deja. Alegeţi un altul. ErrorSetACountryFirst=Setaţi prima ţară diff --git a/htdocs/langs/ru_RU/companies.lang b/htdocs/langs/ru_RU/companies.lang index 3e2ea05d649..3b0ce3c8b20 100644 --- a/htdocs/langs/ru_RU/companies.lang +++ b/htdocs/langs/ru_RU/companies.lang @@ -9,7 +9,6 @@ // START - Lines generated via autotranslator.php tool. // Reference language: en_US CHARSET=UTF-8 -ErrorBadEMail=EMail %s неверен ErrorCompanyNameAlreadyExists=Название компании %s уже существует. Выберите другое. ErrorPrefixAlreadyExists=Префикс %s уже существует. Выберите другой. ErrorSetACountryFirst=Сначала установите страну diff --git a/htdocs/langs/tr_TR/companies.lang b/htdocs/langs/tr_TR/companies.lang index 0dbdef46205..3c9a65d03bc 100644 --- a/htdocs/langs/tr_TR/companies.lang +++ b/htdocs/langs/tr_TR/companies.lang @@ -8,7 +8,6 @@ // START - Lines generated via autotranslator.php tool (2010-03-15 19:05:26). // Reference language: en_US CHARSET=UTF-8 -ErrorBadEMail=Yanlış EPosta: %s ErrorBadUrl=Yanlış Url: %s ErrorCompanyNameAlreadyExists=Zaten Firma adı% var. Başka bir tane seçin. ErrorPrefixAlreadyExists=Önek% s zaten var. Başka bir tane seçin. diff --git a/htdocs/mailmanspip/class/mailmanspip.class.php b/htdocs/mailmanspip/class/mailmanspip.class.php new file mode 100644 index 00000000000..f565d8d67cd --- /dev/null +++ b/htdocs/mailmanspip/class/mailmanspip.class.php @@ -0,0 +1,358 @@ + + * Copyright (C) 2002-2003 Jean-Louis Bergamo + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2004 Sebastien Di Cintio + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2009 Regis Houssin + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/mailmanspip/class/mailmanspip.class.php + * \ingroup member + * \brief File of class to manage members of a foundation + */ + +require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php"); +require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"); + + +/** + * Class to manage mailman and spip + */ +class MailmanSpip +{ + var $db; + var $error; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + $this->db = $db; + } + + /** + * Fonction qui donne les droits redacteurs dans spip + * + * @param Object $object Object with data (->firstname, ->lastname, ->email and ->login) + * @return int =0 if KO, >0 if OK + */ + function add_to_spip($object) + { + dol_syslog(get_class($this)."::add_to_spip"); + + if (defined("ADHERENT_USE_SPIP") && ADHERENT_USE_SPIP ==1 && + defined('ADHERENT_SPIP_SERVEUR') && ADHERENT_SPIP_SERVEUR != '' && + defined('ADHERENT_SPIP_USER') && ADHERENT_SPIP_USER != '' && + defined('ADHERENT_SPIP_PASS') && ADHERENT_SPIP_PASS != '' && + defined('ADHERENT_SPIP_DB') && ADHERENT_SPIP_DB != '' + ) + { + require_once(DOL_DOCUMENT_ROOT."/core/lib/security2.lib.php"); + $mdpass=dol_hash($object->pass); + $htpass=crypt($object->pass,makesalt()); + $query = "INSERT INTO spip_auteurs (nom, email, login, pass, htpass, alea_futur, statut) VALUES(\"".$object->firstname." ".$object->lastname."\",\"".$object->email."\",\"".$object->login."\",\"$mdpass\",\"$htpass\",FLOOR(32000*RAND()),\"1comite\")"; + + $mydb=getDoliDBInstance('mysql',ADHERENT_SPIP_SERVEUR,ADHERENT_SPIP_USER,ADHERENT_SPIP_PASS,ADHERENT_SPIP_DB,ADHERENT_SPIP_PORT); + + if (! $mydb->ok) + { + $this->error=$mydb->lasterror(); + return 0; + } + + $result = $mydb->query($query); + if ($result) + { + $mydb->close(); + return 1; + } + else + { + $this->error=$mydb->lasterror(); + return 0; + } + } + } + + /** + * Fonction qui enleve les droits redacteurs dans spip + * + * @param Object $object Object with data (->login) + * @return int =0 if KO, >0 if OK + */ + function del_to_spip($object) + { + if (defined("ADHERENT_USE_SPIP") && ADHERENT_USE_SPIP ==1 && + defined('ADHERENT_SPIP_SERVEUR') && ADHERENT_SPIP_SERVEUR != '' && + defined('ADHERENT_SPIP_USER') && ADHERENT_SPIP_USER != '' && + defined('ADHERENT_SPIP_PASS') && ADHERENT_SPIP_PASS != '' && + defined('ADHERENT_SPIP_DB') && ADHERENT_SPIP_DB != '' + ) + { + $query = "DELETE FROM spip_auteurs WHERE login='".$object->login."'"; + + $mydb=getDoliDBInstance('mysql',ADHERENT_SPIP_SERVEUR,ADHERENT_SPIP_USER,ADHERENT_SPIP_PASS,ADHERENT_SPIP_DB,ADHERENT_SPIP_PORT); + + $result = $mydb->query($query); + if ($result) + { + $mydb->close(); + return 1; + } + else + { + $this->error=$mydb->lasterror(); + $mydb->close(); + return 0; + } + } + } + + /** + * Fonction qui dit si cet utilisateur est un redacteur existant dans spip + * + * @param Object $object Object with data (->login) + * @return int 1=exists, 0=does not exists, -1=error + */ + function is_in_spip($object) + { + if (defined("ADHERENT_USE_SPIP") && ADHERENT_USE_SPIP ==1 && + defined('ADHERENT_SPIP_SERVEUR') && ADHERENT_SPIP_SERVEUR != '' && + defined('ADHERENT_SPIP_USER') && ADHERENT_SPIP_USER != '' && + defined('ADHERENT_SPIP_PASS') && ADHERENT_SPIP_PASS != '' && + defined('ADHERENT_SPIP_DB') && ADHERENT_SPIP_DB != '') + { + $query = "SELECT login FROM spip_auteurs WHERE login='".$object->login."'"; + + $mydb=getDoliDBInstance('mysql',ADHERENT_SPIP_SERVEUR,ADHERENT_SPIP_USER,ADHERENT_SPIP_PASS,ADHERENT_SPIP_DB,ADHERENT_SPIP_PORT); + + if ($mydb->ok) + { + $result = $mydb->query($query); + + if ($result) + { + if ($mydb->num_rows($result)) + { + // nous avons au moins une reponse + $mydb->close($result); + return 1; + } + else + { + // nous n'avons pas de reponse => n'existe pas + $mydb->close($result); + return 0; + } + } + else + { + $this->error=$mydb->lasterror(); + $mydb->close(); + return -1; + } + } + else + { + $this->error="Failed to connect ".ADHERENT_SPIP_SERVEUR." ".ADHERENT_SPIP_USER." ".ADHERENT_SPIP_PASS." ".ADHERENT_SPIP_DB; + return -1; + } + } + } + + /** + * Subscribe an email to all mailing-lists + * + * @param Object $object Object with data (->email, ->pass, ->element, ->type) + * @param array $listes To force mailing-list (string separated with ,) + * @return int <0 if KO, >=0 if OK + */ + function add_to_mailman($object,$listes='') + { + global $conf,$langs,$user; + + dol_syslog(get_class($this)."::add_to_mailman"); + + if (! function_exists("curl_init")) + { + $langs->load("errors"); + $this->error=$langs->trans("ErrorFunctionNotAvailableInPHP","curl_init"); + return -1; + } + + if (! empty($conf->global->ADHERENT_MAILMAN_URL)) + { + if ($listes == '' && ! empty($conf->global->ADHERENT_MAILMAN_LISTS)) + { + $lists=explode(',',$conf->global->ADHERENT_MAILMAN_LISTS); + } + else + { + $lists=explode(',',$listes); + } + foreach ($lists as $list) + { + // Filter on type something (ADHERENT_MAILMAN_LISTS = "filtervalue:mailinglist1,filtervalue2:mailinglist2,mailinglist3") + $tmp=explode(':',$list); + if (! empty($tmp[1])) + { + $list=$tmp[1]; + if ($object->element == 'member' && $object->type != $tmp[0]) // Filter on member type label + { + dol_syslog("We ignore list ".$list." because object member type ".$object->type." does not match ".$tmp[0], LOG_DEBUG); + continue; + } + } + + // on remplace dans l'url le nom de la liste ainsi + // que l'email et le mot de passe + $patterns = array ( + '/%LISTE%/', + '/%EMAIL%/', + '/%PASSWORD%/', + '/%MAILMAN_ADMINPW%/' + ); + $replace = array ( + $list, + $object->email, + $object->pass, + $conf->global->ADHERENT_MAILMAN_ADMINPW + ); + $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/"); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_FAILONERROR, true); + @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 + $result=curl_exec($ch); + dol_syslog('result curl_exec='.$result); + //--- End buffering and clean output + if ($result === false || curl_errno($ch) > 0) + { + // error + $this->error=curl_errno($ch).' '.curl_error($ch); + dol_syslog('Error using curl '.$this->error, LOG_ERR); + return -2; + } + curl_close($ch); + } + return count($lists); + } + else + { + $this->error="ADHERENT_MAILMAN_URL not defined"; + return -1; + } + } + + /** + * Unsubscribe an email from all mailing-lists + * Used when a user is resiliated + * + * @param Object $object Object with data (->email, ->pass, ->element, ->type) + * @param array $listes To force mailing-list (string separated with ,) + * @return int <0 if KO, >=0 if OK + */ + function del_to_mailman($object,$listes='') + { + global $conf,$langs,$user; + + if (! empty($conf->global->ADHERENT_MAILMAN_UNSUB_URL)) + { + if ($listes=='' && ! empty($conf->global->ADHERENT_MAILMAN_LISTS)) + { + $lists=explode(',',$conf->global->ADHERENT_MAILMAN_LISTS); + } + else + { + $lists=explode(',',$listes); + } + foreach ($lists as $list) + { + // Filter on type something (ADHERENT_MAILMAN_LISTS = "filtervalue:mailinglist1,filtervalue2:mailinglist2,mailinglist3") + $tmp=explode(':',$list); + if (! empty($tmp[1])) + { + if ($object->element == 'member' && $object->type != $tmp[1]) // Filter on member type label + { + continue; + } + } + + // on remplace dans l'url le nom de la liste ainsi + // que l'email et le mot de passe + $patterns = array ( + '/%LISTE%/', + '/%EMAIL%/', + '/%PASSWORD%/', + '/%MAILMAN_ADMINPW%/' + ); + $replace = array ( + trim($list), + $object->email, + $object->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/"); + 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 + $result=curl_exec($ch); + dol_syslog($result); + //--- End buffering and clean output + if ($result === false || curl_errno($ch) > 0) + { + $this->error=curl_errno($ch).' '.curl_error($ch); + dol_syslog('Error using curl '.$this->error, LOG_ERR); + // error + return -2; + } + curl_close($ch); + } + return count($lists); + } + else + { + $this->error="ADHERENT_MAILMAN_UNSUB_URL not defined"; + return -1; + } + } + +} +?>