Merge pull request #10560 from Toumaniere/9.0

Fix #10551 : MailmanSpip & Adherent : add and remove mailman list
This commit is contained in:
Laurent Destailleur 2019-02-13 16:31:32 +01:00 committed by GitHub
commit f60940a141
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -99,39 +99,57 @@ class InterfaceMailmanSpipsynchro extends DolibarrTriggers
} }
// Members // Members
elseif ($action == 'MEMBER_VALIDATE' || $action == 'MEMBER_MODIFY') elseif ($action == 'MEMBER_VALIDATE')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$return=0; $return=0;
if ($object->add_to_abo() < 0)
{
if (! empty($object->error)) $this->error=$object->error;
$this->errors=$object->errors;
$return=-1;
}
else
{
$return=1;
}
return $return;
}
elseif ($action == 'MEMBER_MODIFY')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$return=0;
// Add user into some linked tools (mailman, spip, etc...) // Add user into some linked tools (mailman, spip, etc...)
if (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid)) // TODO Do del/add also if type change if (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid))
{ {
if (is_object($object->oldcopy) && ($object->oldcopy->email != $object->email)) // If email has changed we delete mailman subscription for old email if (is_object($object->oldcopy) && (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid))) // If email has changed or if list has changed we delete mailman subscription for old email
{ {
if ($object->oldcopy->del_to_abo() < 0) if ($object->oldcopy->del_to_abo() < 0)
{ {
if (! empty($object->oldcopy->error)) $this->error=$object->oldcopy->error; if (! empty($object->oldcopy->error)) $this->error=$object->oldcopy->error;
$this->errors=$object->oldcopy->errors; $this->errors=$object->oldcopy->errors;
$return=-1; $return=-1;
} }
else else
{ {
$return=1; $return=1;
} }
} }
// We add subscription if new email or new type (new type may means more mailing-list to subscribe) // We add subscription if new email or new type (new type may means more mailing-list to subscribe)
if ($object->add_to_abo() < 0) if ($object->add_to_abo() < 0)
{ {
if (! empty($object->error)) $this->error=$object->error; if (! empty($object->error)) $this->error=$object->error;
$this->errors=$object->errors; $this->errors=$object->errors;
$return=-1; $return=-1;
} }
else else
{ {
$return=1; $return=1;
} }
} }
return $return; return $return;
} }