From c5c428813978019fe957ea9ac65ec8e2e14d4b73 Mon Sep 17 00:00:00 2001 From: Romain Guerrero Date: Tue, 9 Feb 2016 00:04:49 +0100 Subject: [PATCH] =?UTF-8?q?permet=20la=20suppression=20et=20le=20retour=20?= =?UTF-8?q?JSON=20de=20contact=20avec=20l'option=20des=20infos=20=C3=A9ten?= =?UTF-8?q?dues?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/contacts.php | 13 ++++++++++++- model/DataBase.php | 17 ++++++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/controllers/contacts.php b/controllers/contacts.php index 7527a10..cd8febe 100755 --- a/controllers/contacts.php +++ b/controllers/contacts.php @@ -243,6 +243,17 @@ { global $db; - echo json_encode($db->getFromTableWhere('contacts')); + if (RASPISMS_SETTINGS_EXTENDED_CONTACTS_INFOS) + { + $contacts = $db->getFromTableWhere('contacts', array(), '', false, false, false, array(array( + 'table' => 'contacts_infos', + 'type' => 'LEFT', + 'on' => 'contacts_infos.id_contact = contacts.id' + ))); + } else { + $contacts = $db->getFromTableWhere('contacts'); + } + + echo json_encode($contacts); } } diff --git a/model/DataBase.php b/model/DataBase.php index 9511bbf..f5386fd 100755 --- a/model/DataBase.php +++ b/model/DataBase.php @@ -228,14 +228,25 @@ */ public function deleteContactsIn($contacts_ids) { + //On génère la clause IN et les paramètres adaptés depuis le tableau des id + $generted_in = $this->generateInFromArray($contacts_ids); + $params = $generted_in['PARAMS']; + + if (RASPISMS_SETTINGS_EXTENDED_CONTACTS_INFOS) { + $query = " + DELETE FROM contacts_infos + WHERE id_contact "; + + $query .= $generted_in['QUERY']; + + $this->runQuery($query, $params, self::ROWCOUNT); + } + $query = " DELETE FROM contacts WHERE id "; - //On génère la clause IN et les paramètres adaptés depuis le tableau des id - $generted_in = $this->generateInFromArray($contacts_ids); $query .= $generted_in['QUERY']; - $params = $generted_in['PARAMS']; return $this->runQuery($query, $params, self::ROWCOUNT); }