place imported feeds in a separate category unless otherwise specified (closes #162)
This commit is contained in:
parent
5a68dec1df
commit
c03cf250e8
3 changed files with 44 additions and 4 deletions
|
@ -4,6 +4,16 @@
|
||||||
if (is_file($_FILES['opml_file']['tmp_name'])) {
|
if (is_file($_FILES['opml_file']['tmp_name'])) {
|
||||||
$doc = DOMDocument::load($_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) {
|
if ($doc) {
|
||||||
$body = $doc->getElementsByTagName('body');
|
$body = $doc->getElementsByTagName('body');
|
||||||
|
|
||||||
|
@ -101,8 +111,9 @@
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$add_query = "INSERT INTO ttrss_feeds
|
$add_query = "INSERT INTO ttrss_feeds
|
||||||
(title, feed_url, owner_uid, site_url) VALUES
|
(title, feed_url, owner_uid, cat_id, site_url) VALUES
|
||||||
('$feed_title', '$feed_url', '$owner_uid', '$site_url')";
|
('$feed_title', '$feed_url', '$owner_uid', '$default_cat_id',
|
||||||
|
'$site_url')";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,16 @@
|
||||||
if (is_file($_FILES['opml_file']['tmp_name'])) {
|
if (is_file($_FILES['opml_file']['tmp_name'])) {
|
||||||
$dom = domxml_open_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) {
|
if ($dom) {
|
||||||
$root = $dom->document_element();
|
$root = $dom->document_element();
|
||||||
|
|
||||||
|
@ -104,8 +114,9 @@
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$add_query = "INSERT INTO ttrss_feeds
|
$add_query = "INSERT INTO ttrss_feeds
|
||||||
(title, feed_url, owner_uid, site_url) VALUES
|
(title, feed_url, owner_uid, cat_id, site_url) VALUES
|
||||||
('$feed_title', '$feed_url', '$owner_uid', '$site_url')";
|
('$feed_title', '$feed_url', '$owner_uid', '$default_cat_id',
|
||||||
|
'$site_url')";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
18
opml.php
18
opml.php
|
@ -111,6 +111,24 @@
|
||||||
<div class=\"floatingLogo\"><img src=\"images/ttrss_logo.png\"></div>
|
<div class=\"floatingLogo\"><img src=\"images/ttrss_logo.png\"></div>
|
||||||
<h1>".__('OPML Utility')."</h1>";
|
<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')) {
|
if (function_exists('domxml_open_file')) {
|
||||||
print "<p>".__("Importing OPML (using DOMXML extension)...")."</p>";
|
print "<p>".__("Importing OPML (using DOMXML extension)...")."</p>";
|
||||||
require_once "modules/opml_domxml.php";
|
require_once "modules/opml_domxml.php";
|
||||||
|
|
Loading…
Reference in a new issue