]>
git.wh0rd.org - tt-rss.git/blob - plugins/share/init.php
2 class Share
extends Plugin
{
7 "Share article by unique URL",
11 function init($host) {
14 $host->add_hook($host::HOOK_ARTICLE_BUTTON
, $this);
15 $host->add_hook($host::HOOK_PREFS_TAB_SECTION
, $this);
19 return file_get_contents(dirname(__FILE__
) . "/share.js");
22 function get_prefs_js() {
23 return file_get_contents(dirname(__FILE__
) . "/share_prefs.js");
28 $id = db_escape_string($_REQUEST['id']);
30 db_query("UPDATE ttrss_user_entries SET uuid = '' WHERE int_id = '$id'
31 AND owner_uid = " . $_SESSION['uid']);
36 function hook_prefs_tab_section($id) {
37 if ($id == "prefFeedsPublishedGenerated") {
39 print_warning(__("You can disable all articles shared by unique URLs here."));
43 print "<button dojoType=\"dijit.form.Button\" onclick=\"return clearArticleAccessKeys()\">".
44 __('Unshare all articles')."</button> ";
52 function clearArticleKeys() {
53 db_query("UPDATE ttrss_user_entries SET uuid = '' WHERE
54 owner_uid = " . $_SESSION["uid"]);
61 $id = db_escape_string($_REQUEST['id']);
63 $uuid = db_escape_string(uniqid(base_convert(rand(), 10, 36)));
65 db_query("UPDATE ttrss_user_entries SET uuid = '$uuid' WHERE int_id = '$id'
66 AND owner_uid = " . $_SESSION['uid']);
68 print json_encode(array("link" => $uuid));
71 function hook_article_button($line) {
72 $img = $line['uuid'] ?
"share.png" : "notshared.png";
74 return "<img id='SHARE-IMG-".$line['int_id']."' src=\"plugins/share/$img\"
75 class='tagsPic' style=\"cursor : pointer\"
76 onclick=\"shareArticle(".$line['int_id'].")\"
77 title='".__('Share by URL')."'>";
80 function shareArticle() {
81 $param = db_escape_string($_REQUEST['param']);
83 $result = db_query("SELECT uuid, ref_id FROM ttrss_user_entries WHERE int_id = '$param'
84 AND owner_uid = " . $_SESSION['uid']);
86 if (db_num_rows($result) == 0) {
87 print "Article not found.";
90 $uuid = db_fetch_result($result, 0, "uuid");
91 $ref_id = db_fetch_result($result, 0, "ref_id");
94 $uuid = db_escape_string(uniqid(base_convert(rand(), 10, 36)));
95 db_query("UPDATE ttrss_user_entries SET uuid = '$uuid' WHERE int_id = '$param'
96 AND owner_uid = " . $_SESSION['uid']);
99 print "<h2>". __("You can share this article by the following unique URL:") . "</h2>";
101 $url_path = get_self_url_prefix();
102 $url_path .= "/public.php?op=share&key=$uuid";
104 print "<div class=\"tagCloudContainer\">";
105 print "<a id='gen_article_url' href='$url_path' target='_blank'>$url_path</a>";
108 /* if (!label_find_id(__('Shared'), $_SESSION["uid"]))
109 label_create(__('Shared'), $_SESSION["uid"]);
111 label_add_article($ref_id, __('Shared'), $_SESSION['uid']); */
114 print "<div align='center'>";
116 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('shareArticleDlg').unshare()\">".
117 __('Unshare article')."</button>";
119 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('shareArticleDlg').newurl()\">".
120 __('Generate new URL')."</button>";
122 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('shareArticleDlg').hide()\">".
123 __('Close this window')."</button>";
128 function api_version() {