diff options
author | Camil Staps | 2016-07-27 15:47:23 +0200 |
---|---|---|
committer | Camil Staps | 2016-07-27 15:47:23 +0200 |
commit | 1449555d15916ff7987e68861b587a920463a9b0 (patch) | |
tree | d37a850d17df366518a6fa0046152e841bf82798 /classes/contact.php | |
parent | Remove payment when new value is unparsable (diff) |
Edit contact languages
Diffstat (limited to 'classes/contact.php')
-rw-r--r-- | classes/contact.php | 6 |
1 files changed, 6 insertions, 0 deletions
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) { |