31 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
55 public $errors = array();
80 if (defined(
"ADHERENT_USE_SPIP") && (ADHERENT_USE_SPIP == 1)) {
94 if (defined(
'ADHERENT_SPIP_SERVEUR') && defined(
'ADHERENT_SPIP_USER') && defined(
'ADHERENT_SPIP_PASS') && defined(
'ADHERENT_SPIP_DB')) {
95 if (ADHERENT_SPIP_SERVEUR !=
'' && ADHERENT_SPIP_USER !=
'' && ADHERENT_SPIP_PASS !=
'' && ADHERENT_SPIP_DB !=
'') {
110 $resource =
getDoliDBInstance(
'mysql', ADHERENT_SPIP_SERVEUR, ADHERENT_SPIP_USER, ADHERENT_SPIP_PASS, ADHERENT_SPIP_DB, ADHERENT_SPIP_PORT);
116 dol_syslog(
'Error when connecting to SPIP '.ADHERENT_SPIP_SERVEUR.
' '.ADHERENT_SPIP_USER.
' '.ADHERENT_SPIP_PASS.
' '.ADHERENT_SPIP_DB, LOG_ERR);
144 $conf->global->ADHERENT_MAILMAN_ADMINPW
147 $curl_url = str_replace($patterns, $replace, $url);
152 return $result[
'content'];
172 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
174 $htpass = crypt($object->pass,
makesalt());
175 $query =
"INSERT INTO spip_auteurs (nom, email, login, pass, htpass, alea_futur, statut) VALUES(\"".dolGetFirstLastname($object->firstname, $object->lastname).
"\",\"".$object->email.
"\",\"".$object->login.
"\",\"$mdpass\",\"$htpass\",FLOOR(32000*RAND()),\"1comite\")";
177 $result = $mydb->query($query);
184 $this->error = $mydb->lasterror();
187 $this->error =
'Failed to connect to SPIP';
190 $this->error =
'BadSPIPConfiguration';
193 $this->error =
'SPIPNotEnabled';
216 $query =
"DELETE FROM spip_auteurs WHERE login = '".$mydb->escape($object->login).
"'";
218 $result = $mydb->query($query);
225 $this->error = $mydb->lasterror();
228 $this->error =
'Failed to connect to SPIP';
231 $this->error =
'BadSPIPConfiguration';
234 $this->error =
'SPIPNotEnabled';
255 $query =
"SELECT login FROM spip_auteurs WHERE login = '".$mydb->escape($object->login).
"'";
257 $result = $mydb->query($query);
260 if ($mydb->num_rows($result)) {
270 $this->error = $mydb->lasterror();
274 $this->error =
'Failed to connect to SPIP';
277 $this->error =
'BadSPIPConfiguration';
280 $this->error =
'SPIPNotEnabled';
297 global $conf, $langs, $user;
299 dol_syslog(get_class($this).
"::add_to_mailman");
301 $this->mladded_ok = array();
302 $this->mladded_ko = array();
304 if (!function_exists(
"curl_init")) {
305 $langs->load(
"errors");
306 $this->error = $langs->trans(
"ErrorFunctionNotAvailableInPHP",
"curl_init");
310 if ($conf->adherent->enabled) {
311 if (!empty($conf->global->ADHERENT_MAILMAN_URL)) {
312 if ($listes ==
'' && !empty($conf->global->ADHERENT_MAILMAN_LISTS)) {
313 $lists = explode(
',', $conf->global->ADHERENT_MAILMAN_LISTS);
315 $lists = explode(
',', $listes);
320 foreach ($lists as $list) {
322 $tmp = explode(
':', $list);
323 if (!empty($tmp[2])) {
325 if ($object->element ==
'member' && $tmp[0] ==
'TYPE' && $object->type != $tmp[1]) {
326 dol_syslog(
"We ignore list ".$list.
" because object member type ".$object->type.
" does not match ".$tmp[1], LOG_DEBUG);
329 if ($object->element ==
'member' && $tmp[0] ==
'CATEG' && !in_array($tmp[1], $categstatic->containing($object->id,
'member',
'label'))) {
330 dol_syslog(
"We ignore list ".$list.
" because object member is not into category ".$tmp[1], LOG_DEBUG);
336 $result = $this->
callMailman($object, $conf->global->ADHERENT_MAILMAN_URL, $list);
338 if ($result ===
false) {
339 $this->mladded_ko[$list] = $object->email;
342 $this->mladded_ok[$list] = $object->email;
345 return count($lists);
347 $this->error =
"ADHERENT_MAILMAN_URL not defined";
365 global $conf, $langs, $user;
367 dol_syslog(get_class($this).
"::del_to_mailman");
369 $this->mlremoved_ok = array();
370 $this->mlremoved_ko = array();
372 if (!function_exists(
"curl_init")) {
373 $langs->load(
"errors");
374 $this->error = $langs->trans(
"ErrorFunctionNotAvailableInPHP",
"curl_init");
378 if ($conf->adherent->enabled) {
379 if (!empty($conf->global->ADHERENT_MAILMAN_UNSUB_URL)) {
380 if ($listes ==
'' && !empty($conf->global->ADHERENT_MAILMAN_LISTS)) {
381 $lists = explode(
',', $conf->global->ADHERENT_MAILMAN_LISTS);
383 $lists = explode(
',', $listes);
388 foreach ($lists as $list) {
390 $tmp = explode(
':', $list);
391 if (!empty($tmp[2])) {
393 if ($object->element ==
'member' && $tmp[0] ==
'TYPE' && $object->type != $tmp[1]) {
394 dol_syslog(
"We ignore list ".$list.
" because object member type ".$object->type.
" does not match ".$tmp[1], LOG_DEBUG);
397 if ($object->element ==
'member' && $tmp[0] ==
'CATEG' && !in_array($tmp[1], $categstatic->containing($object->id,
'member',
'label'))) {
398 dol_syslog(
"We ignore list ".$list.
" because object member is not into category ".$tmp[1], LOG_DEBUG);
404 $result = $this->
callMailman($object, $conf->global->ADHERENT_MAILMAN_UNSUB_URL, $list);
406 if ($result ===
false) {
407 $this->mlremoved_ko[$list] = $object->email;
410 $this->mlremoved_ok[$list] = $object->email;
413 return count($lists);
415 $this->error =
"ADHERENT_MAILMAN_UNSUB_URL not defined";