]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - index.php
Public/private filter: use two separate buttons
[github/shaarli/Shaarli.git] / index.php
index 60ac24ac2ec766421a112a89b1b9cbdebdb6b7e8..8770b6694c184ffe5e6e974caa3152571a1803a8 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1012,11 +1012,21 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager)
 
     // -------- User wants to see only private links (toggle)
     if (isset($_GET['visibility'])) {
-        unset($_SESSION['visibility']);
         if ($_GET['visibility'] === 'private') {
-            $_SESSION['visibility'] = 'private'; // See only private links
+            // Visibility not set or not already private, set private, otherwise reset it
+            if (empty($_SESSION['visibility']) || $_SESSION['visibility'] !== 'private') {
+                // See only private links
+                $_SESSION['visibility'] = 'private';
+            } else {
+                unset($_SESSION['visibility']);
+            }
         } else if ($_GET['visibility'] === 'public') {
-            $_SESSION['visibility'] = 'public'; // See only public links
+            if (empty($_SESSION['visibility']) || $_SESSION['visibility'] !== 'public') {
+                // See only public links
+                $_SESSION['visibility'] = 'public';
+            } else {
+                unset($_SESSION['visibility']);
+            }
         }
 
         if (! empty($_SERVER['HTTP_REFERER'])) {