From 58ace4941ef3ec92ab71ae84df816343e2deb625 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Sat, 21 Sep 2013 14:37:53 +0200 Subject: [PATCH] bug fix #229: theme not stored on updated poches --- inc/poche/Database.class.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php index 4d664992d..0662581b9 100644 --- a/inc/poche/Database.class.php +++ b/inc/poche/Database.class.php @@ -113,9 +113,17 @@ class Database { } public function updateUserConfig($userId, $key, $value) { - $sql_update = "UPDATE users_config SET `value`=? WHERE `user_id`=? AND `name`=?"; - $params_update = array($value, $userId, $key); - $query = $this->executeQuery($sql_update, $params_update); + $config = $this->getConfigUser($userId); + + if (!isset ($user_config[$key])) { + $sql = "INSERT INTO users_config (`value`, `user_id`, `name`) VALUES (?, ?, ?)"; + } + else { + $sql = "UPDATE users_config SET `value`=? WHERE `user_id`=? AND `name`=?"; + } + + $params = array($value, $userId, $key); + $query = $this->executeQuery($sql, $params); } private function executeQuery($sql, $params) {