From 1449555d15916ff7987e68861b587a920463a9b0 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Wed, 27 Jul 2016 15:47:23 +0200 Subject: Edit contact languages --- classes/contact.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'classes/contact.php') diff --git a/classes/contact.php b/classes/contact.php index 989a14f..7741c17 100644 --- a/classes/contact.php +++ b/classes/contact.php @@ -317,13 +317,19 @@ class contact { /** * Set the language of the contact * + * @see correspondence::LANGUAGES The available languages + * * @param string $language The new language for the contact * * @throws PDOException If something went wrong with the database + * @throws Exception If the language is unknown * * @return bool True on succes, false on failure */ public function setLanguage($language) { + if (!in_array($language, correspondence::LANGUAGES)) { + throw new Exception("Language $language not available."); + } $stmt = $this->pdo->prepare("UPDATE `".constants::db_prefix."contact` SET `language`=? WHERE `id`=?"); $stmt->execute(array($language, $this->id)); if ($stmt->rowCount() == 1) { -- cgit v1.2.3