32require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
56 public $errors = array();
147 require_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
162 $curl_url = str_replace($patterns, $replace, $url);
167 return $result[
'content'];
187 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
191 $query =
"INSERT INTO spip_auteurs (nom, email, login, pass, htpass, alea_futur, statut)";
193 $query .=
" '".$mydb->escape(
$object->login).
"', '".$mydb->escape($mdpass).
"', '".$mydb->escape($htpass).
"', FLOOR(32000*RAND()), '1comite')";
195 $result = $mydb->query($query);
202 $this->error = $mydb->lasterror();
205 $this->error =
'Failed to connect to SPIP';
208 $this->error =
'BadSPIPConfiguration';
211 $this->error =
'SPIPNotEnabled';
234 $query =
"DELETE FROM spip_auteurs WHERE login = '".$mydb->escape(
$object->login).
"'";
236 $result = $mydb->query($query);
243 $this->error = $mydb->lasterror();
246 $this->error =
'Failed to connect to SPIP';
249 $this->error =
'BadSPIPConfiguration';
252 $this->error =
'SPIPNotEnabled';
273 $query =
"SELECT login FROM spip_auteurs WHERE login = '".$mydb->escape(
$object->login).
"'";
275 $result = $mydb->query($query);
278 if ($mydb->num_rows($result)) {
288 $this->error = $mydb->lasterror();
292 $this->error =
'Failed to connect to SPIP';
295 $this->error =
'BadSPIPConfiguration';
298 $this->error =
'SPIPNotEnabled';
315 global $conf, $langs, $user;
317 dol_syslog(get_class($this).
"::add_to_mailman");
319 $this->mladded_ok = array();
320 $this->mladded_ko = array();
322 if (!function_exists(
"curl_init")) {
323 $langs->load(
"errors");
324 $this->error = $langs->trans(
"ErrorFunctionNotAvailableInPHP",
"curl_init");
328 if (isModEnabled(
'member')) {
333 $lists = explode(
',', $listes);
338 foreach ($lists as $list) {
340 $tmp = explode(
':', $list);
341 if (!empty($tmp[2])) {
343 if (
$object->element ==
'member' && $tmp[0] ==
'TYPE' &&
$object->type != $tmp[1]) {
344 dol_syslog(
"We ignore list ".$list.
" because object member type ".
$object->type.
" does not match ".$tmp[1], LOG_DEBUG);
347 if (
$object->element ==
'member' && $tmp[0] ==
'CATEG' && !in_array($tmp[1], $categstatic->containing(
$object->id,
'member',
'label'))) {
348 dol_syslog(
"We ignore list ".$list.
" because object member is not into category ".$tmp[1], LOG_DEBUG);
356 if ($result ===
false) {
357 $this->mladded_ko[$list] =
$object->email;
360 $this->mladded_ok[$list] =
$object->email;
363 return count($lists);
365 $this->error =
"ADHERENT_MAILMAN_URL not defined";
385 global $conf, $langs, $user;
387 dol_syslog(get_class($this).
"::del_to_mailman");
389 $this->mlremoved_ok = array();
390 $this->mlremoved_ko = array();
392 if (!function_exists(
"curl_init")) {
393 $langs->load(
"errors");
394 $this->error = $langs->trans(
"ErrorFunctionNotAvailableInPHP",
"curl_init");
398 if (isModEnabled(
'member')) {
403 $lists = explode(
',', $listes);
408 foreach ($lists as $list) {
410 $tmp = explode(
':', $list);
411 if (!empty($tmp[2])) {
413 if (
$object->element ==
'member' && $tmp[0] ==
'TYPE' &&
$object->type != $tmp[1]) {
414 dol_syslog(
"We ignore list ".$list.
" because object member type ".
$object->type.
" does not match ".$tmp[1], LOG_DEBUG);
417 if (
$object->element ==
'member' && $tmp[0] ==
'CATEG' && !in_array($tmp[1], $categstatic->containing(
$object->id,
'member',
'label'))) {
418 dol_syslog(
"We ignore list ".$list.
" because object member is not into category ".$tmp[1], LOG_DEBUG);
424 $result = $this->
callMailman(
$object, $conf->global->ADHERENT_MAILMAN_UNSUB_URL, $list);
426 if ($result ===
false) {
427 $this->mlremoved_ko[$list] =
$object->email;
430 $this->mlremoved_ok[$list] =
$object->email;
433 return count($lists);
435 $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 a 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.