summaryrefslogtreecommitdiff
path: root/lib/study/deckadd.php
diff options
context:
space:
mode:
authorNicolas BERNSTEIN <alexis211@gmail.com>2011-09-18 12:07:29 +0200
committerNicolas BERNSTEIN <alexis211@gmail.com>2011-09-18 12:07:29 +0200
commita565e649898c629874ef812a13806b1c384f68e4 (patch)
treeafc03ed12ec7e82ce17bcfff5ba76440ff43eb97 /lib/study/deckadd.php
parent8d9321225140a3db0b72796d4d0236d6cacfeb8a (diff)
downloadBits-a565e649898c629874ef812a13806b1c384f68e4.tar.gz
Bits-a565e649898c629874ef812a13806b1c384f68e4.zip
Added study program. Yay!
Diffstat (limited to 'lib/study/deckadd.php')
-rw-r--r--lib/study/deckadd.php14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/study/deckadd.php b/lib/study/deckadd.php
index d7f8e9f..b95648c 100644
--- a/lib/study/deckadd.php
+++ b/lib/study/deckadd.php
@@ -1,5 +1,13 @@
<?php
-$title = "olol";
-$message = 'Placeholder. Go to <a href="deck">study decks</a>.';
-require("tpl/general/empty.php");
+assert_redir(count($args) == 3, 'deck');
+$deckid = intval($args[2]);
+$deck = mysql_fetch_assoc(sql("SELECT id FROM decks WHERE id = $deckid"));
+assert_error($deck, "This deck does not exist.");
+
+assert_error(!mysql_fetch_assoc(sql("SELECT id FROM deck_study WHERE deck = $deckid AND user = " . $user['id'])),
+ "You are already studying this deck.");
+
+sql("INSERT INTO deck_study(user, deck) VALUES(" . $user['id'] . ", $deckid)");
+header("Location: deck-study-".mysql_insert_id());
+die();