init.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. class Share extends Plugin {
  3. private $host;
  4. function about() {
  5. return array(1.0,
  6. "Share article by unique URL",
  7. "fox");
  8. }
  9. function init($host) {
  10. $this->host = $host;
  11. $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
  12. }
  13. function get_js() {
  14. return file_get_contents(dirname(__FILE__) . "/share.js");
  15. }
  16. function hook_article_button($line) {
  17. return "<img src=\"plugins/share/share.png\"
  18. class='tagsPic' style=\"cursor : pointer\"
  19. onclick=\"shareArticle(".$line['int_id'].")\"
  20. title='".__('Share by URL')."'>";
  21. }
  22. function shareArticle() {
  23. $param = db_escape_string($_REQUEST['param']);
  24. $result = db_query("SELECT uuid, ref_id FROM ttrss_user_entries WHERE int_id = '$param'
  25. AND owner_uid = " . $_SESSION['uid']);
  26. if (db_num_rows($result) == 0) {
  27. print "Article not found.";
  28. } else {
  29. $uuid = db_fetch_result($result, 0, "uuid");
  30. $ref_id = db_fetch_result($result, 0, "ref_id");
  31. if (!$uuid) {
  32. $uuid = db_escape_string(sha1(uniqid(rand(), true)));
  33. db_query("UPDATE ttrss_user_entries SET uuid = '$uuid' WHERE int_id = '$param'
  34. AND owner_uid = " . $_SESSION['uid']);
  35. }
  36. print "<h2>". __("You can share this article by the following unique URL:") . "</h2>";
  37. $url_path = get_self_url_prefix();
  38. $url_path .= "/public.php?op=share&key=$uuid";
  39. print "<div class=\"tagCloudContainer\">";
  40. print "<a id='pub_opml_url' href='$url_path' target='_blank'>$url_path</a>";
  41. print "</div>";
  42. /* if (!label_find_id(__('Shared'), $_SESSION["uid"]))
  43. label_create(__('Shared'), $_SESSION["uid"]);
  44. label_add_article($ref_id, __('Shared'), $_SESSION['uid']); */
  45. }
  46. print "<div align='center'>";
  47. print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('shareArticleDlg').hide()\">".
  48. __('Close this window')."</button>";
  49. print "</div>";
  50. }
  51. }
  52. ?>