diff options
author | Nicolas BERNSTEIN <alexis211@gmail.com> | 2011-09-18 12:07:29 +0200 |
---|---|---|
committer | Nicolas BERNSTEIN <alexis211@gmail.com> | 2011-09-18 12:07:29 +0200 |
commit | a565e649898c629874ef812a13806b1c384f68e4 (patch) | |
tree | afc03ed12ec7e82ce17bcfff5ba76440ff43eb97 /lib/deck | |
parent | 8d9321225140a3db0b72796d4d0236d6cacfeb8a (diff) | |
download | Bits-a565e649898c629874ef812a13806b1c384f68e4.tar.gz Bits-a565e649898c629874ef812a13806b1c384f68e4.zip |
Added study program. Yay!
Diffstat (limited to 'lib/deck')
-rw-r--r-- | lib/deck/index.php | 6 | ||||
-rw-r--r-- | lib/deck/mvent.php | 1 | ||||
-rw-r--r-- | lib/deck/rment.php | 2 | ||||
-rw-r--r-- | lib/deck/view.php | 8 |
4 files changed, 14 insertions, 3 deletions
diff --git a/lib/deck/index.php b/lib/deck/index.php index 7a125e2..ad497d5 100644 --- a/lib/deck/index.php +++ b/lib/deck/index.php @@ -15,9 +15,9 @@ $fdefaults = array ( $decks = array(); $n = sql( - "SELECT decks.id AS id, decks.name AS name, account.login AS owner, 0 AS nbUsers ". - "FROM decks LEFT JOIN account ON decks.owner = account.id ". - "ORDER BY " . get_filter("order") . " " . get_filter("way") + "SELECT decks.id AS id, decks.name AS name, account.login AS owner, COUNT(deck_study.id) AS nbUsers ". + "FROM decks LEFT JOIN account ON decks.owner = account.id LEFT JOIN deck_study ON deck_study.deck = decks.id ". + "GROUP BY decks.id ORDER BY " . get_filter("order") . " " . get_filter("way") ); while ($nn = mysql_fetch_assoc($n)) $decks[] = $nn; diff --git a/lib/deck/mvent.php b/lib/deck/mvent.php index d4571e9..10d585a 100644 --- a/lib/deck/mvent.php +++ b/lib/deck/mvent.php @@ -26,6 +26,7 @@ if ($pos > $mn) { sql("UPDATE cards SET number = number - 1 WHERE number > " . $card['number']); sql("UPDATE cards SET number = number + 1 WHERE number >= $pos"); sql("UPDATE cards SET number = $pos WHERE id = $cardid"); + sql("UPDATE deck_study SET need_check = 1 WHERE deck = $deckid"); header("Location: view-deck-$deckid"); } diff --git a/lib/deck/rment.php b/lib/deck/rment.php index d3a87e0..6bb8300 100644 --- a/lib/deck/rment.php +++ b/lib/deck/rment.php @@ -15,4 +15,6 @@ assert_error($card && $card["deckowner"] == $user['id'], token_validate("Do you really want to delete this card ?", "view-deck-". $card['deckid']); sql("DELETE FROM cards WHERE id = $cardid"); sql("UPDATE cards SET number = number - 1 WHERE number > " . $card['number'] . " AND deck = " . $card['deckid']); +sql("UPDATE deck_study SET need_check = 1 WHERE deck = " . $card['deckid']); header("Location: view-deck-" . $card['deckid']); +die(); diff --git a/lib/deck/view.php b/lib/deck/view.php index eda2ca0..5604395 100644 --- a/lib/deck/view.php +++ b/lib/deck/view.php @@ -31,4 +31,12 @@ while ($nn = mysql_fetch_assoc($n)) $cards[] = $nn; $can_edit = false; if ($deck["owner_id"] == $user['id']) $can_edit = true; +$can_start_study = false; +if ($user['id'] != 0) { + if (!mysql_fetch_assoc(sql("SELECT id FROM deck_study WHERE deck = $deckid AND user = " . $user['id']))) + $can_start_study = true; +} else { + $message = "You should create an account in order to study this deck."; +} + require("tpl/deck/view.php"); |