diff options
Diffstat (limited to 'lib/study/setrate.php')
-rw-r--r-- | lib/study/setrate.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/study/setrate.php b/lib/study/setrate.php new file mode 100644 index 0000000..f893eb9 --- /dev/null +++ b/lib/study/setrate.php @@ -0,0 +1,19 @@ +<?php + +assert_redir(count($args) >= 3, 'study'); +$studyid = intval($args[2]); + +$study = mysql_fetch_assoc(sql( + "SELECT decks.id AS deckid, decks.name AS deckname, account.login AS deckowner, ". + " deck_study.learn_rate AS learn_rate, deck_study.user AS learn_user ". + "FROM deck_study LEFT JOIN decks ON deck_study.deck = decks.id LEFT JOIN account ON account.id = decks.owner ". + "WHERE deck_study.id = $studyid")); +assert_error($study && $study['learn_user'] == $user['id'], "You are not at the right place here."); + +if (isset($args[3]) && ($rate = intval($args[3])) > 0) { + sql("UPDATE deck_study SET learn_rate = $rate WHERE id = $studyid"); + header("Location: deck-study-$studyid"); + die(); +} + +include ("tpl/study/setrate.php"); |