From b140a661229e3dc19e417a44b07ecba98b252905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20D=C3=BCpmeier?= Date: Sat, 22 Mar 2014 14:30:42 +0100 Subject: [PATCH] now we can only change pizza if user is not ready --- server/db.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/server/db.php b/server/db.php index e8ba4e6..62dcb51 100755 --- a/server/db.php +++ b/server/db.php @@ -311,6 +311,13 @@ function changePizza($userid, $to) { )); return; } + + if ($this->isReady($userid)) { + $out->addStatus("set-ready", array( + "75833", 86, "User is ready." + )); + return; + } $sql = "UPDATE users SET pizza = :pizza WHERE id = :id"; @@ -324,6 +331,24 @@ function changePizza($userid, $to) { $stm->closeCursor(); } + + function isReady($id) { + global $controller; + + $sql = "SELECT ready FROM users WHERE id = :id"; + + $stm = $controller->exec($sql, array( + ":id" => $id + )); + $ready = $stm->fetch(); + + if (count($ready) > 0) { + + return $ready[0]; + } else { + return false; + } + } /** * mark the user as had paid.