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);
|
||||
for ($i = 0 ; $i < $num ; $i++)
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_cibles";
|
||||
$sql .= " (fk_mailing,";
|
||||
$sql .= " fk_contact,";
|
||||
$sql .= " nom, prenom, email, other, source_url, source_id,";
|
||||
if (! empty($conf->global->MAILING_EMAIL_UNSUBSCRIBE)) $sql .= " tag,";
|
||||
$sql.= " source_type)";
|
||||
$sql .= " VALUES (".$mailing_id.",";
|
||||
$sql .= (empty($cibles[$i]['fk_contact']) ? '0' : "'".$cibles[$i]['fk_contact']."'") .",";
|
||||
$sql .= "'".$this->db->escape($cibles[$i]['name'])."',";
|
||||
$sql .= "'".$this->db->escape($cibles[$i]['firstname'])."',";
|
||||
$sql .= "'".$this->db->escape($cibles[$i]['email'])."',";
|
||||
$sql .= "'".$this->db->escape($cibles[$i]['other'])."',";
|
||||
$sql .= "'".$this->db->escape($cibles[$i]['source_url'])."',";
|
||||
$sql .= "'".$this->db->escape($cibles[$i]['source_id'])."',";
|
||||
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_type'])."')";
|
||||
$result=$this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$j++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($this->db->errno() != 'DB_ERROR_RECORD_ALREADY_EXISTS')
|
||||
{
|
||||
// Si erreur autre que doublon
|
||||
dol_syslog($this->db->error());
|
||||
$this->error=$this->db->error();
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (! empty($cibles[$i]['email'])) // avoid empty email address
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_cibles";
|
||||
$sql .= " (fk_mailing,";
|
||||
$sql .= " fk_contact,";
|
||||
$sql .= " nom, prenom, email, other, source_url, source_id,";
|
||||
if (! empty($conf->global->MAILING_EMAIL_UNSUBSCRIBE)) $sql .= " tag,";
|
||||
$sql.= " source_type)";
|
||||
$sql .= " VALUES (".$mailing_id.",";
|
||||
$sql .= (empty($cibles[$i]['fk_contact']) ? '0' : "'".$cibles[$i]['fk_contact']."'") .",";
|
||||
$sql .= "'".$this->db->escape($cibles[$i]['name'])."',";
|
||||
$sql .= "'".$this->db->escape($cibles[$i]['firstname'])."',";
|
||||
$sql .= "'".$this->db->escape($cibles[$i]['email'])."',";
|
||||
$sql .= "'".$this->db->escape($cibles[$i]['other'])."',";
|
||||
$sql .= "'".$this->db->escape($cibles[$i]['source_url'])."',";
|
||||
$sql .= "'".$this->db->escape($cibles[$i]['source_id'])."',";
|
||||
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_type'])."')";
|
||||
$result=$this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$j++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($this->db->errno() != 'DB_ERROR_RECORD_ALREADY_EXISTS')
|
||||
{
|
||||
// Si erreur autre que doublon
|
||||
dol_syslog($this->db->error());
|
||||
$this->error=$this->db->error();
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this)."::add_to_target: mailing ".$j." targets added");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user