diff options
Diffstat (limited to 'lib/list')
-rw-r--r-- | lib/list/addbatch.php | 43 | ||||
-rw-r--r-- | lib/list/edbatch.php | 47 | ||||
-rw-r--r-- | lib/list/edit.php | 43 | ||||
-rw-r--r-- | lib/list/inc_process.php | 40 | ||||
-rw-r--r-- | lib/list/index.php | 25 | ||||
-rw-r--r-- | lib/list/list_models.php | 39 | ||||
-rw-r--r-- | lib/list/new.php | 33 | ||||
-rw-r--r-- | lib/list/rmbatch.php | 20 | ||||
-rw-r--r-- | lib/list/view.php | 31 |
9 files changed, 0 insertions, 321 deletions
diff --git a/lib/list/addbatch.php b/lib/list/addbatch.php deleted file mode 100644 index 5cb5fb6..0000000 --- a/lib/list/addbatch.php +++ /dev/null @@ -1,43 +0,0 @@ -<?php - -require("lib/list/inc_process.php"); - -assert_redir(count($args) == 3, 'list'); -$listid = intval($args[2]); - -$list = mysql_fetch_assoc(sql( - "SELECT lists.id AS id, lists.name AS name, lists.owner AS owner_id ". - "FROM lists WHERE lists.id = $listid")); -assert_error($list && $list['owner_id'] == $user['id'], - "This list does not exist, or you are not allowed to edit it."); - -$batch_name = ""; -$batch_model = ""; -$batch_contents = ""; -if (isset($_POST['name']) && isset($_POST['model']) && isset($_POST['contents'])) { - $batch_name = esca($_POST['name']); - $batch_model = esca($_POST['model']); - $batch_contents = esca($_POST['contents']); - $batch_json = mk_batch_json($batch_model, $batch_contents); - if ($batch_name == "") { - $error = "You must give a name to this batch."; - } else if (mysql_fetch_assoc(sql("SELECT id FROM batches WHERE list = $listid AND name = '" . escs($batch_name) . "'"))) { - $error = "You already have a batch using that name."; - } else { - sql( - "INSERT INTO batches(list, name, model, contents, json_data) ". - "VALUES($listid, '" . escs($batch_name) . "', '" . escs($batch_model) . "', '" . escs($batch_contents) . "', '" . escs($batch_json) . "')"); - header("Location: view-list-$listid"); - die(); - } -} - -$title = "Add batch to " . $list['name']; -$fields = array( - array("label" => "Name : ", "name" => "name", "value" => $batch_name), - array("label" => "Columns : ", "name" => "model", "value" => $batch_model), - array("label" => "Contents : ", "name" => "contents", "type" => "textarea", "value" => $batch_contents) -); -$validate = "Add batch"; - -require("tpl/list/ef.php"); diff --git a/lib/list/edbatch.php b/lib/list/edbatch.php deleted file mode 100644 index 380ecf2..0000000 --- a/lib/list/edbatch.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php - -require("lib/list/inc_process.php"); - -assert_redir(count($args) == 3, 'list'); -$batchid = intval($args[2]); - -$batch = mysql_fetch_assoc(sql( - "SELECT lists.id AS listid, lists.owner AS listowner, lists.name AS listname, batches.name AS name, ". - "batches.model AS model, batches.contents AS contents ". - "FROM batches LEFT JOIN lists ON lists.id = batches.list ". - "WHERE batches.id = $batchid")); -assert_error($batch && $batch['listowner'] == $user['id'], - "this batch does not exist, or you are not allowed to edit it."); -$list = array("id" => $batch['listid'], 'name' => $batch['listname']); - -$batch_name = $batch['name']; -$batch_model = $batch['model']; -$batch_contents = $batch['contents']; -if (isset($_POST['name']) && isset($_POST['model']) && isset($_POST['contents'])) { - $batch_name = esca($_POST['name']); - $batch_model = esca($_POST['model']); - $batch_contents = esca($_POST['contents']); - $batch_json = mk_batch_json($batch_model, $batch_contents); - if ($batch_name == "") { - $error = "You must give a name to this batch."; - } else if (mysql_fetch_assoc(sql("SELECT id FROM batches WHERE list = " . $list['id'] . " AND name = '" . escs($batch_name) . "' AND id != $batchid"))) { - $error = "You already have a batch using that name."; - } else { - sql( - "UPDATE batches SET name = '" . escs($batch_name) . "', model = '" . escs($batch_model) . "', ". - "contents = '" . escs($batch_contents) . "', json_data = '" . escs($batch_json) . "' WHERE id = $batchid" - ); - header("Location: view-list-" . $list['id']); - die(); - } -} - -$title = "Edit batch in " . $list['name']; -$fields = array( - array("label" => "Name : ", "name" => "name", "value" => $batch_name), - array("label" => "Columns : ", "name" => "model", "value" => $batch_model), - array("label" => "Contents : ", "name" => "contents", "type" => "textarea", "value" => $batch_contents) -); -$validate = "Edit batch"; - -require("tpl/list/ef.php"); diff --git a/lib/list/edit.php b/lib/list/edit.php deleted file mode 100644 index 64394be..0000000 --- a/lib/list/edit.php +++ /dev/null @@ -1,43 +0,0 @@ -<?php - -require("lib/markdown.php"); - -assert_redir(count($args) == 3, 'list'); -$listid = intval($args[2]); - -$list = mysql_fetch_assoc(sql( - "SELECT lists.id AS id, lists.name AS name, lists.comment_md AS comment, account.id AS owner_id ". - "FROM lists LEFT JOIN account ON account.id = lists.owner ". - "WHERE lists.id = $listid")); -assert_error($list && $list['owner_id'] == $user['id'], - "This list does not exist, or you are not allowed to edit it."); - -$list_name = $list['name']; -$list_comment = $list['comment']; -if (isset($_POST['name']) && isset($_POST['comment'])) { - $list_name = esca($_POST['name']); - $list_comment = esca($_POST['comment']); - $list_comment_html = Markdown($list_comment); - if ($list_name == "") { - $error = "You must enter a name for your list."; - } else if (mysql_fetch_assoc(sql("SELECT id FROM lists WHERE owner = " . $user['id'] . " AND name = '" . escs($list_name) . "' AND id != $listid"))) { - $error = "You already have a list with that title."; - } else if ($list_comment == "") { - $error = "Please enter a comment on your list."; - } else { - sql("UPDATE lists SET name = '" . escs($list_name) . "', comment_md = '" . escs($list_comment) . - "', comment_html = '" . escs($list_comment_html) . "' WHERE id = $listid"); - header("Location: view-list-" . $listid); - die(); - } -} - -$title = "Edit list : " . $list['name']; -$fields = array( - array("label" => "Name : ", "name" => "name", "value" => $list_name), - array("label" => "Comment : ", "name" => "comment", "type" => "textarea", "value" => $list_comment), -); -$validate = "Edit list"; - -require("tpl/list/ef.php"); - diff --git a/lib/list/inc_process.php b/lib/list/inc_process.php deleted file mode 100644 index 0c7dd82..0000000 --- a/lib/list/inc_process.php +++ /dev/null @@ -1,40 +0,0 @@ -<?php - -require("lib/JSON/inc_json.php"); -require("lib/list/list_models.php"); - -function mk_batch_json($models, $contents) { - global $list_models; - - $data = array("columns" => array(), "items" => array(), "questions" => array()); - - if ($models[0] == '*') { - $model = $list_models[substr($models, 1)]; - - $columns = $data['columns'] = $model['columns']; - $data['questions'] = $model['questions']; - } else { - $columns = explode('|', $models); - - foreach ($columns as $k => $c) { - if ($c[0] == '!') { - $data['columns'][] = substr($c, 1); - } else { - $data['columns'][] = $c; - $data['questions'][] = array('col' => $k); - } - } - } - - $items = explode("\n", $contents); - foreach($items as $i) { - $ii = explode('|', str_replace("\r", '', $i)); - if (count($ii) == count($columns)) { - $data['items'][] = $ii; - } - } - - return json_encode($data); -} - - diff --git a/lib/list/index.php b/lib/list/index.php deleted file mode 100644 index cbcad67..0000000 --- a/lib/list/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", -); - -$lists = array(); -$n = sql( - "SELECT lists.id AS id, lists.name AS name, account.login AS owner, COUNT(list_study.id) AS nbUsers ". - "FROM lists LEFT JOIN account ON lists.owner = account.id LEFT JOIN list_study ON list_study.list = lists.id ". - "GROUP BY lists.id ORDER BY " . get_filter("order") . " " . get_filter("way") - ); -while ($nn = mysql_fetch_assoc($n)) $lists[] = $nn; - -require("tpl/list/index.php"); - diff --git a/lib/list/list_models.php b/lib/list/list_models.php deleted file mode 100644 index b68b538..0000000 --- a/lib/list/list_models.php +++ /dev/null @@ -1,39 +0,0 @@ -<?php - -$list_models = array( - "RTK-Kanji" => array( - "columns" => array("N#", "Kanji", "Keyword", "Strokes"), - "questions" => array( - array( - 'q' => '<p class="rtk_kr_q_2">%2</p>', - 'a' => '<p class="rtk_kr_a_2">#%0: %2 [%3]<br /><span>%1</span></p>' - ), - array( - 'q' => '<p class="rtk_kr_q_1">%1</p>', - 'a' => '<p class="rtk_kr_a_1">#%0: %1 [%3]<br /><span>%2</span></p>' - ), - ), - ), - "JA-Vocab" => array( - "columns" => array("N#", "Kanji", "Kana", "English"), - "questions" => array( - array( - 'q' => '<p class="vocabqa">%3</p>', - 'a' => '<p class="vocaba"><span class="vocabreading">%2</span><br />%1<br /><span>%3</span></p>', - ), - array( - 'q' => '<p class="vocabqb">%1</p>', - 'a' => '<p class="vocaba"><span class="vocabreading">%2</span><br />%1<br /><span>%3</span></p>', - ), - ), - ), - "JA-Vocab-fr" => array( - "columns" => array("N#", "Kanji", "Kana", "French"), - "questions" => array( - array( - 'q' => '<p class="vocabqb">%1</p>', - 'a' => '<p class="vocaba"><span class="vocabreading">%2</span><br />%1<br /><span>%3</span></p>', - ), - ), - ), -); diff --git a/lib/list/new.php b/lib/list/new.php deleted file mode 100644 index 9a9c801..0000000 --- a/lib/list/new.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php - -require("lib/markdown.php"); - -$list_name = ""; -$list_comment = ""; -if (isset($_POST["name"]) && isset($_POST['comment'])) { - $list_name = esca($_POST['name']); - $list_comment = esca($_POST['comment']); - $list_comment_html = Markdown($list_comment); - if ($list_name == "") { - $error = "You must enter a name for your list."; - } else if (mysql_fetch_assoc(sql("SELECT id FROM lists WHERE owner = " . $user['id'] . " AND name = '" . escs($list_name) . "'"))) { - $error = "You already have a list with that title."; - } else if ($list_comment == "") { - $error = "Please enter a comment on your list."; - } else { - sql("INSERT INTO lists(owner, name, comment_md, comment_html) ". - "VALUES(" . $user['id'] . ", '" . escs($list_name) . "', '" . escs($list_comment) . "', '" . escs($list_comment_html) . "')"); - header("Location: view-list-" . mysql_insert_id()); - die(); - } -} - -$title = "Create list"; -$fields = array( - array("label" => "Name : ", "name" => "name", "value" => $list_name), - array("label" => "Comment : ", "name" => "comment", "type" => "textarea", "value" => $list_comment), - ); -$validate = "Create list"; - -require("tpl/list/new.php"); - diff --git a/lib/list/rmbatch.php b/lib/list/rmbatch.php deleted file mode 100644 index 90ea370..0000000 --- a/lib/list/rmbatch.php +++ /dev/null @@ -1,20 +0,0 @@ -<?php - -assert_redir(count($args) >= 3, 'list'); -$batchid = intval($args[2]); - -$batch = mysql_fetch_assoc(sql( - "SELECT lists.id AS listid, lists.owner AS listowner, lists.name AS listname, batches.name AS name, ". - "batches.model AS model, batches.contents AS contents ". - "FROM batches LEFT JOIN lists ON lists.id = batches.list ". - "WHERE batches.id = $batchid")); -assert_error($batch && $batch['listowner'] == $user['id'], - "this batch does not exist, or you are not allowed to edit it."); - -token_validate("Do you really want to delete this batch ?", "view-list-" . $batch['listid']); - -sql("DELETE FROM batches WHERE id = $batchid"); -sql("DELETE FROM batch_study WHERE batch = $batchid"); -sql("DELETE FROM batch_review WHERE batch = $batchid"); -header("Location: view-list-" . $batch['listid']); -die(); diff --git a/lib/list/view.php b/lib/list/view.php deleted file mode 100644 index 2055523..0000000 --- a/lib/list/view.php +++ /dev/null @@ -1,31 +0,0 @@ -<?php - -assert_redir(count($args) == 3, 'list'); -$listid = intval($args[2]); - -$list = mysql_fetch_assoc(sql( - "SELECT lists.id AS id, lists.name AS name, lists.comment_html AS comment, account.login AS owner, ". - "account.id AS owner_id ". - "FROM lists LEFT JOIN account ON account.id = lists.owner ". - "WHERE lists.id = $listid")); -assert_error($list, "This list does not exist."); - -$can_edit = false; -if ($list["owner_id"] == $user['id']) $can_edit = true; - -$batches = array(); -$n = sql( - "SELECT id, name FROM batches WHERE list = $listid ". - "ORDER BY name ASC" - ); -while ($nn = mysql_fetch_assoc($n)) $batches[] = $nn; - -$can_start_study = false; -if ($user['id'] != 0) { - if (!mysql_fetch_assoc(sql("SELECT id FROM list_study WHERE list = $listid AND user = " . $user['id']))) - $can_start_study = true; -} else { - $message = "You should create an account in order to study this list."; -} - -require("tpl/list/view.php"); |