aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php33
1 files changed, 22 insertions, 11 deletions
diff --git a/index.php b/index.php
index 2de9be0a..c2aaf84a 100644
--- a/index.php
+++ b/index.php
@@ -287,7 +287,7 @@ function logout() {
287 unset($_SESSION['uid']); 287 unset($_SESSION['uid']);
288 unset($_SESSION['ip']); 288 unset($_SESSION['ip']);
289 unset($_SESSION['username']); 289 unset($_SESSION['username']);
290 unset($_SESSION['privateonly']); 290 unset($_SESSION['visibility']);
291 unset($_SESSION['untaggedonly']); 291 unset($_SESSION['untaggedonly']);
292 } 292 }
293 setcookie('shaarli_staySignedIn', FALSE, 0, WEB_PATH); 293 setcookie('shaarli_staySignedIn', FALSE, 0, WEB_PATH);
@@ -805,7 +805,7 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager)
805 // -------- Tag cloud 805 // -------- Tag cloud
806 if ($targetPage == Router::$PAGE_TAGCLOUD) 806 if ($targetPage == Router::$PAGE_TAGCLOUD)
807 { 807 {
808 $visibility = ! empty($_SESSION['privateonly']) ? 'private' : 'all'; 808 $visibility = ! empty($_SESSION['visibility']) ? $_SESSION['visibility'] : '';
809 $filteringTags = isset($_GET['searchtags']) ? explode(' ', $_GET['searchtags']) : []; 809 $filteringTags = isset($_GET['searchtags']) ? explode(' ', $_GET['searchtags']) : [];
810 $tags = $LINKSDB->linksCountPerTag($filteringTags, $visibility); 810 $tags = $LINKSDB->linksCountPerTag($filteringTags, $visibility);
811 811
@@ -850,7 +850,7 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager)
850 // -------- Tag list 850 // -------- Tag list
851 if ($targetPage == Router::$PAGE_TAGLIST) 851 if ($targetPage == Router::$PAGE_TAGLIST)
852 { 852 {
853 $visibility = ! empty($_SESSION['privateonly']) ? 'private' : 'all'; 853 $visibility = ! empty($_SESSION['visibility']) ? $_SESSION['visibility'] : '';
854 $filteringTags = isset($_GET['searchtags']) ? explode(' ', $_GET['searchtags']) : []; 854 $filteringTags = isset($_GET['searchtags']) ? explode(' ', $_GET['searchtags']) : [];
855 $tags = $LINKSDB->linksCountPerTag($filteringTags, $visibility); 855 $tags = $LINKSDB->linksCountPerTag($filteringTags, $visibility);
856 foreach ($filteringTags as $tag) { 856 foreach ($filteringTags as $tag) {
@@ -1016,15 +1016,26 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager)
1016 } 1016 }
1017 1017
1018 // -------- User wants to see only private links (toggle) 1018 // -------- User wants to see only private links (toggle)
1019 if (isset($_GET['privateonly'])) { 1019 if (isset($_GET['visibility'])) {
1020 if (empty($_SESSION['privateonly'])) { 1020 if ($_GET['visibility'] === 'private') {
1021 $_SESSION['privateonly'] = 1; // See only private links 1021 // Visibility not set or not already private, set private, otherwise reset it
1022 } else { 1022 if (empty($_SESSION['visibility']) || $_SESSION['visibility'] !== 'private') {
1023 unset($_SESSION['privateonly']); // See all links 1023 // See only private links
1024 $_SESSION['visibility'] = 'private';
1025 } else {
1026 unset($_SESSION['visibility']);
1027 }
1028 } else if ($_GET['visibility'] === 'public') {
1029 if (empty($_SESSION['visibility']) || $_SESSION['visibility'] !== 'public') {
1030 // See only public links
1031 $_SESSION['visibility'] = 'public';
1032 } else {
1033 unset($_SESSION['visibility']);
1034 }
1024 } 1035 }
1025 1036
1026 if (! empty($_SERVER['HTTP_REFERER'])) { 1037 if (! empty($_SERVER['HTTP_REFERER'])) {
1027 $location = generateLocation($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'], array('privateonly')); 1038 $location = generateLocation($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'], array('visibility'));
1028 } else { 1039 } else {
1029 $location = '?'; 1040 $location = '?';
1030 } 1041 }
@@ -1666,7 +1677,7 @@ function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager)
1666 } 1677 }
1667 } else { 1678 } else {
1668 // Filter links according search parameters. 1679 // Filter links according search parameters.
1669 $visibility = ! empty($_SESSION['privateonly']) ? 'private' : 'all'; 1680 $visibility = ! empty($_SESSION['visibility']) ? $_SESSION['visibility'] : '';
1670 $request = [ 1681 $request = [
1671 'searchtags' => $searchtags, 1682 'searchtags' => $searchtags,
1672 'searchterm' => $searchterm, 1683 'searchterm' => $searchterm,
@@ -1742,7 +1753,7 @@ function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager)
1742 'result_count' => count($linksToDisplay), 1753 'result_count' => count($linksToDisplay),
1743 'search_term' => $searchterm, 1754 'search_term' => $searchterm,
1744 'search_tags' => $searchtags, 1755 'search_tags' => $searchtags,
1745 'visibility' => ! empty($_SESSION['privateonly']) ? 'private' : '', 1756 'visibility' => ! empty($_SESSION['visibility']) ? $_SESSION['visibility'] : '',
1746 'redirector' => $conf->get('redirector.url'), // Optional redirector URL. 1757 'redirector' => $conf->get('redirector.url'), // Optional redirector URL.
1747 'links' => $linkDisp, 1758 'links' => $linkDisp,
1748 ); 1759 );