Fix MailmanSpip bad adherent type after update

This commit is contained in:
Timoté Fallais 2019-02-13 14:45:51 +01:00
parent 6c08cc6b6a
commit a115b1da7f
3 changed files with 60 additions and 30 deletions

View File

@ -563,6 +563,19 @@ class Adherent extends CommonObject
$sql.= ", fk_user_mod = ".($user->id>0?$user->id:'null'); // Can be null because member can be create by a guest $sql.= ", fk_user_mod = ".($user->id>0?$user->id:'null'); // Can be null because member can be create by a guest
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid = ".$this->id;
$sql2 = "SELECT libelle";
$sql2.= " FROM ".MAIN_DB_PREFIX."adherent_type";
$sql2.= " WHERE rowid = ".$this->typeid;
$resql2 = $this->db->query($sql2);
if($resql2)
{
while ($obj=$this->db->fetch_object($resql2))
{
$this->type=$obj->libelle;
}
}
dol_syslog(get_class($this)."::update update member", LOG_DEBUG); dol_syslog(get_class($this)."::update update member", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)

View File

@ -103,9 +103,25 @@ class InterfaceMailmanSpipsynchro extends DolibarrTriggers
{ {
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);
if($action == 'MEMBER_VALIDATE')
{
$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;
}
}
else
{
$return=0; $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) || ($object->oldcopy->typeid != $object->typeid))) // If email has changed or if list 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
{ {
@ -131,6 +147,7 @@ class InterfaceMailmanSpipsynchro extends DolibarrTriggers
{ {
$return=1; $return=1;
} }
}
} }
return $return; return $return;

View File

@ -354,7 +354,7 @@ class MailmanSpip
if (! empty($tmp[2])) if (! empty($tmp[2]))
{ {
$list=$tmp[2]; $list=$tmp[2];
if ($object->element == 'member' && $tmp[0] == 'TYPE' && $object->type == $tmp[1]) // Filter on member type label if ($object->element == 'member' && $tmp[0] == 'TYPE' && $object->type != $tmp[1]) // Filter on member type label
{ {
dol_syslog("We ignore list ".$list." because object member type ".$object->type." does not match ".$tmp[1], LOG_DEBUG); dol_syslog("We ignore list ".$list." because object member type ".$object->type." does not match ".$tmp[1], LOG_DEBUG);
continue; continue;