31require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
55 public $errors = array();
146 require_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
161 $curl_url = str_replace($patterns, $replace, $url);
166 return $result[
'content'];
186 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
190 $query =
"INSERT INTO spip_auteurs (nom, email, login, pass, htpass, alea_futur, statut)";
192 $query .=
" '".$mydb->escape(
$object->login).
"', '".$mydb->escape($mdpass).
"', '".$mydb->escape($htpass).
"', FLOOR(32000*RAND()), '1comite')";
194 $result = $mydb->query($query);
201 $this->error = $mydb->lasterror();
204 $this->error =
'Failed to connect to SPIP';
207 $this->error =
'BadSPIPConfiguration';
210 $this->error =
'SPIPNotEnabled';
233 $query =
"DELETE FROM spip_auteurs WHERE login = '".$mydb->escape(
$object->login).
"'";
235 $result = $mydb->query($query);
242 $this->error = $mydb->lasterror();
245 $this->error =
'Failed to connect to SPIP';
248 $this->error =
'BadSPIPConfiguration';
251 $this->error =
'SPIPNotEnabled';
272 $query =
"SELECT login FROM spip_auteurs WHERE login = '".$mydb->escape(
$object->login).
"'";
274 $result = $mydb->query($query);
277 if ($mydb->num_rows($result)) {
287 $this->error = $mydb->lasterror();
291 $this->error =
'Failed to connect to SPIP';
294 $this->error =
'BadSPIPConfiguration';
297 $this->error =
'SPIPNotEnabled';
314 global $conf, $langs, $user;
316 dol_syslog(get_class($this).
"::add_to_mailman");
318 $this->mladded_ok = array();
319 $this->mladded_ko = array();
321 if (!function_exists(
"curl_init")) {
322 $langs->load(
"errors");
323 $this->error = $langs->trans(
"ErrorFunctionNotAvailableInPHP",
"curl_init");
327 if (isModEnabled(
'member')) {
332 $lists = explode(
',', $listes);
337 foreach ($lists as $list) {
339 $tmp = explode(
':', $list);
340 if (!empty($tmp[2])) {
342 if (
$object->element ==
'member' && $tmp[0] ==
'TYPE' &&
$object->type != $tmp[1]) {
343 dol_syslog(
"We ignore list ".$list.
" because object member type ".
$object->type.
" does not match ".$tmp[1], LOG_DEBUG);
346 if (
$object->element ==
'member' && $tmp[0] ==
'CATEG' && !in_array($tmp[1], $categstatic->containing(
$object->id,
'member',
'label'))) {
347 dol_syslog(
"We ignore list ".$list.
" because object member is not into category ".$tmp[1], LOG_DEBUG);
355 if ($result ===
false) {
356 $this->mladded_ko[$list] =
$object->email;
359 $this->mladded_ok[$list] =
$object->email;
362 return count($lists);
364 $this->error =
"ADHERENT_MAILMAN_URL not defined";
384 global $conf, $langs, $user;
386 dol_syslog(get_class($this).
"::del_to_mailman");
388 $this->mlremoved_ok = array();
389 $this->mlremoved_ko = array();
391 if (!function_exists(
"curl_init")) {
392 $langs->load(
"errors");
393 $this->error = $langs->trans(
"ErrorFunctionNotAvailableInPHP",
"curl_init");
397 if (isModEnabled(
'member')) {
402 $lists = explode(
',', $listes);
407 foreach ($lists as $list) {
409 $tmp = explode(
':', $list);
410 if (!empty($tmp[2])) {
412 if (
$object->element ==
'member' && $tmp[0] ==
'TYPE' &&
$object->type != $tmp[1]) {
413 dol_syslog(
"We ignore list ".$list.
" because object member type ".
$object->type.
" does not match ".$tmp[1], LOG_DEBUG);
416 if (
$object->element ==
'member' && $tmp[0] ==
'CATEG' && !in_array($tmp[1], $categstatic->containing(
$object->id,
'member',
'label'))) {
417 dol_syslog(
"We ignore list ".$list.
" because object member is not into category ".$tmp[1], LOG_DEBUG);
423 $result = $this->
callMailman(
$object, $conf->global->ADHERENT_MAILMAN_UNSUB_URL, $list);
425 if ($result ===
false) {
426 $this->mlremoved_ko[$list] =
$object->email;
429 $this->mlremoved_ok[$list] =
$object->email;
432 return count($lists);
434 $this->error =
"ADHERENT_MAILMAN_UNSUB_URL not defined";
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Class to manage categories.
Class to manage mailman and spip.
del_to_mailman($object, $listes='')
Unsubscribe an email from all mailing-lists Used when a user is resiliated.
add_to_mailman($object, $listes='')
Subscribe an email to all mailing-lists.
del_to_spip($object)
Fonction qui enleve les droits redacteurs dans spip.
connectSpip()
Function used to connect to SPIP.
checkSpipConfig()
Function used to check if the SPIP config is correct.
callMailman($object, $url, $list)
Function used to connect to Mailman.
add_to_spip($object)
Fonction qui donne les droits redacteurs dans spip.
__construct($db)
Constructor.
isSpipEnabled()
Function used to check if SPIP is enabled on the system.
is_in_spip($object)
Indicate if the user is an existing editor in spip.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getDoliDBInstance($type, $host, $user, $pass, $name, $port)
Return a DoliDB instance (database handler).
getURLContent($url, $postorget='GET', $param='', $followlocation=1, $addheaders=array(), $allowedschemes=array('http', 'https'), $localurl=0, $ssl_verifypeer=-1)
Function to get a content from an URL (use proxy if proxy defined).
if(!function_exists( 'dol_loginfunction')) makesalt($type=CRYPT_SALT_LENGTH)
Initialise the salt for the crypt function.
dol_hash($chain, $type='0', $nosalt=0)
Returns a hash (non reversible encryption) of a string.