aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2017-12-16 12:36:59 +0100
committerArthurHoaro <arthur@hoa.ro>2017-12-16 14:32:56 +0100
commit9d4736a3e95332198896f97ecc8a83abb0cbe85b (patch)
treefc2487dbefd09953f21f8d10850c7689c87af224 /index.php
parent877491b4ad0a6a9119e667901cef40cc56116901 (diff)
downloadShaarli-9d4736a3e95332198896f97ecc8a83abb0cbe85b.tar.gz
Shaarli-9d4736a3e95332198896f97ecc8a83abb0cbe85b.tar.zst
Shaarli-9d4736a3e95332198896f97ecc8a83abb0cbe85b.zip
Add a filter to only display public links
When the key filter is clicked once, it only displays private link. When it is clicked on again, it becomes red and only public links are displayed. Another click and all links are displayed. The current visibility status is shown in the search banner Fixes #1030
Diffstat (limited to 'index.php')
-rw-r--r--index.php23
1 files changed, 12 insertions, 11 deletions
diff --git a/index.php b/index.php
index 9d5f25ea..60ac24ac 100644
--- a/index.php
+++ b/index.php
@@ -282,7 +282,7 @@ function logout() {
282 unset($_SESSION['uid']); 282 unset($_SESSION['uid']);
283 unset($_SESSION['ip']); 283 unset($_SESSION['ip']);
284 unset($_SESSION['username']); 284 unset($_SESSION['username']);
285 unset($_SESSION['privateonly']); 285 unset($_SESSION['visibility']);
286 unset($_SESSION['untaggedonly']); 286 unset($_SESSION['untaggedonly']);
287 } 287 }
288 setcookie('shaarli_staySignedIn', FALSE, 0, WEB_PATH); 288 setcookie('shaarli_staySignedIn', FALSE, 0, WEB_PATH);
@@ -800,7 +800,7 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager)
800 // -------- Tag cloud 800 // -------- Tag cloud
801 if ($targetPage == Router::$PAGE_TAGCLOUD) 801 if ($targetPage == Router::$PAGE_TAGCLOUD)
802 { 802 {
803 $visibility = ! empty($_SESSION['privateonly']) ? 'private' : 'all'; 803 $visibility = ! empty($_SESSION['visibility']) ? $_SESSION['visibility'] : '';
804 $filteringTags = isset($_GET['searchtags']) ? explode(' ', $_GET['searchtags']) : []; 804 $filteringTags = isset($_GET['searchtags']) ? explode(' ', $_GET['searchtags']) : [];
805 $tags = $LINKSDB->linksCountPerTag($filteringTags, $visibility); 805 $tags = $LINKSDB->linksCountPerTag($filteringTags, $visibility);
806 806
@@ -845,7 +845,7 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager)
845 // -------- Tag list 845 // -------- Tag list
846 if ($targetPage == Router::$PAGE_TAGLIST) 846 if ($targetPage == Router::$PAGE_TAGLIST)
847 { 847 {
848 $visibility = ! empty($_SESSION['privateonly']) ? 'private' : 'all'; 848 $visibility = ! empty($_SESSION['visibility']) ? $_SESSION['visibility'] : '';
849 $filteringTags = isset($_GET['searchtags']) ? explode(' ', $_GET['searchtags']) : []; 849 $filteringTags = isset($_GET['searchtags']) ? explode(' ', $_GET['searchtags']) : [];
850 $tags = $LINKSDB->linksCountPerTag($filteringTags, $visibility); 850 $tags = $LINKSDB->linksCountPerTag($filteringTags, $visibility);
851 foreach ($filteringTags as $tag) { 851 foreach ($filteringTags as $tag) {
@@ -1011,15 +1011,16 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager)
1011 } 1011 }
1012 1012
1013 // -------- User wants to see only private links (toggle) 1013 // -------- User wants to see only private links (toggle)
1014 if (isset($_GET['privateonly'])) { 1014 if (isset($_GET['visibility'])) {
1015 if (empty($_SESSION['privateonly'])) { 1015 unset($_SESSION['visibility']);
1016 $_SESSION['privateonly'] = 1; // See only private links 1016 if ($_GET['visibility'] === 'private') {
1017 } else { 1017 $_SESSION['visibility'] = 'private'; // See only private links
1018 unset($_SESSION['privateonly']); // See all links 1018 } else if ($_GET['visibility'] === 'public') {
1019 $_SESSION['visibility'] = 'public'; // See only public links
1019 } 1020 }
1020 1021
1021 if (! empty($_SERVER['HTTP_REFERER'])) { 1022 if (! empty($_SERVER['HTTP_REFERER'])) {
1022 $location = generateLocation($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'], array('privateonly')); 1023 $location = generateLocation($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'], array('visibility'));
1023 } else { 1024 } else {
1024 $location = '?'; 1025 $location = '?';
1025 } 1026 }
@@ -1667,7 +1668,7 @@ function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager)
1667 } 1668 }
1668 } else { 1669 } else {
1669 // Filter links according search parameters. 1670 // Filter links according search parameters.
1670 $visibility = ! empty($_SESSION['privateonly']) ? 'private' : 'all'; 1671 $visibility = ! empty($_SESSION['visibility']) ? $_SESSION['visibility'] : '';
1671 $request = [ 1672 $request = [
1672 'searchtags' => $searchtags, 1673 'searchtags' => $searchtags,
1673 'searchterm' => $searchterm, 1674 'searchterm' => $searchterm,
@@ -1743,7 +1744,7 @@ function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager)
1743 'result_count' => count($linksToDisplay), 1744 'result_count' => count($linksToDisplay),
1744 'search_term' => $searchterm, 1745 'search_term' => $searchterm,
1745 'search_tags' => $searchtags, 1746 'search_tags' => $searchtags,
1746 'visibility' => ! empty($_SESSION['privateonly']) ? 'private' : '', 1747 'visibility' => ! empty($_SESSION['visibility']) ? $_SESSION['visibility'] : '',
1747 'redirector' => $conf->get('redirector.url'), // Optional redirector URL. 1748 'redirector' => $conf->get('redirector.url'), // Optional redirector URL.
1748 'links' => $linkDisp, 1749 'links' => $linkDisp,
1749 ); 1750 );