]>
Commit | Line | Data |
---|---|---|
1 | <?php | |
2 | class Share extends Plugin { | |
3 | private $host; | |
4 | ||
5 | function about() { | |
6 | return array(1.0, | |
7 | "Share article by unique URL", | |
8 | "fox"); | |
9 | } | |
10 | ||
11 | function init($host) { | |
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) { | |
22 | return "<img src=\"plugins/share/share.png\" | |
23 | class='tagsPic' style=\"cursor : pointer\" | |
24 | onclick=\"shareArticle(".$line['int_id'].")\" | |
25 | title='".__('Share by URL')."'>"; | |
26 | } | |
27 | ||
28 | function shareArticle() { | |
29 | $param = db_escape_string( $_REQUEST['param']); | |
30 | ||
31 | $result = db_query( "SELECT uuid, ref_id FROM ttrss_user_entries WHERE int_id = '$param' | |
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) { | |
42 | $uuid = db_escape_string( sha1(uniqid(rand(), true))); | |
43 | db_query( "UPDATE ttrss_user_entries SET uuid = '$uuid' WHERE int_id = '$param' | |
44 | AND owner_uid = " . $_SESSION['uid']); | |
45 | } | |
46 | ||
47 | print "<h2>". __("You can share this article by the following unique URL:") . "</h2>"; | |
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 | ||
56 | /* if (!label_find_id( __('Shared'), $_SESSION["uid"])) | |
57 | label_create( __('Shared'), $_SESSION["uid"]); | |
58 | ||
59 | label_add_article( $ref_id, __('Shared'), $_SESSION['uid']); */ | |
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 | ?> |