summaryrefslogtreecommitdiff
path: root/lib/deck
diff options
context:
space:
mode:
authorroot <root@adnab.me>2014-01-31 16:42:40 +0100
committerroot <root@adnab.me>2014-01-31 16:42:40 +0100
commitb0c23ea84327d48e3a4383fac3e795c2dc0a1215 (patch)
tree625a8f0882815d9442a4ff2ec15a49e669a15ed3 /lib/deck
parentcee55b766230837c21453f85e76a921cb5b8b89e (diff)
downloadBits-b0c23ea84327d48e3a4383fac3e795c2dc0a1215.tar.gz
Bits-b0c23ea84327d48e3a4383fac3e795c2dc0a1215.zip
Remove all studying apps code.
Diffstat (limited to 'lib/deck')
-rw-r--r--lib/deck/add.php5
-rw-r--r--lib/deck/addent.php46
-rw-r--r--lib/deck/edent.php44
-rw-r--r--lib/deck/edit.php42
-rw-r--r--lib/deck/index.php25
-rw-r--r--lib/deck/mvent.php33
-rw-r--r--lib/deck/new.php32
-rw-r--r--lib/deck/rment.php20
-rw-r--r--lib/deck/view.php42
9 files changed, 0 insertions, 289 deletions
diff --git a/lib/deck/add.php b/lib/deck/add.php
deleted file mode 100644
index d7f8e9f..0000000
--- a/lib/deck/add.php
+++ /dev/null
@@ -1,5 +0,0 @@
-<?php
-
-$title = "olol";
-$message = 'Placeholder. Go to <a href="deck">study decks</a>.';
-require("tpl/general/empty.php");
diff --git a/lib/deck/addent.php b/lib/deck/addent.php
deleted file mode 100644
index a860df1..0000000
--- a/lib/deck/addent.php
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php
-
-require("lib/markdown.php");
-
-assert_redir(count($args) == 3, 'deck');
-$deckid = intval($args[2]);
-
-$deck = mysql_fetch_assoc(sql(
- "SELECT decks.id AS id, decks.name AS name, decks.comment_md AS comment, decks.owner AS owner_id ".
- "FROM decks ".
- "WHERE decks.id = $deckid"));
-assert_error($deck && $deck['owner_id'] == $user['id'],
- "This deck does not exist, or you are not allowed to edit it.");
-
-$card_name = "";
-$card_text = "";
-if (isset($_POST['name']) && isset($_POST['text'])) {
- $card_name = esca($_POST['name']);
- $card_text = esca($_POST['text']);
- $card_text_html = Markdown($card_text);
- if ($card_name == "") {
- $error = "You must give your card a name.";
- } else if ($card_text == "") {
- $error = "You must put some text in your card.";
- } else if (mysql_fetch_assoc(sql("SELECT id FROM cards WHERE deck = $deckid AND name = '" . escs($card_name)."'"))) {
- $error = "You already have a card using that name.";
- } else {
- $n = mysql_fetch_assoc(sql("SELECT MAX(number) AS n FROM cards WHERE deck = $deckid"));
- $number = $n['n'] + 1;
- sql(
- "INSERT INTO cards(deck, number, name, text_md, text_html) ".
- "VALUES($deckid, $number, '" . escs($card_name) . "', '" . escs($card_text) . "', '" . escs($card_text_html). "')");
- header("Location: view-deck-$deckid");
- die();
- }
-}
-
-$title = "Add card to " . $deck['name'];
-$message = "Your card will be added at the end of the deck. You can always move it afterwards.";
-$fields = array(
- array("label" => "Name : ", "name" => "name", "value" => $card_name),
- array("label" => "Text : ", "name" => "text", "type" => "textarea", "value" => $card_text),
-);
-$validate = "Add card";
-
-require("tpl/deck/ef.php");
diff --git a/lib/deck/edent.php b/lib/deck/edent.php
deleted file mode 100644
index 8bdfac3..0000000
--- a/lib/deck/edent.php
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-
-require("lib/markdown.php");
-
-assert_redir(count($args) == 3, 'deck');
-$cardid = intval($args[2]);
-
-$card = mysql_fetch_assoc(sql(
- "SELECT decks.id AS deckid, decks.owner AS deckowner, decks.name AS deckname, cards.name AS name, cards.text_md AS text ".
- "FROM cards LEFT JOIN decks ON decks.id = cards.deck ".
- "WHERE cards.id = $cardid"));
-assert_error($card && $card["deckowner"] == $user['id'],
- "This card does not exist, or you are not allowed to edit it.");
-$deck = array("id" => $card['deckid'], 'name' => $card['deckname']);
-
-$card_name = $card['name'];
-$card_text = $card['text'];
-if (isset($_POST['name']) && isset($_POST['text'])) {
- $card_name = esca($_POST['name']);
- $card_text = esca($_POST['text']);
- $card_text_html = Markdown($card_text);
- if ($card_name == "") {
- $error = "You must give your card a name.";
- } else if ($card_text == "") {
- $error = "You must put some text in your card.";
- } else if (mysql_fetch_assoc(sql("SELECT id FROM cards WHERE deck = " . $deck['id'] . " AND name = '" . escs($card_name)."' AND id != $cardid"))) {
- $error = "You already have a card using that name.";
- } else {
- sql("UPDATE cards SET name = '" . escs($card_name) . "', text_md = '" . escs($card_text) . "', text_html = '" . escs($card_text_html) . "'" .
- " WHERE id = $cardid");
- header("Location: view-deck-" . $deck['id']);
- die();
- }
-}
-
-$title = "Edit card in " . $deck['name'];
-$fields = array(
- array("label" => "Name : ", "name" => "name", "value" => $card_name),
- array("label" => "Text : ", "name" => "text", "type" => "textarea", "value" => $card_text),
-);
-$validate = "Edit card";
-
-require("tpl/deck/ef.php");
-
diff --git a/lib/deck/edit.php b/lib/deck/edit.php
deleted file mode 100644
index d4102bb..0000000
--- a/lib/deck/edit.php
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-
-require("lib/markdown.php");
-
-assert_redir(count($args) == 3, 'deck');
-$deckid = intval($args[2]);
-
-$deck = mysql_fetch_assoc(sql(
- "SELECT decks.id AS id, decks.name AS name, decks.comment_md AS comment, account.id AS owner_id ".
- "FROM decks LEFT JOIN account ON account.id = decks.owner ".
- "WHERE decks.id = $deckid"));
-assert_error($deck && $deck['owner_id'] == $user['id'],
- "This deck does not exist, or you are not allowed to edit it.");
-
-$deck_name = $deck['name'];
-$deck_comment = $deck['comment'];
-if (isset($_POST['name']) && isset($_POST['comment'])) {
- $deck_name = esca($_POST['name']);
- $deck_comment = esca($_POST['comment']);
- $deck_comment_html = Markdown($deck_comment);
- if ($deck_name == "") {
- $error = "You must enter a name for your deck.";
- } else if (mysql_fetch_assoc(sql("SELECT id FROM decks WHERE owner = " . $user['id'] . " AND name = '" . escs($deck_name) . "' AND id != $deckid"))) {
- $error = "You already have a deck with that title.";
- } else if ($deck_comment == "") {
- $error = "Please enter a comment on your deck.";
- } else {
- sql("UPDATE decks SET name = '" . escs($deck_name) . "', comment_md = '" . escs($deck_comment) .
- "', comment_html = '" . escs($deck_comment_html) . "' WHERE id = $deckid");
- header("Location: view-deck-" . $deckid);
- die();
- }
-}
-
-$title = "Edit deck : " . $deck['name'];
-$fields = array(
- array("label" => "Name : ", "name" => "name", "value" => $deck_name),
- array("label" => "Comment : ", "name" => "comment", "type" => "textarea", "value" => $deck_comment),
-);
-$validate = "Edit deck";
-
-require("tpl/deck/ef.php");
diff --git a/lib/deck/index.php b/lib/deck/index.php
deleted file mode 100644
index ad497d5..0000000
--- a/lib/deck/index.php
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-
-$filters = array (
- "order" => array (
- "nbUsers" => "popularity",
- "name" => "name",
- "owner" => "author",
- ),
- "way" => $ord_ways,
-);
-$fdefaults = array (
- "order" => "nbUsers",
- "way" => "DESC",
-);
-
-$decks = array();
-$n = sql(
- "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;
-
-require("tpl/deck/index.php");
-
diff --git a/lib/deck/mvent.php b/lib/deck/mvent.php
deleted file mode 100644
index 28a7fa3..0000000
--- a/lib/deck/mvent.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-
-require("lib/markdown.php");
-
-assert_redir(count($args) == 4, 'deck');
-$cardid = intval($args[2]);
-$pos = intval($args[3]);
-
-$card = mysql_fetch_assoc(sql(
- "SELECT decks.id AS deckid, decks.owner AS deckowner, decks.name AS deckname, cards.name AS name, cards.text_md AS text, cards.number AS number ".
- "FROM cards LEFT JOIN decks ON decks.id = cards.deck ".
- "WHERE cards.id = $cardid"));
-assert_error($card && $card["deckowner"] == $user['id'],
- "This card does not exist, or you are not allowed to edit it.");
-$deck = array("id" => $card['deckid'], 'name' => $card['deckname']);
-$deckid = $card['deckid'];
-
-$mn = mysql_fetch_assoc(sql("SELECT COUNT(*) AS c FROM cards WHERE deck = $deckid"));
-$mn = $mn['c'];
-if ($pos > $mn) {
- $error = "That number is too big. You don't even have that much cards in your deck.";
-} else if ($pos < 1) {
- $error = "A position is at least one...";
-} else {
- sql("UPDATE cards SET number = 0 WHERE id = $cardid");
- sql("UPDATE cards SET number = number - 1 WHERE number > " . $card['number'] . " AND deck = $deckid ORDER BY number ASC");
- sql("UPDATE cards SET number = number + 1 WHERE number >= $pos AND deck = $deckid ORDER BY number DESC");
- 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");
-}
-
-require("tpl/deck/ef.php");
diff --git a/lib/deck/new.php b/lib/deck/new.php
deleted file mode 100644
index 2ff1b50..0000000
--- a/lib/deck/new.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-
-require("lib/markdown.php");
-
-$deck_name = "";
-$deck_comment = "";
-if (isset($_POST["name"]) && isset($_POST['comment'])) {
- $deck_name = esca($_POST['name']);
- $deck_comment = esca($_POST['comment']);
- $deck_comment_html = Markdown($deck_comment);
- if ($deck_name == "") {
- $error = "You must enter a name for your deck.";
- } else if (mysql_fetch_assoc(sql("SELECT id FROM decks WHERE owner = " . $user['id'] . " AND name = '" . escs($deck_name) . "'"))) {
- $error = "You already have a deck with that title.";
- } else if ($deck_comment == "") {
- $error = "Please enter a comment on your deck.";
- } else {
- sql("INSERT INTO decks(owner, name, comment_md, comment_html) ".
- "VALUES(" . $user['id'] . ", '" . escs($deck_name) . "', '" . escs($deck_comment) . "', '" . escs($deck_comment_html) . "')");
- header("Location: view-deck-" . mysql_insert_id());
- die();
- }
-}
-
-$title = "Create deck";
-$fields = array(
- array("label" => "Name : ", "name" => "name", "value" => $deck_name),
- array("label" => "Comment : ", "name" => "comment", "type" => "textarea", "value" => $deck_comment),
- );
-$validate = "Create deck";
-
-require("tpl/deck/new.php");
diff --git a/lib/deck/rment.php b/lib/deck/rment.php
deleted file mode 100644
index c4f86c8..0000000
--- a/lib/deck/rment.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-
-require("lib/markdown.php");
-
-assert_redir(count($args) >= 3, 'deck');
-$cardid = intval($args[2]);
-
-$card = mysql_fetch_assoc(sql(
- "SELECT decks.id AS deckid, decks.owner AS deckowner, decks.name AS deckname, cards.name AS name, cards.text_md AS text, cards.number AS number ".
- "FROM cards LEFT JOIN decks ON decks.id = cards.deck ".
- "WHERE cards.id = $cardid"));
-assert_error($card && $card["deckowner"] == $user['id'],
- "This card does not exist, or you are not allowed to edit it.");
-
-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'] . " ORDER BY number ASC");
-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
deleted file mode 100644
index e9a83e6..0000000
--- a/lib/deck/view.php
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-
-assert_redir(count($args) == 3, 'deck');
-$deckid = intval($args[2]);
-
-$deck = mysql_fetch_assoc(sql(
- "SELECT decks.id AS id, decks.name AS name, decks.comment_html AS comment, account.login AS owner, account.id AS owner_id ".
- "FROM decks LEFT JOIN account ON account.id = decks.owner ".
- "WHERE decks.id = $deckid"));
-assert_error($deck, "This deck does not exist.");
-
-$can_edit = false;
-if ($deck["owner_id"] == $user['id']) $can_edit = true;
-
-$filters = array (
- "order" => array (
- "name" => "card name",
- "number" => "card number",
- ),
- "way" => $ord_ways,
-);
-$fdefaults = array (
- "order" => "number",
- "way" => ($can_edit ? "DESC" : "ASC"),
-);
-
-$cards = array();
-$n = sql(
- "SELECT id, number, name, text_html AS text FROM cards WHERE deck = $deckid ".
- "ORDER BY " . get_filter("order") . " " . get_filter("way")
- );
-while ($nn = mysql_fetch_assoc($n)) $cards[] = $nn;
-
-$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");