Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2012-08-28 09:33:58 +02:00
commit 562e2b6a7b
6 changed files with 245 additions and 172 deletions

View File

@ -3,6 +3,7 @@
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
*
* 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
@ -40,7 +41,7 @@ $langs->load("companies");
$langs->load("bills");
$langs->load("members");
$langs->load("users");
$langs->load('other');
$action=GETPOST('action','alpha');
$backtopage=GETPOST('backtopage','alpha');
@ -53,6 +54,15 @@ $socid=GETPOST('socid','int');
// Security check
$result=restrictedArea($user,'adherent',$rowid);
if ($conf->mailmanspip->enabled)
{
include_once DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php';
$langs->load('mailmanspip');
$mailmanspip = new MailmanSpip($db);
}
$object = new Adherent($db);
$extrafields = new ExtraFields($db);
@ -632,9 +642,9 @@ if ($user->rights->adherent->supprimer && $action == 'confirm_del_spip' && $conf
{
if (! count($object->errors))
{
if(!$object->del_to_spip())
if (!$mailmanspip->del_to_spip($object))
{
$errmsg.="Echec de la suppression de l'utilisateur dans spip: ".$object->error."<BR>\n";
$errmsg.= $langs->trans('DeleteIntoSpipError').': '.$mailmanspip->error."<BR>\n";
}
}
}
@ -643,9 +653,9 @@ if ($user->rights->adherent->creer && $action == 'confirm_add_spip' && $confirm
{
if (! count($object->errors))
{
if (!$object->add_to_spip())
if (!$mailmanspip->add_to_spip($object))
{
$errmsg.="Echec du rajout de l'utilisateur dans spip: ".$object->error."<BR>\n";
$errmsg.= $langs->trans('AddIntoSpipError').': '.$mailmanspip->error."<BR>\n";
}
}
}
@ -1194,8 +1204,8 @@ if ($rowid && $action != 'edit')
// Cree un tableau formulaire
$formquestion=array();
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'=>''); }
if ($conf->global->ADHERENT_USE_MAILMAN) { $formquestion[]=array('type'=>'other','label'=>$langs->transnoentitiesnoconv("SynchroMailManEnabled"),'value'=>''); }
if ($conf->global->ADHERENT_USE_SPIP) { $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);
}
@ -1251,8 +1261,7 @@ if ($rowid && $action != 'edit')
*/
if ($action == 'add_spip')
{
$langs->load("mailmanspip");
$ret=$form->form_confirm("fiche.php?rowid=".$rowid,"Add to spip","Etes-vous sur de vouloir ajouter cet adherent dans spip ? (serveur : ".ADHERENT_SPIP_SERVEUR.")","confirm_add_spip");
$ret=$form->form_confirm("fiche.php?rowid=".$rowid, $langs->trans('AddIntoSpip'), $langs->trans('AddIntoSpipConfirmation'), 'confirm_add_spip');
if ($ret == 'html') print '<br>';
}
@ -1261,8 +1270,7 @@ if ($rowid && $action != 'edit')
*/
if ($action == 'del_spip')
{
$langs->load("mailmanspip");
$ret=$form->form_confirm("fiche.php?rowid=$rowid","Supprimer dans spip","Etes-vous sur de vouloir effacer cet adherent dans spip ? (serveur : ".ADHERENT_SPIP_SERVEUR.")","confirm_del_spip");
$ret=$form->form_confirm("fiche.php?rowid=$rowid", $langs->trans('DeleteIntoSpip'), $langs->trans('DeleteIntoSpipConfirmation'), 'confirm_del_spip');
if ($ret == 'html') print '<br>';
}
@ -1564,10 +1572,8 @@ if ($rowid && $action != 'edit')
// Action SPIP
if ($conf->mailmanspip->enabled && $conf->global->ADHERENT_USE_SPIP)
{
include_once DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php';
$mailmanspip=new MailmanSpip($db);
$isinspip = $mailmanspip->is_in_spip($object);
$isinspip=$mailmanspip->is_in_spip($object);
if ($isinspip == 1)
{
print "<a class=\"butAction\" href=\"fiche.php?rowid=$object->id&action=del_spip\">".$langs->trans("DeleteIntoSpip")."</a>\n";
@ -1578,7 +1584,7 @@ if ($rowid && $action != 'edit')
}
if ($isinspip == -1)
{
print '<br><br><font class="error">Failed to connect to SPIP: '.$object->error.'</font>';
print '<br><br><font class="error">'.$langs->trans('SPIPConnectionFailed').': '.$mailmanspip->error.'</font>';
}
}

View File

@ -218,7 +218,9 @@ $(document).ready(function() {
$('#service_duration_area').hide();
$('#idprod').change(function() {
if ($(this).val() > 0) {
if (typeof CKEDITOR == 'object' && typeof CKEDITOR.instances != 'undefined' && CKEDITOR.instances['product_desc'] != 'undefined') {
// We use CKEditor
CKEDITOR.instances['product_desc'].focus();
@ -226,6 +228,7 @@ $(document).ready(function() {
// We use a simple textarea
$('#product_desc').focus();
}
// For compatibility with combobox
<?php if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) { ?>
$.post('<?php echo DOL_URL_ROOT; ?>/product/ajax/products.php', {
@ -235,13 +238,13 @@ $(document).ready(function() {
},
function(data) {
if (typeof data != 'undefined') {
$('#select_type').val(data.type).attr('disabled','disabled');
$('#select_type').val(data.type).attr('disabled','disabled').trigger('change');
$('#product_ref').val(data.ref);
$('#product_label').val(data.label).attr('disabled','disabled');
$('#origin_label_cache').val(data.label);
$('#origin_desc_cache').val(data.desc);
$('#price_base_type').val(data.pricebasetype);
$('#price_ht').val(data.price_ht).attr('disabled','disabled');
$('#price_ht').val(data.price_ht);
$('#origin_price_ht_cache').val(data.price_ht);
$('#update_label_area').show().trigger('show');
$('#update_desc_area').show().trigger('show');
@ -249,23 +252,28 @@ $(document).ready(function() {
}
}, 'json');
<?php } ?>
} else {
$('#update_desc_checkbox').removeAttr('checked').trigger('change');
$('#update_price_checkbox').removeAttr('checked').trigger('change');
$('#update_price_checkbox').removeAttr('checked');
$('#price_ttc').val('');
// For compatibility with combobox
<?php if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) { ?>
$('#select_type').val('').removeAttr('disabled');
$('#select_type').val('').removeAttr('disabled').trigger('change');
$('#product_ref').val('');
$('#product_label').val('').removeAttr('disabled');
$('#origin_label_cache').val('');
$('#origin_desc_cache').val('');
$('#price_base_type').val('');
$('#price_ht').val('').removeAttr('disabled');
$('#price_ht').val('').trigger('change');
$('#origin_price_ht_cache').val('');
$('#price_base_type').val('');
$('#update_label_area').hide().trigger('hide');
$('#update_desc_area').hide().trigger('hide');
$('#update_price_area').hide().trigger('hide');
<?php } ?>
}
});
@ -285,7 +293,7 @@ $(document).ready(function() {
$('#service_duration_area').show();
}
//$('#add_product_area').show(); // TODO for add product card
if (($('#price_ht').val().length > 0) || ($('#price_ttc').val().length > 0)) {
if ($('#price_ht').val().length > 0 || $('#price_ttc').val().length > 0) {
$('#addlinebutton').removeAttr('disabled');
} else {
$('#addlinebutton').attr('disabled','disabled');
@ -411,7 +419,7 @@ $(document).ready(function() {
});
$('#price_ht').bind('change keyup input', function() {
if ($('#tva_tx').val() > 0 && ($('#idprod').val().length == 0 && $('#price_base_type').val() == 'HT') || $('#idprod').val().length > 0) {
if ($('#tva_tx').val() > 0 && (($('#idprod').val() == 0 && $('#price_base_type').val() == 'HT') || $('#idprod').val() > 0)) {
update_price('price_ht', 'price_ttc');
}
});
@ -435,7 +443,7 @@ $(document).ready(function() {
$('#price_ttc').attr('disabled','disabled');
$('#price_ttc').val('');
} else {
if ($('#idprod').val().length == 0 || ($('#idprod').val().length > 0 && $('#update_price_checkbox').attr('checked') == 'checked')) {
if ($('#idprod').val() == 0 || ($('#idprod').val() > 0 && $('#update_price_checkbox').attr('checked') == 'checked')) {
$('#price_ttc').removeAttr('disabled');
}
if ($('#price_base_type').val() == 'HT') {

View File

@ -16,4 +16,11 @@ SPIPTitle=SPIP Content Management System
DescADHERENT_SPIP_SERVEUR=SPIP Server
DescADHERENT_SPIP_DB=SPIP database name
DescADHERENT_SPIP_USER=SPIP database login
DescADHERENT_SPIP_PASS=SPIP database password
DescADHERENT_SPIP_PASS=SPIP database password
AddIntoSpip=Add into SPIP
AddIntoSpipConfirmation=Are you sure you want to add this member into SPIP?
AddIntoSpipError=Failed to add the user in SPIP
DeleteIntoSpip=Remove from SPIP
DeleteIntoSpipConfirmation=Are you sure you want to remove this member from SPIP?
DeleteIntoSpipError=Failed to suppress the user from SPIP
SPIPConnectionFailed=Failed to connect to SPIP

View File

@ -16,4 +16,11 @@ SPIPTitle=Sistema de gestión de contenidos SPIP
DescADHERENT_SPIP_SERVEUR=Servidor SPIP
DescADHERENT_SPIP_DB=Nombre de la base de datos de SPIP
DescADHERENT_SPIP_USER=Usuario de la base de datos de SPIP
DescADHERENT_SPIP_PASS=Contraseña de la base de datos de SPIP
DescADHERENT_SPIP_PASS=Contraseña de la base de datos de SPIP
AddIntoSpip=Añadir a SPIP
AddIntoSpipConfirmation=¿Está seguro de querer añadir este miembro a SPIP?
AddIntoSpipError=Ha ocurrido un error al añadir el miembro a SPIP
DeleteIntoSpip=Borrar de SPIP
DeleteIntoSpipConfirmation=¿Está seguro de querer borrar este miembro de SPIP?
DeleteIntoSpipError=Ha ocurrido un error al borrar el miembro de SPIP
SPIPConnectionFailed=Error al conectar con SPIP

View File

@ -15,4 +15,11 @@ SPIPTitle=Gestion de contenu SPIP
DescADHERENT_SPIP_SERVEUR=Serveur SPIP
DescADHERENT_SPIP_DB=Nom base SPIP
DescADHERENT_SPIP_USER=Login connexion base SPIP
DescADHERENT_SPIP_PASS=Mot de passe connexion base SPIP
DescADHERENT_SPIP_PASS=Mot de passe connexion base SPIP
AddIntoSpip=Ajouter dans SPIP
AddIntoSpipConfirmation=Êtes-vous sur de vouloir ajouter cet adhérent dans SPIP?
AddIntoSpipError=Echec du rajout de l'utilisateur dans SPIP
DeleteIntoSpip=Supprimer de spip
DeleteIntoSpipConfirmation=Êtes-vous sur de vouloir effacer cet adhérent de SPIP?
DeleteIntoSpipError=Échec de la suppression de l'utilisateur de SPIP
SPIPConnectionFailed=Échec de connexion à SPIP

View File

@ -5,6 +5,7 @@
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
*
* 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
@ -50,6 +51,104 @@ class MailmanSpip
$this->db = $db;
}
/**
* Function used to check if SPIP is enabled on the system
* @return boolean
*/
function isSpipEnabled()
{
if (defined("ADHERENT_USE_SPIP") && (ADHERENT_USE_SPIP == 1))
{
return true;
}
return false;
}
/**
* Function used to check if the SPIP config is correct
* @return boolean
*/
function checkSpipConfig()
{
if (defined('ADHERENT_SPIP_SERVEUR') && defined('ADHERENT_SPIP_USER') && defined('ADHERENT_SPIP_PASS') && defined('ADHERENT_SPIP_DB'))
{
if (ADHERENT_SPIP_SERVEUR != '' && ADHERENT_SPIP_USER != '' && ADHERENT_SPIP_PASS != '' && ADHERENT_SPIP_DB != '')
{
return true;
}
}
return false;
}
/**
* Function used to connect to SPIP
* @return boolean|DoliDB
*/
function connectSpip()
{
$resource = getDoliDBInstance('mysql', ADHERENT_SPIP_SERVEUR, ADHERENT_SPIP_USER, ADHERENT_SPIP_PASS, ADHERENT_SPIP_DB, ADHERENT_SPIP_PORT);
if ($resource->ok)
{
return $resource;
}
dol_syslog('Error when connecting to SPIP '.ADHERENT_SPIP_SERVEUR.' '.ADHERENT_SPIP_USER.' '.ADHERENT_SPIP_PASS.' '.ADHERENT_SPIP_DB, LOG_ERR);
return false;
}
/**
* Function used to connect to Mailman
* @param object $object Object with the data
* @param string $url Mailman URL to be called with patterns
* @return boolean|string
*/
function callMailman($object, $url)
{
global $conf;
//Patterns that are going to be replaced with their original value
$patterns = array(
'%LISTE%',
'%EMAIL%',
'%PASSWORD%',
'%MAILMAN_ADMINPW%'
);
$replace = array(
$list,
$object->email,
$object->pass,
$conf->global->ADHERENT_MAILMAN_ADMINPW
);
$curl_url = str_replace($patterns, $replace, $url);
dol_syslog('Calling Mailman: '.$curl_url);
$ch = curl_init($curl_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
$result = curl_exec($ch);
dol_syslog('result curl_exec='.$result);
//An error was found, we store it in $this->error for later
if ($result === false || curl_errno($ch) > 0)
{
$this->error = curl_errno($ch).' '.curl_error($ch);
dol_syslog('Error using curl '.$this->error, LOG_ERR);
}
curl_close($ch);
return $result;
}
/**
* Fonction qui donne les droits redacteurs dans spip
*
@ -60,38 +159,36 @@ class MailmanSpip
{
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 != ''
)
if ($this->isSpipEnabled())
{
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)
if ($this->checkSpipConfig())
{
$this->error=$mydb->lasterror();
return 0;
}
$mydb = $this->connectSpip();
$result = $mydb->query($query);
if ($result)
{
$mydb->close();
return 1;
}
else
{
$this->error=$mydb->lasterror();
return 0;
if ($mydb)
{
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\")";
$result = $mydb->query($query);
$mydb->close();
if ($result)
{
return 1;
}
else $this->error = $mydb->lasterror();
}
else $this->error = 'Failed to connect to SPIP';
}
else $this->error = 'BadSPIPConfiguration';
}
else $this->error = 'SPIPNotEnabled';
return 0;
}
/**
@ -102,30 +199,35 @@ class MailmanSpip
*/
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 != ''
)
dol_syslog(get_class($this)."::del_to_spip");
if ($this->isSpipEnabled())
{
$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)
if ($this->checkSpipConfig())
{
$mydb->close();
return 1;
}
else
{
$this->error=$mydb->lasterror();
$mydb->close();
return 0;
$mydb = $this->connectSpip();
if ($mydb)
{
$query = "DELETE FROM spip_auteurs WHERE login='".$object->login."'";
$result = $mydb->query($query);
$mydb->close();
if ($result)
{
return 1;
}
else $this->error = $mydb->lasterror();
}
else $this->error = 'Failed to connect to SPIP';
}
else $this->error = 'BadSPIPConfiguration';
}
else $this->error = 'SPIPNotEnabled';
return 0;
}
/**
@ -136,48 +238,46 @@ class MailmanSpip
*/
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 != '')
if ($this->isSpipEnabled())
{
$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)
if ($this->checkSpipConfig())
{
$result = $mydb->query($query);
$mydb = $this->connectSpip();
if ($result)
if ($mydb)
{
if ($mydb->num_rows($result))
$query = "SELECT login FROM spip_auteurs WHERE login='".$object->login."'";
$result = $mydb->query($query);
if ($result)
{
// nous avons au moins une reponse
$mydb->close($result);
return 1;
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
{
// nous n'avons pas de reponse => n'existe pas
$mydb->close($result);
return 0;
$this->error = $mydb->lasterror();
$mydb->close();
}
}
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;
else $this->error = 'Failed to connect to SPIP';
}
else $this->error = 'BadSPIPConfiguration';
}
else $this->error = 'SPIPNotEnabled';
return -1;
}
/**
@ -224,44 +324,13 @@ class MailmanSpip
}
}
// 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);
//We call Mailman to subscribe the user
$result = $this->callMailman($object, $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)
if ($result === false)
{
// 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);
}
@ -306,44 +375,13 @@ class MailmanSpip
}
}
// 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);
//We call Mailman to unsubscribe the user
$result = $this->callMailman($object, $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)
if ($result === false)
{
$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);
}