]> git.wh0rd.org Git - tt-rss.git/commitdiff
place imported feeds in a separate category unless otherwise specified (closes #162)
authorAndrew Dolgov <fox@bah.spb.su>
Sat, 17 Nov 2007 09:23:44 +0000 (10:23 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Sat, 17 Nov 2007 09:23:44 +0000 (10:23 +0100)
modules/opml_domdoc.php
modules/opml_domxml.php
opml.php

index 98eba69fa41f4eec6777c2351e244ce3b7115bff..1c0404c342f423b4e78fb85a20673f14bbaad209 100644 (file)
@@ -4,6 +4,16 @@
                if (is_file($_FILES['opml_file']['tmp_name'])) {
                        $doc = DOMDocument::load($_FILES['opml_file']['tmp_name']);
 
+                       $result = db_query($link, "SELECT id FROM
+                               ttrss_feed_categories WHERE title = 'Imported feeds' AND
+                               owner_uid = '$owner_uid' LIMIT 1");
+
+                       if (db_num_rows($result) == 1) {
+                               $default_cat_id = db_fetch_result($result, 0, "id");
+                       } else {
+                               $default_cat_id = 0;
+                       }
+
                        if ($doc) {
                                $body = $doc->getElementsByTagName('body');
 
 
                                                } else {
                                                        $add_query = "INSERT INTO ttrss_feeds 
-                                                               (title, feed_url, owner_uid, site_url) VALUES
-                                                               ('$feed_title', '$feed_url', '$owner_uid', '$site_url')";
+                                                               (title, feed_url, owner_uid, cat_id, site_url) VALUES
+                                                               ('$feed_title', '$feed_url', '$owner_uid', '$default_cat_id', 
+                                                                       '$site_url')";
 
                                                }
 
index 54ec76b907681993fa2a00edd2d68f1fd9d52b47..5b1e4067dc6405fd98eabb7dd01ea118a6052d03 100644 (file)
@@ -4,6 +4,16 @@
                if (is_file($_FILES['opml_file']['tmp_name'])) {
                        $dom = domxml_open_file($_FILES['opml_file']['tmp_name']);
 
+                       $result = db_query($link, "SELECT id FROM
+                               ttrss_feed_categories WHERE title = 'Imported feeds' AND
+                               owner_uid = '$owner_uid' LIMIT 1");
+
+                       if (db_num_rows($result) == 1) {
+                               $default_cat_id = db_fetch_result($result, 0, "id");
+                       } else {
+                               $default_cat_id = 0;
+                       }
+
                        if ($dom) {
                                $root = $dom->document_element();
 
 
                                                        } else {
                                                                $add_query = "INSERT INTO ttrss_feeds 
-                                                                       (title, feed_url, owner_uid, site_url) VALUES
-                                                                       ('$feed_title', '$feed_url', '$owner_uid', '$site_url')";
+                                                                       (title, feed_url, owner_uid, cat_id, site_url) VALUES
+                                                                       ('$feed_title', '$feed_url', '$owner_uid', '$default_cat_id',
+                                                                               '$site_url')";
 
                                                        }
 
index 883ddd0d923201f5a3ed492082877f4cd020c97e..35d7a070c8ae1a17896df8e52cc66a652fd6cffc 100644 (file)
--- a/opml.php
+++ b/opml.php
                        <div class=\"floatingLogo\"><img src=\"images/ttrss_logo.png\"></div>
                        <h1>".__('OPML Utility')."</h1>";
 
+               db_query($link, "BEGIN");
+
+               /* create Imported feeds category just in case */
+
+               $result = db_query($link, "SELECT id FROM
+                       ttrss_feed_categories WHERE title = 'Imported feeds' AND
+                       owner_uid = '$owner_uid' LIMIT 1");
+
+               if (db_num_rows($result) == 0) {
+                               db_query($link, "INSERT INTO ttrss_feed_categories
+                                       (title,owner_uid) 
+                                               VALUES ('Imported feeds', '$owner_uid')");
+               }
+
+               db_query($link, "COMMIT");
+
+               /* Handle OPML import by DOMXML/DOMDocument */
+
                if (function_exists('domxml_open_file')) {
                        print "<p>".__("Importing OPML (using DOMXML extension)...")."</p>";
                        require_once "modules/opml_domxml.php";