diff --git a/add-single.php b/add-single.php
index 03ddda8..ce98e1d 100644
--- a/add-single.php
+++ b/add-single.php
@@ -15,9 +15,20 @@
include_once("fof-main.php");
$url = $_REQUEST['url'];
+$tags = $_REQUEST['tags'];
$unread = $_REQUEST['unread'];
-$error = fof_subscribe(fof_current_user(), $url, $unread);
+list($error, $feed) = fof_subscribe(fof_current_user(), $url, $unread);
+$error .= '
';
+foreach (preg_split("/[\s,]*,[\s,]*/", $tags) as $tag)
+{
+ if ($tag)
+ {
+ fof_tag_feed(fof_current_user(), $feed['feed_id'], $tag);
+ $error .= 'Tagged \''.htmlspecialchars($feed['feed_title']).'\' as '.htmlspecialchars($tag).'
';
+ }
+}
+
if (preg_match('/HTTP 401/', $error))
print "";
print $error;
-?>
diff --git a/add-tag.php b/add-tag.php
index 06eb193..abc206d 100644
--- a/add-tag.php
+++ b/add-tag.php
@@ -29,4 +29,3 @@ foreach(preg_split("/[\s,]*,[\s,]*/", $tags) as $tag)
fof_tag_item(fof_current_user(), $item, $tag);
}
}
-?>
diff --git a/add.php b/add.php
index 2162824..35f0c85 100644
--- a/add.php
+++ b/add.php
@@ -17,6 +17,7 @@
include("header.php");
$url = $_REQUEST['rss_url'];
+$new_tags = $_REQUEST['new_tags'];
$login = $_REQUEST['basic_login'];
$password = $_REQUEST['basic_password'];
$opml = $_REQUEST['opml_url'];
@@ -91,7 +92,8 @@ When adding feeds, mark
OPML import
@@ -124,14 +126,11 @@ if(count($feeds))
print("");
}
-print("
");
+print("
");
include("footer.php");
-?>
diff --git a/fof-db.php b/fof-db.php
index f628f02..d789e2f 100644
--- a/fof-db.php
+++ b/fof-db.php
@@ -257,7 +257,7 @@ function fof_db_add_feed($url, $title, $link, $description)
fof_safe_query("insert into $FOF_FEED_TABLE (feed_url,feed_title,feed_link,feed_description) values ('%s', '%s', '%s', '%s')", $url, $title, $link, $description);
- return(mysql_insert_id($fof_connection));
+ return mysql_insert_id($fof_connection);
}
function fof_db_add_subscription($user_id, $feed_id)
@@ -274,9 +274,7 @@ function fof_db_delete_subscription($user_id, $feed_id)
$result = fof_db_get_items($user_id, $feed_id, $what="all", NULL, NULL);
foreach($result as $r)
- {
$items[] = $r['item_id'];
- }
fof_safe_query("delete from $FOF_SUBSCRIPTION_TABLE where feed_id = %d and user_id = %d", $feed_id, $user_id);
@@ -304,14 +302,10 @@ function fof_db_find_item($feed_id, $item_guid)
$result = fof_safe_query("select item_id from $FOF_ITEM_TABLE where feed_id=%d and item_guid='%s'", $feed_id, $item_guid);
$row = mysql_fetch_array($result);
- if(mysql_num_rows($result) == 0)
- {
+ if (mysql_num_rows($result) == 0)
return NULL;
- }
else
- {
return($row['item_id']);
- }
}
$fof_db_item_fields = array('item_guid', 'item_link', 'item_title', 'item_author', 'item_content', 'item_cached', 'item_published', 'item_updated');
@@ -658,25 +652,17 @@ function fof_db_mark_feed_read($user_id, $feed_id)
fof_db_untag_items($user_id, 1, $items);
}
-function fof_db_mark_feed_unread($user_id, $feed, $what)
+function fof_db_mark_feed_unread($user_id, $feed_id, $what)
{
- global $FOF_ITEM_TAG_TABLE;
+ fof_log("fof_db_mark_feed_unread($user_id, $feed_id, $what)");
- fof_log("fof_db_mark_feed_unread($user_id, $feed, $what)");
-
- if($what == "all")
- {
- $result = fof_db_get_items($user_id, $feed, "all");
- }
- if($what == "today")
- {
- $result = fof_db_get_items($user_id, $feed, "all", "today");
- }
+ if ($what == "all")
+ $result = fof_db_get_items($user_id, $feed_id, "all");
+ elseif ($what == "today")
+ $result = fof_db_get_items($user_id, $feed_id, "all", "today");
foreach((array)$result as $r)
- {
$items[] = $r['item_id'];
- }
fof_db_tag_items($user_id, 1, $items);
}
diff --git a/fof-main.php b/fof-main.php
index a10fe36..8186e36 100644
--- a/fof-main.php
+++ b/fof-main.php
@@ -609,34 +609,32 @@ function fof_prepare_url($url)
return $url;
}
-function fof_subscribe($user_id, $url, $unread="today")
+function fof_subscribe($user_id, $url, $unread = "today")
{
- if(!$url) return false;
+ if (!$url)
+ return array("Empty URL", false);
$url = fof_prepare_url($url);
$feed = fof_db_get_feed_by_url($url);
- if(fof_is_subscribed($user_id, $url))
- {
- return "You are already subscribed to " . fof_render_feed_link($feed) . "
";
- }
+ if (fof_is_subscribed($user_id, $url))
+ return array("You are already subscribed to " . fof_render_feed_link($feed), $feed);
- if(fof_feed_exists($url))
+ if (fof_feed_exists($url))
{
fof_db_add_subscription($user_id, $feed['feed_id']);
fof_apply_plugin_tags($id, NULL, $user_id);
fof_update_feed($feed['feed_id']);
- if($unread != "no") fof_db_mark_feed_unread($user_id, $feed['feed_id'], $unread);
- return 'Subscribed.
';
+ if ($unread != "no")
+ fof_db_mark_feed_unread($user_id, $feed['feed_id'], $unread);
+ return array('Subscribed.', $feed);
}
$rss = fof_parse($url, $user_id);
if (isset($rss->error))
- {
- return "Error: " . $rss->error . "
";
- }
+ return array("Error: " . $rss->error . "", $feed);
else
{
$url = html_entity_decode($rss->subscribe_url(), ENT_QUOTES);
@@ -645,45 +643,45 @@ function fof_subscribe($user_id, $url, $unread="today")
// Why? 1) handling broken feeds 2) handling authorized feeds 3) user knows URL better
//if($self) $url = html_entity_decode($self, ENT_QUOTES);
- if(fof_feed_exists($url))
+ if (fof_feed_exists($url))
{
$feed = fof_db_get_feed_by_url($url);
- if(fof_is_subscribed($user_id, $url))
- {
- return "You are already subscribed to " . fof_render_feed_link($feed) . "
";
- }
+ if (fof_is_subscribed($user_id, $url))
+ return array("You are already subscribed to " . fof_render_feed_link($feed), $feed);
fof_db_add_subscription($user_id, $feed['feed_id']);
- if($unread != "no") fof_db_mark_feed_unread($user_id, $feed['feed_id'], $unread);
+ if ($unread != "no")
+ fof_db_mark_feed_unread($user_id, $feed['feed_id'], $unread);
- return 'Subscribed.
';
+ return array('Subscribed.', $feed);
}
- $id = fof_add_feed($url, rss_feed_title($rss), $rss->get_link(), $rss->get_description() );
+ $id = fof_add_feed($url, rss_feed_title($rss), $rss->get_link(), $rss->get_description());
fof_update_feed($id);
fof_db_add_subscription($user_id, $id);
- if($unread != "no") fof_db_mark_feed_unread($user_id, $id, $unread);
+ if ($unread != "no")
+ fof_db_mark_feed_unread($user_id, $id, $unread);
fof_apply_plugin_tags($id, NULL, $user_id);
- return "Subscribed.
";
+ $feed = fof_db_get_feed_by_id($id);
+ return array('Subscribed.', $feed);
}
}
function fof_add_feed($url, $title, $link, $description)
{
- if($title == "") $title = "[no title]";
+ if ($title == "")
+ $title = "[no title]";
- $id = fof_db_add_feed($url, $title, $link, $description);
-
- return $id;
+ return fof_db_add_feed($url, $title, $link, $description);
}
function fof_is_subscribed($user_id, $url)
{
- return(fof_db_is_subscribed($user_id, $url));
+ return fof_db_is_subscribed($user_id, $url);
}
function fof_feed_exists($url)
diff --git a/fof.js b/fof.js
index 0bdb95b..181d2a8 100644
--- a/fof.js
+++ b/fof.js
@@ -884,14 +884,16 @@ function continueupdate()
function continueadd()
{
var feed, f, m, dispUrl;
- if(feed = feedi())
+ if (feed = feedi())
{
f = feed();
dispUrl = f['url'].replace(/^([a-z]+:\/\/[^\/]+:)([^\/]+)(@.*)$/, '$1******$3');
new Insertion.Bottom($('items'), 'Adding ' + dispUrl + "... ");
$('items').childElements().last().scrollTo();
- parameters = 'url=' + encodeURIComponent(f['url']) + "&unread=" + document.addform.unread.value;
+ var parameters = 'url=' + encodeURIComponent(f['url']);
+ parameters += "&unread=" + document.addform.unread.value;
+ parameters += "&tags=" + document.addform.new_tags.value;
new Ajax.Updater('items', 'add-single.php', {
method: 'get',
@@ -903,7 +905,7 @@ function continueadd()
}
else
{
- new Insertion.Bottom($('items'), '
Done!');
+ new Insertion.Bottom($('items'), '
Done!');
refreshlist();
}
}
diff --git a/login-external.php b/login-external.php
index f471d5f..4fe741f 100644
--- a/login-external.php
+++ b/login-external.php
@@ -137,9 +137,9 @@ function globalauth($url, $require = true)
function fof_tag_subscribe($userid, $url, $tag)
{
- $id = fof_subscribe($userid, $url);
- if (preg_match('//is', $id, $m))
- fof_tag_feed($userid, 0+$m[1], $tag);
+ list($error, $feed) = fof_subscribe($userid, $url);
+ if ($feed)
+ fof_tag_feed($userid, $feed['feed_id'], $tag);
}
/* Добавление фидов для новых юзеров */
diff --git a/prefs.php b/prefs.php
index 3f78087..7162870 100644
--- a/prefs.php
+++ b/prefs.php
@@ -56,7 +56,7 @@ if (isset($_REQUEST['tagfeeds']))
}
}
// add tags
- else if ($prop == 'tag')
+ elseif ($prop == 'tag')
{
foreach (preg_split("/[\s,]*,[\s,]*/", $v) as $tag)
{
@@ -68,7 +68,7 @@ if (isset($_REQUEST['tagfeeds']))
}
}
// change filter
- else if ($prop == 'filter')
+ elseif ($prop == 'filter')
{
if (fof_db_set_feedprop(fof_current_user(), $feed_id, 'filter', $v))
$message[] = 'Set filter \''.htmlspecialchars($v).'\' for feed \''.htmlspecialchars($_REQUEST["title_$feed_id"]).'\'';