implement sharing articles by unique url
This commit is contained in:
parent
359fc686dd
commit
83cd33fcec
11 changed files with 136 additions and 8 deletions
24
backend.php
24
backend.php
|
@ -59,7 +59,7 @@
|
|||
}
|
||||
|
||||
if (!($_SESSION["uid"] && validate_session($link)) && $op != "globalUpdateFeeds" &&
|
||||
$op != "rss" && $op != "getUnread" && $op != "getProfiles" &&
|
||||
$op != "rss" && $op != "getUnread" && $op != "getProfiles" && $op != "share" &&
|
||||
$op != "fbexport" && $op != "logout" && $op != "pubsub") {
|
||||
|
||||
if ($op == 'pref-feeds' && $_REQUEST['subop'] == 'add') {
|
||||
|
@ -633,6 +633,28 @@
|
|||
}
|
||||
break; // fbexport
|
||||
|
||||
case "share":
|
||||
$uuid = db_escape_string($_REQUEST["key"]);
|
||||
|
||||
$result = db_query($link, "SELECT ref_id, owner_uid FROM ttrss_user_entries WHERE
|
||||
uuid = '$uuid'");
|
||||
|
||||
if (db_num_rows($result) != 0) {
|
||||
header("Content-Type: text/html");
|
||||
|
||||
$id = db_fetch_result($result, 0, "ref_id");
|
||||
$owner_uid = db_fetch_result($result, 0, "owner_uid");
|
||||
|
||||
$article = format_article($link, $id, false, true);
|
||||
|
||||
print_r($article['content']);
|
||||
|
||||
} else {
|
||||
print "Article not found.";
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
header("Content-Type: text/plain");
|
||||
print json_encode(array("error" => array("code" => 7)));
|
||||
|
|
|
@ -1275,9 +1275,9 @@
|
|||
$result = db_query($link,
|
||||
"INSERT INTO ttrss_user_entries
|
||||
(ref_id, owner_uid, feed_id, unread, last_read, marked,
|
||||
published, score, tag_cache, label_cache)
|
||||
published, score, tag_cache, label_cache, uuid)
|
||||
VALUES ('$ref_id', '$owner_uid', '$feed', $unread,
|
||||
$last_read_qpart, $marked, $published, '$score', '', '')");
|
||||
$last_read_qpart, $marked, $published, '$score', '', '', '')");
|
||||
|
||||
if (PUBSUBHUBBUB_HUB && $published == 'true') {
|
||||
$rss_link = get_self_url_prefix() .
|
||||
|
@ -4927,6 +4927,11 @@
|
|||
alt='Zoom' title='".__('Share on Twitter')."'>";
|
||||
}
|
||||
|
||||
$rv['content'] .= "<img src=\"".theme_image($link, 'images/art-share.png')."\"
|
||||
class='tagsPic' style=\"cursor : pointer\"
|
||||
onclick=\"shareArticle(".$line['int_id'].")\"
|
||||
alt='Zoom' title='".__('Share by URL')."'>";
|
||||
|
||||
$rv['content'] .= "<img src=\"".theme_image($link, 'images/digest_checkbox.png')."\"
|
||||
class='tagsPic' style=\"cursor : pointer\"
|
||||
onclick=\"closeArticlePanel($id)\"
|
||||
|
|
|
@ -783,6 +783,15 @@
|
|||
return;
|
||||
}
|
||||
|
||||
// Silent
|
||||
if ($subop == "clearArticleKeys") {
|
||||
db_query($link, "UPDATE ttrss_user_entries SET uuid = '' WHERE
|
||||
owner_uid = " . $_SESSION["uid"]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ($subop == "verifyRegexp") {
|
||||
$reg_exp = $_REQUEST["reg_exp"];
|
||||
|
||||
|
|
|
@ -1071,12 +1071,52 @@
|
|||
__('Cancel')."</button></div>";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($id == "shareArticle") {
|
||||
|
||||
$result = db_query($link, "SELECT uuid, ref_id FROM ttrss_user_entries WHERE int_id = '$param'
|
||||
AND owner_uid = " . $_SESSION['uid']);
|
||||
|
||||
if (db_num_rows($result) == 0) {
|
||||
print "Article not found.";
|
||||
} else {
|
||||
|
||||
$uuid = db_fetch_result($result, 0, "uuid");
|
||||
$ref_id = db_fetch_result($result, 0, "ref_id");
|
||||
|
||||
if (!$uuid) {
|
||||
$uuid = db_escape_string(sha1(uniqid(rand(), true)));
|
||||
db_query($link, "UPDATE ttrss_user_entries SET uuid = '$uuid' WHERE int_id = '$param'
|
||||
AND owner_uid = " . $_SESSION['uid']);
|
||||
}
|
||||
|
||||
print __("You can share this article by the following unique URL:");
|
||||
|
||||
$url_path = get_self_url_prefix();
|
||||
$url_path .= "/backend.php?op=share&key=$uuid";
|
||||
|
||||
print "<div class=\"tagCloudContainer\">";
|
||||
print "<a id='pub_opml_url' href='$url_path' target='_blank'>$url_path</a>";
|
||||
print "</div>";
|
||||
|
||||
/* if (!label_find_id($link, __('Shared'), $_SESSION["uid"]))
|
||||
label_create($link, __('Shared'), $_SESSION["uid"]);
|
||||
|
||||
label_add_article($link, $ref_id, __('Shared'), $_SESSION['uid']); */
|
||||
}
|
||||
|
||||
print "<div align='center'>";
|
||||
|
||||
print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('shareArticleDlg').hide()\">".
|
||||
__('Close this window')."</button>";
|
||||
|
||||
print "</div>";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
print "</dlg>";
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -1506,7 +1506,9 @@
|
|||
|
||||
print "</div>"; #pane
|
||||
|
||||
print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Published articles and generated feeds')."\">";
|
||||
print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Published & shared articles and generated feeds')."\">";
|
||||
|
||||
print "<h3>" . __("Published articles and generated feeds") . "</h3>";
|
||||
|
||||
print "<p>".__('Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.')."</p>";
|
||||
|
||||
|
@ -1519,6 +1521,13 @@
|
|||
print "<button dojoType=\"dijit.form.Button\" onclick=\"return clearFeedAccessKeys()\">".
|
||||
__('Clear all generated URLs')."</button> ";
|
||||
|
||||
print "<h3>" . __("Articles shared by URL") . "</h3>";
|
||||
|
||||
print "<p>" . __("You can disable all articles shared by unique URLs here.") . "</p>";
|
||||
|
||||
print "<button dojoType=\"dijit.form.Button\" onclick=\"return clearArticleAccessKeys()\">".
|
||||
__('Unshare all articles')."</button> ";
|
||||
|
||||
print "</div>"; #pane
|
||||
|
||||
if (defined('CONSUMER_KEY') && CONSUMER_KEY != '') {
|
||||
|
|
18
prefs.js
18
prefs.js
|
@ -1590,6 +1590,24 @@ function clearFeedAccessKeys() {
|
|||
return false;
|
||||
}
|
||||
|
||||
function clearArticleAccessKeys() {
|
||||
|
||||
var ok = confirm(__("This will invalidate all previously shared article URLs. Continue?"));
|
||||
|
||||
if (ok) {
|
||||
notify_progress("Clearing URLs...");
|
||||
|
||||
var query = "?op=rpc&subop=clearArticleKeys";
|
||||
|
||||
new Ajax.Request("backend.php", {
|
||||
parameters: query,
|
||||
onComplete: function(transport) {
|
||||
notify_info("Shared URLs cleared.");
|
||||
} });
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
function resetFeedOrder() {
|
||||
try {
|
||||
notify_progress("Loading, please wait...");
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
require_once "functions.php";
|
||||
|
||||
define('EXPECTED_CONFIG_VERSION', 23);
|
||||
define('SCHEMA_VERSION', 85);
|
||||
define('SCHEMA_VERSION', 86);
|
||||
|
||||
if (!file_exists("config.php")) {
|
||||
print "<b>Fatal Error</b>: You forgot to copy
|
||||
|
|
|
@ -152,6 +152,7 @@ create index ttrss_entries_updated_idx on ttrss_entries(updated);
|
|||
create table ttrss_user_entries (
|
||||
int_id integer not null primary key auto_increment,
|
||||
ref_id integer not null,
|
||||
uuid varchar(200) not null,
|
||||
feed_id int,
|
||||
orig_feed_id int,
|
||||
owner_uid integer not null,
|
||||
|
@ -254,7 +255,7 @@ create table ttrss_tags (id integer primary key auto_increment,
|
|||
|
||||
create table ttrss_version (schema_version int not null) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
|
||||
|
||||
insert into ttrss_version values (85);
|
||||
insert into ttrss_version values (86);
|
||||
|
||||
create table ttrss_enclosures (id integer primary key auto_increment,
|
||||
content_url text not null,
|
||||
|
|
|
@ -137,6 +137,7 @@ create index ttrss_entries_updated_idx on ttrss_entries(updated);
|
|||
create table ttrss_user_entries (
|
||||
int_id serial not null primary key,
|
||||
ref_id integer not null references ttrss_entries(id) ON DELETE CASCADE,
|
||||
uuid varchar(200) not null,
|
||||
feed_id int references ttrss_feeds(id) ON DELETE CASCADE,
|
||||
orig_feed_id integer references ttrss_archived_feeds(id) ON DELETE SET NULL,
|
||||
owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
|
||||
|
@ -225,7 +226,7 @@ create index ttrss_tags_post_int_id_idx on ttrss_tags(post_int_id);
|
|||
|
||||
create table ttrss_version (schema_version int not null);
|
||||
|
||||
insert into ttrss_version values (85);
|
||||
insert into ttrss_version values (86);
|
||||
|
||||
create table ttrss_enclosures (id serial not null primary key,
|
||||
content_url text not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
body#ttrssMain, body#ttrssPrefs, body#ttrssLogin {
|
||||
body#ttrssMain, body#ttrssPrefs, body#ttrssLogin, body {
|
||||
background : white;
|
||||
color : black;
|
||||
margin : 0px;
|
||||
|
|
23
viewfeed.js
23
viewfeed.js
|
@ -2184,6 +2184,7 @@ function precache_headlines() {
|
|||
feed_precache_timeout_id = false;
|
||||
}, 3000);
|
||||
|
||||
x
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
|
@ -2191,3 +2192,25 @@ function precache_headlines() {
|
|||
exception_error("precache_headlines", e);
|
||||
}
|
||||
}
|
||||
|
||||
function shareArticle(id) {
|
||||
try {
|
||||
if (dijit.byId("shareArticleDlg"))
|
||||
dijit.byId("shareArticleDlg").destroyRecursive();
|
||||
|
||||
var query = "backend.php?op=dlg&id=shareArticle¶m=" + param_escape(id);
|
||||
|
||||
dialog = new dijit.Dialog({
|
||||
id: "shareArticleDlg",
|
||||
title: __("Share article by URL"),
|
||||
style: "width: 600px",
|
||||
href: query});
|
||||
|
||||
dialog.show();
|
||||
|
||||
} catch (e) {
|
||||
exception_error("emailArticle", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue