From 5c7c7da9e12134ae2c4be1f60823e5440015f0ca Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 7 Nov 2010 23:30:05 +0300 Subject: allow adding cats from feed editor --- modules/backend-rpc.php | 25 +++++++++++++++++++++++++ modules/pref-feeds.php | 18 ++---------------- 2 files changed, 27 insertions(+), 16 deletions(-) (limited to 'modules') diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php index fee93a586..4a82a888b 100644 --- a/modules/backend-rpc.php +++ b/modules/backend-rpc.php @@ -1094,6 +1094,31 @@ return; } + if ($subop == "quickAddCat") { + print ""; + + $cat = db_escape_string($_REQUEST["cat"]); + + add_feed_category($link, $cat); + + $result = db_query($link, "SELECT id FROM ttrss_feed_categories WHERE + title = '$cat' AND owner_uid = " . $_SESSION["uid"]); + + if (db_num_rows($result) == 1) { + $id = db_fetch_result($result, 0, "id"); + } else { + $id = 0; + } + + print ""; + + print ""; + + return; + } + print "Unknown method: $subop"; } ?> diff --git a/modules/pref-feeds.php b/modules/pref-feeds.php index 376980ce3..7a436cfd2 100644 --- a/modules/pref-feeds.php +++ b/modules/pref-feeds.php @@ -1031,24 +1031,10 @@ if ($action == "add") { - $feed_cat = db_escape_string(trim($_REQUEST["cat"])); - $result = db_query($link, - "SELECT id FROM ttrss_feed_categories - WHERE 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')"); - - } else { - - print_warning(T_sprintf("Category $%s already exists in the database.", - $feed_cat)); - } + if (!add_feed_category($link, $feed_cat)) + print_warning(T_sprintf("Category $%s already exists in the database.", $feed_cat)); } -- cgit v1.2.3