Allow to tag new feeds on adding
parent
11e280dbbe
commit
098d962eb4
|
@ -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 .= '<br />';
|
||||
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).'<br />';
|
||||
}
|
||||
}
|
||||
|
||||
if (preg_match('/HTTP 401/', $error))
|
||||
print "<script>
|
||||
document.addform.basic_login.style.backgroundColor='#FFC0C0';
|
||||
|
@ -25,4 +36,3 @@ document.addform.basic_password.style.backgroundColor='#FFC0C0';
|
|||
document.addform.basic_password.focus();
|
||||
</script>";
|
||||
print $error;
|
||||
?>
|
||||
|
|
|
@ -29,4 +29,3 @@ foreach(preg_split("/[\s,]*,[\s,]*/", $tags) as $tag)
|
|||
fof_tag_item(fof_current_user(), $item, $tag);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
9
add.php
9
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 <select name="unread"><option value=today <?= $unread ==
|
|||
|
||||
<p>
|
||||
RSS or weblog URL: <input type="text" name="rss_url" size="40" value="<?= htmlspecialchars($url) ?>" /> <input name="do" type="Submit" value="Add a feed" /><br />
|
||||
Login: <input type="text" name="basic_login" value="<?= htmlspecialchars($login) ?>" /> Password: <input type="password" name="basic_password" value="<?= htmlspecialchars($password) ?>" /> (optional) for password-protected feeds
|
||||
Login: <input type="text" name="basic_login" value="<?= htmlspecialchars($login) ?>" /> Password: <input type="password" name="basic_password" value="<?= htmlspecialchars($password) ?>" /> (optional) for password-protected feeds<br />
|
||||
Tags for new feed(s): <input type="text" name="new_tags" size="40" value="<?= htmlspecialchars($new_tags) ?>" /> (separate by comma)
|
||||
</p>
|
||||
|
||||
<h1>OPML import</h1>
|
||||
|
@ -124,14 +126,11 @@ if(count($feeds))
|
|||
print("<script>\nwindow.onload = ajaxadd;\nfeedslist = [");
|
||||
|
||||
foreach($feeds as $feed)
|
||||
{
|
||||
$feedjson[] = "{'url': '" . addslashes($feed) . "'}";
|
||||
}
|
||||
|
||||
print(join($feedjson, ", "));
|
||||
print("];\n</script>");
|
||||
}
|
||||
print("<br>");
|
||||
print("<br />");
|
||||
|
||||
include("footer.php");
|
||||
?>
|
||||
|
|
26
fof-db.php
26
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);
|
||||
|
||||
|
@ -305,14 +303,10 @@ function fof_db_find_item($feed_id, $item_guid)
|
|||
$row = mysql_fetch_array($result);
|
||||
|
||||
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');
|
||||
function fof_db_add_item($feed_id, $item)
|
||||
|
@ -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, $what)");
|
||||
fof_log("fof_db_mark_feed_unread($user_id, $feed_id, $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");
|
||||
}
|
||||
$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);
|
||||
}
|
||||
|
|
40
fof-main.php
40
fof-main.php
|
@ -611,15 +611,14 @@ function fof_prepare_url($url)
|
|||
|
||||
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) . "<br>";
|
||||
}
|
||||
return array("You are already subscribed to " . fof_render_feed_link($feed), $feed);
|
||||
|
||||
if (fof_feed_exists($url))
|
||||
{
|
||||
|
@ -627,16 +626,15 @@ function fof_subscribe($user_id, $url, $unread="today")
|
|||
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 '<font color="green"><b>Subscribed.</b></font><!-- '.$feed['feed_id'].' --><br>';
|
||||
if ($unread != "no")
|
||||
fof_db_mark_feed_unread($user_id, $feed['feed_id'], $unread);
|
||||
return array('<font color="green"><b>Subscribed.</b></font>', $feed);
|
||||
}
|
||||
|
||||
$rss = fof_parse($url, $user_id);
|
||||
|
||||
if (isset($rss->error))
|
||||
{
|
||||
return "Error: <b>" . $rss->error . "</b><br />";
|
||||
}
|
||||
return array("Error: <b>" . $rss->error . "</b>", $feed);
|
||||
else
|
||||
{
|
||||
$url = html_entity_decode($rss->subscribe_url(), ENT_QUOTES);
|
||||
|
@ -650,40 +648,40 @@ function fof_subscribe($user_id, $url, $unread="today")
|
|||
$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) . "<br>";
|
||||
}
|
||||
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 '<font color="green"><b>Subscribed.</b></font><!-- '.$feed['feed_id'].' --><br>';
|
||||
return array('<font color="green"><b>Subscribed.</b></font>', $feed);
|
||||
}
|
||||
|
||||
$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 "<font color='green'><b>Subscribed.</b></font><!-- $id --><br>";
|
||||
$feed = fof_db_get_feed_by_id($id);
|
||||
return array('<font color="green"><b>Subscribed.</b></font>', $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)
|
||||
|
|
6
fof.js
6
fof.js
|
@ -891,7 +891,9 @@ function continueadd()
|
|||
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'), '<br>Done!');
|
||||
new Insertion.Bottom($('items'), '<br />Done!');
|
||||
refreshlist();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,9 +137,9 @@ function globalauth($url, $require = true)
|
|||
|
||||
function fof_tag_subscribe($userid, $url, $tag)
|
||||
{
|
||||
$id = fof_subscribe($userid, $url);
|
||||
if (preg_match('/<!-- (\d+) -->/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);
|
||||
}
|
||||
|
||||
/* Добавление фидов для новых юзеров */
|
||||
|
|
Loading…
Reference in New Issue