Merge branch '11.0' of git@github.com:Dolibarr/dolibarr.git into 12.0

This commit is contained in:
Laurent Destailleur 2021-06-29 15:47:58 +02:00
commit e2c4a14939

View File

@ -744,40 +744,34 @@ class Contact extends CommonObject
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
} }
if ($user) {
// Mis a jour alerte birthday // Mis a jour alerte birthday
if ($this->birthday_alert) if ($this->birthday_alert) {
{
//check existing //check existing
$sql_check = "SELECT rowid FROM ".MAIN_DB_PREFIX."user_alert WHERE type=1 AND fk_contact=".$this->db->escape($id)." AND fk_user=".$user->id; $sql_check = "SELECT rowid FROM " . MAIN_DB_PREFIX . "user_alert WHERE type=1 AND fk_contact=" . $this->db->escape($id) . " AND fk_user=" . $user->id;
$result_check = $this->db->query($sql_check); $result_check = $this->db->query($sql_check);
if (!$result_check || ($this->db->num_rows($result_check) < 1)) if (!$result_check || ($this->db->num_rows($result_check) < 1)) {
{
//insert //insert
$sql = "INSERT INTO ".MAIN_DB_PREFIX."user_alert(type,fk_contact,fk_user) "; $sql = "INSERT INTO " . MAIN_DB_PREFIX . "user_alert(type,fk_contact,fk_user) ";
$sql .= "VALUES (1,".$this->db->escape($id).",".$user->id.")"; $sql .= "VALUES (1," . $this->db->escape($id) . "," . $user->id . ")";
$result = $this->db->query($sql); $result = $this->db->query($sql);
if (!$result) if (!$result) {
{
$error++; $error++;
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
} }
} } else {
else
{
$result = true; $result = true;
} }
} } else {
else $sql = "DELETE FROM " . MAIN_DB_PREFIX . "user_alert ";
{ $sql .= "WHERE type=1 AND fk_contact=" . $this->db->escape($id) . " AND fk_user=" . $user->id;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_alert ";
$sql .= "WHERE type=1 AND fk_contact=".$this->db->escape($id)." AND fk_user=".$user->id;
$result = $this->db->query($sql); $result = $this->db->query($sql);
if (!$result) if (!$result) {
{
$error++; $error++;
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
} }
} }
}
if (!$error && !$notrigger) if (!$error && !$notrigger)
{ {