remplace les tests empty par isset pour éviter les erreurs si valeur = 0

This commit is contained in:
Romain Guerrero 2016-02-14 23:44:58 +01:00
parent 15cd965580
commit 10262a7976

View file

@ -110,7 +110,7 @@
global $db; global $db;
if (empty($_POST['name']) || empty($_POST['phone']) || (RASPISMS_SETTINGS_EXTENDED_CONTACTS_INFOS && empty($_POST['civility']))) if (!isset($_POST['name']) || !isset($_POST['phone']) || (RASPISMS_SETTINGS_EXTENDED_CONTACTS_INFOS && !isset($_POST['civility'])))
{ {
$_SESSION['errormessage'] = 'Des champs sont manquants.'; $_SESSION['errormessage'] = 'Des champs sont manquants.';
header('Location: ' . $this->generateUrl('contacts', 'add')); header('Location: ' . $this->generateUrl('contacts', 'add'));
@ -140,6 +140,8 @@
return false; return false;
} }
$id_contact = $db->lastId();
$db->insertIntoTable('events', ['type' => 'CONTACT_ADD', 'text' => 'Ajout contact : ' . $nomComplet . ' (' . internalTools::phoneAddSpace($phone) . ')']); $db->insertIntoTable('events', ['type' => 'CONTACT_ADD', 'text' => 'Ajout contact : ' . $nomComplet . ' (' . internalTools::phoneAddSpace($phone) . ')']);
if (!RASPISMS_SETTINGS_EXTENDED_CONTACTS_INFOS) if (!RASPISMS_SETTINGS_EXTENDED_CONTACTS_INFOS)
@ -149,8 +151,6 @@
return true; return true;
} }
$id_contact = $db->lastId();
if (!$db->insertIntoTable('contacts_infos', ['id_contact' => $id_contact, 'civility' => $civility, 'first_name' => $prenom, 'last_name' => $nom, 'birthday' => $birthday, 'love_situation' => $loveSituation])) if (!$db->insertIntoTable('contacts_infos', ['id_contact' => $id_contact, 'civility' => $civility, 'first_name' => $prenom, 'last_name' => $nom, 'birthday' => $birthday, 'love_situation' => $loveSituation]))
{ {
$_SESSION['errormessage'] = "Le contact a bien été créé, mais certaines informations n'ont pas pu être enregistrées."; $_SESSION['errormessage'] = "Le contact a bien été créé, mais certaines informations n'ont pas pu être enregistrées.";