Fix: avoid empty email address
This commit is contained in:
parent
971802e773
commit
4db07c3d34
@ -152,38 +152,41 @@ class MailingTargets // This can't be abstract as it is used for some method
|
|||||||
$num = count($cibles);
|
$num = count($cibles);
|
||||||
for ($i = 0 ; $i < $num ; $i++)
|
for ($i = 0 ; $i < $num ; $i++)
|
||||||
{
|
{
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_cibles";
|
if (! empty($cibles[$i]['email'])) // avoid empty email address
|
||||||
$sql .= " (fk_mailing,";
|
{
|
||||||
$sql .= " fk_contact,";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_cibles";
|
||||||
$sql .= " nom, prenom, email, other, source_url, source_id,";
|
$sql .= " (fk_mailing,";
|
||||||
if (! empty($conf->global->MAILING_EMAIL_UNSUBSCRIBE)) $sql .= " tag,";
|
$sql .= " fk_contact,";
|
||||||
$sql.= " source_type)";
|
$sql .= " nom, prenom, email, other, source_url, source_id,";
|
||||||
$sql .= " VALUES (".$mailing_id.",";
|
if (! empty($conf->global->MAILING_EMAIL_UNSUBSCRIBE)) $sql .= " tag,";
|
||||||
$sql .= (empty($cibles[$i]['fk_contact']) ? '0' : "'".$cibles[$i]['fk_contact']."'") .",";
|
$sql.= " source_type)";
|
||||||
$sql .= "'".$this->db->escape($cibles[$i]['name'])."',";
|
$sql .= " VALUES (".$mailing_id.",";
|
||||||
$sql .= "'".$this->db->escape($cibles[$i]['firstname'])."',";
|
$sql .= (empty($cibles[$i]['fk_contact']) ? '0' : "'".$cibles[$i]['fk_contact']."'") .",";
|
||||||
$sql .= "'".$this->db->escape($cibles[$i]['email'])."',";
|
$sql .= "'".$this->db->escape($cibles[$i]['name'])."',";
|
||||||
$sql .= "'".$this->db->escape($cibles[$i]['other'])."',";
|
$sql .= "'".$this->db->escape($cibles[$i]['firstname'])."',";
|
||||||
$sql .= "'".$this->db->escape($cibles[$i]['source_url'])."',";
|
$sql .= "'".$this->db->escape($cibles[$i]['email'])."',";
|
||||||
$sql .= "'".$this->db->escape($cibles[$i]['source_id'])."',";
|
$sql .= "'".$this->db->escape($cibles[$i]['other'])."',";
|
||||||
if (! empty($conf->global->MAILING_EMAIL_UNSUBSCRIBE)) $sql .= "'".$this->db->escape(md5($cibles[$i]['email'].';'.$cibles[$i]['name'].';'.$mailing_id.';'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY))."',";
|
$sql .= "'".$this->db->escape($cibles[$i]['source_url'])."',";
|
||||||
$sql .= "'".$this->db->escape($cibles[$i]['source_type'])."')";
|
$sql .= "'".$this->db->escape($cibles[$i]['source_id'])."',";
|
||||||
$result=$this->db->query($sql);
|
if (! empty($conf->global->MAILING_EMAIL_UNSUBSCRIBE)) $sql .= "'".$this->db->escape(md5($cibles[$i]['email'].';'.$cibles[$i]['name'].';'.$mailing_id.';'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY))."',";
|
||||||
if ($result)
|
$sql .= "'".$this->db->escape($cibles[$i]['source_type'])."')";
|
||||||
{
|
$result=$this->db->query($sql);
|
||||||
$j++;
|
if ($result)
|
||||||
}
|
{
|
||||||
else
|
$j++;
|
||||||
{
|
}
|
||||||
if ($this->db->errno() != 'DB_ERROR_RECORD_ALREADY_EXISTS')
|
else
|
||||||
{
|
{
|
||||||
// Si erreur autre que doublon
|
if ($this->db->errno() != 'DB_ERROR_RECORD_ALREADY_EXISTS')
|
||||||
dol_syslog($this->db->error());
|
{
|
||||||
$this->error=$this->db->error();
|
// Si erreur autre que doublon
|
||||||
$this->db->rollback();
|
dol_syslog($this->db->error());
|
||||||
return -1;
|
$this->error=$this->db->error();
|
||||||
}
|
$this->db->rollback();
|
||||||
}
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::add_to_target: mailing ".$j." targets added");
|
dol_syslog(get_class($this)."::add_to_target: mailing ".$j." targets added");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user