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