diff options
author | YoungMin Park <[email protected]> | 2014-11-04 11:49:43 +0900 |
---|---|---|
committer | YoungMin Park <[email protected]> | 2014-11-04 11:49:43 +0900 |
commit | a5bbb2bec133bdee08b361628f32430ae3884107 (patch) | |
tree | b203105149ec234ebe155d5718d2cbb6390b4a45 /plugins/share/init.php | |
parent | 12727ad17d125eb2f3f243231ccca1cb0a5a7b4b (diff) | |
parent | 2f43089de1ead3f164b8b31967d1abbb784319fa (diff) |
Merge pull request #1 from gothfox/master
Update from original
Diffstat (limited to 'plugins/share/init.php')
-rw-r--r-- | plugins/share/init.php | 64 |
1 files changed, 61 insertions, 3 deletions
diff --git a/plugins/share/init.php b/plugins/share/init.php index 72a4d4bf9..899677c32 100644 --- a/plugins/share/init.php +++ b/plugins/share/init.php @@ -12,14 +12,66 @@ class Share extends Plugin { $this->host = $host; $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); + $host->add_hook($host::HOOK_PREFS_TAB_SECTION, $this); } function get_js() { return file_get_contents(dirname(__FILE__) . "/share.js"); } + function get_prefs_js() { + return file_get_contents(dirname(__FILE__) . "/share_prefs.js"); + } + + + function unshare() { + $id = db_escape_string($_REQUEST['id']); + + db_query("UPDATE ttrss_user_entries SET uuid = '' WHERE int_id = '$id' + AND owner_uid = " . $_SESSION['uid']); + + print "OK"; + } + + function hook_prefs_tab_section($id) { + if ($id == "prefFeedsPublishedGenerated") { + + print_warning(__("You can disable all articles shared by unique URLs here.")); + + print "<p>"; + + print "<button dojoType=\"dijit.form.Button\" onclick=\"return clearArticleAccessKeys()\">". + __('Unshare all articles')."</button> "; + + print "</p>"; + + } + } + + // Silent + function clearArticleKeys() { + db_query("UPDATE ttrss_user_entries SET uuid = '' WHERE + owner_uid = " . $_SESSION["uid"]); + + return; + } + + + function newkey() { + $id = db_escape_string($_REQUEST['id']); + + $uuid = db_escape_string(uniqid(base_convert(rand(), 10, 36))); + + db_query("UPDATE ttrss_user_entries SET uuid = '$uuid' WHERE int_id = '$id' + AND owner_uid = " . $_SESSION['uid']); + + print json_encode(array("link" => $uuid)); + } + function hook_article_button($line) { - return "<img src=\"plugins/share/share.png\" + $img = $line['uuid'] ? "share.png" : "notshared.png"; + + return "<img id='SHARE-IMG-".$line['int_id']."' src=\"plugins/share/$img\" class='tagsPic' style=\"cursor : pointer\" onclick=\"shareArticle(".$line['int_id'].")\" title='".__('Share by URL')."'>"; @@ -39,7 +91,7 @@ class Share extends Plugin { $ref_id = db_fetch_result($result, 0, "ref_id"); if (!$uuid) { - $uuid = db_escape_string(sha1(uniqid(rand(), true))); + $uuid = db_escape_string(uniqid(base_convert(rand(), 10, 36))); db_query("UPDATE ttrss_user_entries SET uuid = '$uuid' WHERE int_id = '$param' AND owner_uid = " . $_SESSION['uid']); } @@ -50,7 +102,7 @@ class Share extends Plugin { $url_path .= "/public.php?op=share&key=$uuid"; print "<div class=\"tagCloudContainer\">"; - print "<a id='pub_opml_url' href='$url_path' target='_blank'>$url_path</a>"; + print "<a id='gen_article_url' href='$url_path' target='_blank'>$url_path</a>"; print "</div>"; /* if (!label_find_id(__('Shared'), $_SESSION["uid"])) @@ -61,6 +113,12 @@ class Share extends Plugin { print "<div align='center'>"; + print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('shareArticleDlg').unshare()\">". + __('Unshare article')."</button>"; + + print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('shareArticleDlg').newurl()\">". + __('Generate new URL')."</button>"; + print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('shareArticleDlg').hide()\">". __('Close this window')."</button>"; |