require_once "modules/pref-users.php";
require_once "modules/pref-feed-browser.php";
-
if (!sanity_check($link)) { return; }
if ($op == "rpc") {
module_popup_dialog($link);
}
+ if ($op == "pref-pub-items") {
+ module_pref_pub_items($link);
+ }
+
+
// update feeds of all users, may be used anonymously
if ($op == "globalUpdateFeeds") {
SET unread = false,last_read = NOW()
WHERE marked = true AND owner_uid = ".$_SESSION["uid"]);
}
-
+
+ if ($feed == -2) {
+ db_query($link, "UPDATE ttrss_user_entries
+ SET unread = false,last_read = NOW()
+ WHERE published = true AND owner_uid = ".$_SESSION["uid"]);
+ }
+
} else if ($feed < -10) { // label
// TODO make this more efficient
return getCategoryUnread($link, $n_feed);
} else if ($n_feed == -1) {
$match_part = "marked = true";
+ } else if ($n_feed == -2) {
+ $match_part = "published = true";
} else if ($n_feed > 0) {
$result = db_query($link, "SELECT id FROM ttrss_feeds
$result = db_query($link, "SELECT count(ttrss_entries.id) as count FROM ttrss_entries,ttrss_user_entries,ttrss_feeds
WHERE marked = true AND ttrss_user_entries.ref_id = ttrss_entries.id AND
ttrss_user_entries.feed_id = ttrss_feeds.id AND
- unread = true AND ttrss_user_entries.owner_uid = ".$_SESSION["uid"]);
+ hidden = false AND unread = true AND ttrss_user_entries.owner_uid = ".$_SESSION["uid"]);
$count = db_fetch_result($result, 0, "count");
$ret_arr["-1"]["description"] = "Starred";
}
+ $result = db_query($link, "SELECT count(ttrss_entries.id) as count FROM ttrss_entries,ttrss_user_entries,ttrss_feeds
+ WHERE published = true AND ttrss_user_entries.ref_id = ttrss_entries.id AND
+ ttrss_user_entries.feed_id = ttrss_feeds.id AND
+ hidden = false AND unread = true AND ttrss_user_entries.owner_uid = ".$_SESSION["uid"]);
+
+ $count = db_fetch_result($result, 0, "count");
+
+ if (!$ret_mode) {
+ print "<counter type=\"label\" id=\"-2\" counter=\"$count\"/>";
+ } else {
+ $ret_arr["-2"]["counter"] = $count;
+ $ret_arr["-2"]["description"] = "Published";
+ }
+
+
$result = db_query($link, "SELECT owner_uid,id,sql_exp,description FROM
ttrss_labels WHERE owner_uid = ".$_SESSION["uid"]." ORDER by description");
} else if ($feed == -1) { // starred virtual feed
$query_strategy_part = "marked = true";
$vfeed_query_part = "ttrss_feeds.title AS feed_title,";
+ } else if ($feed == -2) { // published virtual feed
+ $query_strategy_part = "published = true";
+ $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
} else if ($feed <= -10) { // labels
$label_id = -$feed - 11;
} else if ($feed == -1) {
$feed_title = __("Starred articles");
+ } else if ($feed == -2) {
+ $feed_title = __("Published articles");
} else if ($feed < -10) {
$label_id = -$feed - 11;
$result = db_query($link, "SELECT description FROM ttrss_labels
guid,
ttrss_entries.id,ttrss_entries.title,
updated,
- unread,feed_id,marked,link,last_read,
+ unread,feed_id,marked,published,link,last_read,
SUBSTRING(last_read,1,19) as last_read_noms,
$vfeed_query_part
$content_query_part
}
}
+ function publishArticlesById($link, $ids, $cmode) {
+
+ $tmp_ids = array();
+
+ foreach ($ids as $id) {
+ array_push($tmp_ids, "ref_id = '$id'");
+ }
+
+ $ids_qpart = join(" OR ", $tmp_ids);
+
+ if ($cmode == 0) {
+ db_query($link, "UPDATE ttrss_user_entries SET
+ published = false,last_read = NOW()
+ WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
+ } else if ($cmode == 1) {
+ db_query($link, "UPDATE ttrss_user_entries SET
+ published = true
+ WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
+ } else {
+ db_query($link, "UPDATE ttrss_user_entries SET
+ published = NOT published,last_read = NOW()
+ WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
+ }
+ }
+
function catchupArticlesById($link, $ids, $cmode) {
$tmp_ids = array();
$tog_unread_link = "javascript:selectionToggleUnread()";
$tog_marked_link = "javascript:selectionToggleMarked()";
+ $tog_published_link = "javascript:selectionTogglePublished()";
} else {
$tog_unread_link = "javascript:selectionToggleUnread(true)";
$tog_marked_link = "javascript:selectionToggleMarked(true)";
+ $tog_published_link = "javascript:selectionTogglePublished(true)";
}
<li class=\"vsep\"> </li>
<li class=\"top\">Toggle<ul>
<li onclick=\"$tog_unread_link\">".__('Unread')."</li>
- <li onclick=\"$tog_marked_link\">".__('Starred')."</li></ul></li>
+ <li onclick=\"$tog_marked_link\">".__('Starred')."</li>
+ <li onclick=\"$tog_published_link\">".__('Published')."</li>
+ </ul></li>
<li class=\"vsep\"> </li>
<li class=\"top\"><a href=\"$catchup_page_link\">".__('Mark as read')."</a><ul>
<li onclick=\"$catchup_page_link\">".__('This page')."</li>
}
$num_starred = getFeedUnread($link, -1);
+ $num_published = getFeedUnread($link, -2);
$class = "virt";
printFeedEntry(-1, $class, __("Starred articles"), $num_starred,
"images/mark_set.png", $link);
+ $class = "virt";
+
+ if ($num_published > 0) $class .= "Unread";
+
+ printFeedEntry(-2, $class, __("Published articles"), $num_published,
+ "images/pub_set.png", $link);
+
if (get_pref($link, 'ENABLE_FEED_CATS')) {
print "</ul>";
}
alt=\"Set mark\" onclick='javascript:tMark($id)'>";
}
+ if ($line["published"] == "t" || $line["published"] == "1") {
+ $published_pic = "<img id=\"FPPIC-$id\" src=\"images/pub_set.png\"
+ class=\"markedPic\"
+ alt=\"Unpublish\" onclick='javascript:tPub($id)'>";
+ } else {
+ $published_pic = "<img id=\"FPPIC-$id\" src=\"images/pub_unset.png\"
+ class=\"markedPic\"
+ alt=\"Publish\" onclick='javascript:tPub($id)'>";
+ }
+
# $content_link = "<a target=\"_new\" href=\"".$line["link"]."\">" .
# $line["title"] . "</a>";
</td>";
print "<td class='hlMarkedPic'>$marked_pic</td>";
+ print "<td class='hlMarkedPic'>$published_pic</td>";
if ($line["feed_title"]) {
print "<td class='hlContent'>$content_link</td>";
'RROW-$id')\" class=\"feedCheckBox\" id=\"RCHK-$id\">";
print "</span><span class='s1'>$marked_pic</span> ";
+ print "<span class='s1'>$published_pic</span> ";
$tags = get_article_tags($link, $id);
return $tag;
}
+
+ function generate_publish_key() {
+ return sha1(uniqid(rand(), true));
+ }
+
?>
WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
}
+ if ($subop == "publ") {
+ $pub = $_GET["pub"];
+ $id = db_escape_string($_GET["id"]);
+
+ if ($pub == "1") {
+ $mark = "true";
+ } else {
+ $pub = "false";
+ }
+
+ // FIXME this needs collision testing
+
+ $result = db_query($link, "UPDATE ttrss_user_entries SET published = $pub
+ WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
+ }
+
if ($subop == "updateFeed") {
$feed_id = db_escape_string($_GET["feed"]);
print "</rpc-reply>";
}
+ if ($subop == "publishSelected") {
+
+ $ids = split(",", db_escape_string($_GET["ids"]));
+ $cmode = sprintf("%d", $_GET["cmode"]);
+
+ publishArticlesById($link, $ids, $cmode);
+
+ print "<rpc-reply>";
+ print "<counters>";
+ getAllCounters($link);
+ print "</counters>";
+ print_runtime_info($link);
+ print "</rpc-reply>";
+ }
+
if ($subop == "sanityCheck") {
print "<rpc-reply>";
if (sanity_check($link)) {
class=\"button\" onclick=\"gotoExportOpml()\"
value=\"".__('Export OPML')."\">";
+
+ print "<h3>Published articles</h3>";
+
+ if (!get_pref($link, "_PREFS_PUBLISH_KEY")) {
+ set_pref($link, "_PREFS_PUBLISH_KEY", generate_publish_key());
+ }
+
+ print "<p>".__('Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the address specified below.')."</p>";
+
+ $url_path = 'http://' . $_SERVER["HTTP_HOST"] . \
+ parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
+
+ $url_path .= "?op=publish&key=" . get_pref($link, "_PREFS_PUBLISH_KEY");
+
+ print "<p><a id=\"pubGenAddress\" target=\"_new\" href=\"$url_path\">$url_path</a></p>";
+
+ print "<p><input type=\"submit\" onclick=\"return pubRegenKey()\"
+ value=\"".__('Generate another address')."\"></p>";
+
}
?>
var sanity_check_done = false;
-function expand_feed_callback() {
+/*
+function replace_pubkey_callback() {
if (xmlhttp.readyState == 4) {
try {
- var container = document.getElementById("BRDET-" + feed_to_expand);
- container.innerHTML=xmlhttp.responseText;
- container.style.display = "block";
-// p_notify("");
+ var link = document.getElementById("pubGenAddress");
+
+ if (xmlhttp.responseXML) {
+
+
+ } else {
+ notify_error("Error while changing adress");
+ }
} catch (e) {
- exception_error("expand_feed_callback", e);
+ exception_error("replace_pubkey_callback", e);
}
}
-}
+} */
-function pubitems_callback() {
+function expand_feed_callback() {
if (xmlhttp.readyState == 4) {
try {
- var container = document.getElementById('prefContent');
+ var container = document.getElementById("BRDET-" + feed_to_expand);
container.innerHTML=xmlhttp.responseText;
- selectTab("pubItems", true);
-
- if (typeof correctPNG != 'undefined') {
- correctPNG();
- }
- notify("");
+ container.style.display = "block";
+// p_notify("");
} catch (e) {
- exception_error("feedlist_callback", e);
+ exception_error("expand_feed_callback", e);
}
}
}
updateUsersList();
} else if (id == "feedBrowser") {
updateBigFeedBrowser();
- } else if (id == "pubItems") {
- updatePublishedItems();
}
}
updateFeedList()
}
-function updatePublishedItems() {
+/*
+function pubRegenKey() {
+
if (!xmlhttp_ready(xmlhttp)) {
printLockingError();
- return
+ return false;
}
- xmlhttp.open("GET", "backend.php?op=pref-pubitems");
- xmlhttp.onreadystatechange=pubitems_callback;
- xmlhttp.send(null);
+ var ok = confirm("Replace current publishing address with a new one?");
-}
+ if (ok) {
+
+ notify_progress("Trying to change address...");
+
+ xmlhttp.open("GET", "backend.php?op=backend-rpc&subop=regen-pub-key");
+ xmlhttp.onreadystatechange=replace_pubkey_callback;
+ xmlhttp.send(null);
+ }
+
+ return false;
+} */
<div id="feedBrowserTab" class="prefsTab"
onclick="selectTab('feedBrowser')"><?php echo __('Other Feeds') ?></div>
<?php } ?>
- <div id="pubItemsTab" class="prefsTab"
- onclick="selectTab('pubItems')"><?php echo __('Published Articles') ?></div>
+ <!-- <div id="pubItemsTab" class="prefsTab"
+ onclick="selectTab('pubItems')"><?php echo __('Published Articles') ?></div> -->
<div id="filterConfigTab" class="prefsTab"
onclick="selectTab('filterConfig')"><?php echo __('Content Filtering') ?></div>
<?php if (get_pref($link, 'ENABLE_LABELS')) { ?>
return toggleMark(id);
}
+function tPub(id) {
+ return togglePub(id);
+}
+
+
function toggleMark(id) {
if (!xmlhttp_ready(xmlhttp_rpc)) {
}
+function togglePub(id) {
+
+ if (!xmlhttp_ready(xmlhttp_rpc)) {
+ printLockingError();
+ return;
+ }
+
+ var query = "backend.php?op=rpc&id=" + id + "&subop=publ";
+
+ var mark_img = document.getElementById("FPPIC-" + id);
+ var vfeedu = document.getElementById("FEEDU--2");
+ var crow = document.getElementById("RROW-" + id);
+
+ if (mark_img.alt != "Unpublish") {
+ mark_img.src = "images/pub_set.png";
+ mark_img.alt = "Unpublish";
+ query = query + "&pub=1";
+
+ if (vfeedu && crow.className.match("Unread")) {
+ vfeedu.innerHTML = (+vfeedu.innerHTML) + 1;
+ }
+
+ } else {
+ mark_img.src = "images/pub_unset.png";
+ mark_img.alt = "Publish";
+ query = query + "&pub=0";
+
+ if (vfeedu && crow.className.match("Unread")) {
+ vfeedu.innerHTML = (+vfeedu.innerHTML) - 1;
+ }
+
+ }
+
+ var vfeedctr = document.getElementById("FEEDCTR--2");
+ var vfeedr = document.getElementById("FEEDR--2");
+
+ if (vfeedu && vfeedctr) {
+ if ((+vfeedu.innerHTML) > 0) {
+ if (crow.className.match("Unread") && !vfeedr.className.match("Unread")) {
+ vfeedr.className = vfeedr.className + "Unread";
+ vfeedctr.className = "odd";
+ }
+ } else {
+ vfeedctr.className = "invisible";
+ vfeedr.className = vfeedr.className.replace("Unread", "");
+ }
+ }
+
+ debug("toggle published for aid " + id);
+
+ new Ajax.Request(query);
+
+}
+
function correctHeadlinesOffset(id) {
try {
for (i = 0; i < rows.length; i++) {
var row = document.getElementById("RROW-" + rows[i]);
- var mark_img = document.getElementById("FMARKPIC-" + rows[i]);
+ var mark_img = document.getElementById("FMPIC-" + rows[i]);
if (row && mark_img) {
}
}
+function selectionTogglePublished(cdm_mode) {
+ try {
+ if (!xmlhttp_ready(xmlhttp_rpc)) {
+ printLockingError();
+ return;
+ }
+
+ var rows;
+
+ if (cdm_mode) {
+ rows = cdmGetSelectedArticles();
+ } else {
+ rows = getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
+ }
+
+ if (rows.length == 0) {
+ alert(__("No articles are selected."));
+ return;
+ }
+
+ for (i = 0; i < rows.length; i++) {
+ var row = document.getElementById("RROW-" + rows[i]);
+ var mark_img = document.getElementById("FPPIC-" + rows[i]);
+
+ if (row && mark_img) {
+
+ if (mark_img.alt == "Publish") {
+ mark_img.src = "images/pub_set.png";
+ mark_img.alt = "Unpublish";
+ mark_img.setAttribute('onclick',
+ 'javascript:togglePub('+rows[i]+', false)');
+
+ } else {
+ mark_img.src = "images/pub_unset.png";
+ mark_img.alt = "Publish";
+ mark_img.setAttribute('onclick',
+ 'javascript:togglePub('+rows[i]+', true)');
+ }
+ }
+ }
+
+ if (rows.length > 0) {
+
+ var query = "backend.php?op=rpc&subop=publishSelected&ids=" +
+ param_escape(rows.toString()) + "&cmode=2";
+
+ xmlhttp_rpc.open("GET", query, true);
+ xmlhttp_rpc.onreadystatechange=all_counters_callback;
+ xmlhttp_rpc.send(null);
+
+ }
+
+ } catch (e) {
+ exception_error("selectionToggleMarked", e);
+ }
+}
+
function cdmGetSelectedArticles() {
var sel_articles = new Array();
var container = document.getElementById("headlinesInnerContainer");