From 7adcada324dc6960cf4a120b1397c1bd60521d9b Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 17 Feb 2021 08:52:39 +0300 Subject: share plugin: cleanup, fix icon not highlighting properly --- plugins/share/init.php | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) (limited to 'plugins/share/init.php') diff --git a/plugins/share/init.php b/plugins/share/init.php index 846e1f39c..a569393fe 100644 --- a/plugins/share/init.php +++ b/plugins/share/init.php @@ -17,18 +17,17 @@ class Share extends Plugin { } function get_js() { - return file_get_contents(dirname(__FILE__) . "/share.js"); + return file_get_contents(__DIR__ . "/share.js"); } function get_css() { - return file_get_contents(dirname(__FILE__) . "/share.css"); + return file_get_contents(__DIR__ . "/share.css"); } function get_prefs_js() { - return file_get_contents(dirname(__FILE__) . "/share_prefs.js"); + return file_get_contents(__DIR__ . "/share_prefs.js"); } - function unshare() { $id = $_REQUEST['id']; @@ -36,7 +35,7 @@ class Share extends Plugin { AND owner_uid = ?"); $sth->execute([$id, $_SESSION['uid']]); - print "OK"; + print __("Article unshared"); } function hook_prefs_tab_section($id) { @@ -52,16 +51,14 @@ class Share extends Plugin { } } - // Silent function clearArticleKeys() { $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET uuid = '' WHERE owner_uid = ?"); $sth->execute([$_SESSION['uid']]); - return; + print __("Shared URLs cleared."); } - function newkey() { $id = $_REQUEST['id']; $uuid = uniqid_short(); @@ -70,26 +67,25 @@ class Share extends Plugin { AND owner_uid = ?"); $sth->execute([$uuid, $id, $_SESSION['uid']]); - print json_encode(array("link" => $uuid)); + print json_encode(["link" => $uuid]); } function hook_article_button($line) { - $img_class = $line['uuid'] ? "shared" : ""; + $icon_class = !empty($line['uuid']) ? "is-shared" : ""; - return "link"; } - function shareArticle() { - $param = $_REQUEST['param']; + function shareDialog() { + $id = (int)clean($_REQUEST['id'] ?? 0); $sth = $this->pdo->prepare("SELECT uuid FROM ttrss_user_entries WHERE int_id = ? AND owner_uid = ?"); - $sth->execute([$param, $_SESSION['uid']]); + $sth->execute([$id, $_SESSION['uid']]); if ($row = $sth->fetch()) { - $uuid = $row['uuid']; if (!$uuid) { @@ -97,27 +93,26 @@ class Share extends Plugin { $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET uuid = ? WHERE int_id = ? AND owner_uid = ?"); - $sth->execute([$uuid, $param, $_SESSION['uid']]); + $sth->execute([$uuid, $id, $_SESSION['uid']]); } - $url_path = htmlspecialchars(get_self_url_prefix() . "/public.php?op=share&key=$uuid"); + $url_path = get_self_url_prefix() . "/public.php?op=share&key=$uuid"; ?>
-
- +
-- cgit v1.2.3