summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2012-08-15 15:03:40 +0400
committerAndrew Dolgov <[email protected]>2012-08-15 15:03:40 +0400
commitd2a317e3c897efb854a316858281c67d08972f43 (patch)
tree9e39f084935b8a728b1742be228550e911b39814 /include
parent3a9d5c6e88420336f698ab5239072fc50ae0c1fc (diff)
refactor opml import/export code
fix opml to properly handle nested categories allow creating categories with same name in different parent categories
Diffstat (limited to 'include')
-rw-r--r--include/functions.php36
1 files changed, 32 insertions, 4 deletions
diff --git a/include/functions.php b/include/functions.php
index 91f3b900e..41f6c9db5 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -4293,21 +4293,49 @@
}
}
- function add_feed_category($link, $feed_cat) {
+ function get_feed_category($link, $feed_cat, $parent_cat_id = false) {
+ if ($parent_cat_id) {
+ $parent_qpart = "parent_cat = '$parent_cat_id'";
+ $parent_insert = "'$parent_cat_id'";
+ } else {
+ $parent_qpart = "parent_cat IS NULL";
+ $parent_insert = "NULL";
+ }
+
+ $result = db_query($link,
+ "SELECT id FROM ttrss_feed_categories
+ WHERE $parent_qpart AND title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]);
+
+ if (db_num_rows($result) == 0) {
+ return false;
+ } else {
+ return db_fetch_result($result, 0, "id");
+ }
+ }
+
+ function add_feed_category($link, $feed_cat, $parent_cat_id = false) {
if (!$feed_cat) return false;
db_query($link, "BEGIN");
+ if ($parent_cat_id) {
+ $parent_qpart = "parent_cat = '$parent_cat_id'";
+ $parent_insert = "'$parent_cat_id'";
+ } else {
+ $parent_qpart = "parent_cat IS NULL";
+ $parent_insert = "NULL";
+ }
+
$result = db_query($link,
"SELECT id FROM ttrss_feed_categories
- WHERE title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]);
+ WHERE $parent_qpart AND title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]);
if (db_num_rows($result) == 0) {
$result = db_query($link,
- "INSERT INTO ttrss_feed_categories (owner_uid,title)
- VALUES ('".$_SESSION["uid"]."', '$feed_cat')");
+ "INSERT INTO ttrss_feed_categories (owner_uid,title,parent_cat)
+ VALUES ('".$_SESSION["uid"]."', '$feed_cat', $parent_insert)");
db_query($link, "COMMIT");