Fix MailmanSpip bad adherent type after update
This commit is contained in:
parent
6c08cc6b6a
commit
a115b1da7f
@ -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.= " 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);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
|
||||
@ -103,35 +103,52 @@ class InterfaceMailmanSpipsynchro extends DolibarrTriggers
|
||||
{
|
||||
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...)
|
||||
if (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid)) // TODO Do del/add also if type change
|
||||
{
|
||||
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 (! empty($object->oldcopy->error)) $this->error=$object->oldcopy->error;
|
||||
$this->errors=$object->oldcopy->errors;
|
||||
$return=-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$return=1;
|
||||
}
|
||||
}
|
||||
// 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 (! empty($object->error)) $this->error=$object->error;
|
||||
$this->errors=$object->errors;
|
||||
$return=-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$return=1;
|
||||
}
|
||||
}
|
||||
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;
|
||||
// Add user into some linked tools (mailman, spip, etc...)
|
||||
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 ($object->oldcopy->del_to_abo() < 0)
|
||||
{
|
||||
if (! empty($object->oldcopy->error)) $this->error=$object->oldcopy->error;
|
||||
$this->errors=$object->oldcopy->errors;
|
||||
$return=-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$return=1;
|
||||
}
|
||||
}
|
||||
// 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 (! empty($object->error)) $this->error=$object->error;
|
||||
$this->errors=$object->errors;
|
||||
$return=-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$return=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
@ -354,7 +354,7 @@ class MailmanSpip
|
||||
if (! empty($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);
|
||||
continue;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user