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