]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Merge pull request #768 from ArthurHoaro/feature/get-public-links
authorArthurHoaro <arthur@hoa.ro>
Tue, 17 Jan 2017 08:55:25 +0000 (09:55 +0100)
committerGitHub <noreply@github.com>
Tue, 17 Jan 2017 08:55:25 +0000 (09:55 +0100)
Update LinkFilter to be able to filter only public links

1  2 
index.php

diff --combined index.php
index 190d7f6bace6170d0c7b9a9437e304dbd102ca58,4f07a013420c93dfc4decd8219dce61bdea8a7e9..b62149f647f469556d1f1a5c99120e22a9702aac
+++ b/index.php
@@@ -1208,7 -1208,7 +1208,7 @@@ function renderPage($conf, $pluginManag
                  $LINKSDB[$key]=$value;
              }
              $LINKSDB->save($conf->get('resource.page_cache'));
 -            echo '<script>alert("Tag was removed from '.count($linksToAlter).' links.");document.location=\'?\';</script>';
 +            echo '<script>alert("Tag was removed from '.count($linksToAlter).' links.");document.location=\'?do=changetag\';</script>';
              exit;
          }
  
  
          // If we are called from the bookmarklet, we must close the popup:
          if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { echo '<script>self.close();</script>'; exit; }
 -        // Pick where we're going to redirect
 -        // =============================================================
 -        // Basically, we can't redirect to where we were previously if it was a permalink
 -        // or an edit_link, because it would 404.
 -        // Cases:
 -        //    - /             : nothing in $_GET, redirect to self
 -        //    - /?page        : redirect to self
 -        //    - /?searchterm  : redirect to self (there might be other links)
 -        //    - /?searchtags  : redirect to self
 -        //    - /permalink    : redirect to / (the link does not exist anymore)
 -        //    - /?edit_link   : redirect to / (the link does not exist anymore)
 -        // PHP treats the permalink as a $_GET variable, so we need to check if every condition for self
 -        // redirect is not satisfied, and only then redirect to /
 -        $location = "?";
 -        // Self redirection
 -        if (count($_GET) == 0
 -            || isset($_GET['page'])
 -            || isset($_GET['searchterm'])
 -            || isset($_GET['searchtags'])
 -        ) {
 -            if (isset($_POST['returnurl'])) {
 -                $location = $_POST['returnurl']; // Handle redirects given by the form
 -            } else if (isset($_SERVER['HTTP_REFERER'])) {
 -                $location = generateLocation($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'], array('delete_link'));
 -            }
 +
 +        $location = '?';
 +        if (isset($_SERVER['HTTP_REFERER'])) {
 +            // Don't redirect to where we were previously if it was a permalink or an edit_link, because it would 404.
 +            $location = generateLocation(
 +                    $_SERVER['HTTP_REFERER'],
 +                    $_SERVER['HTTP_HOST'],
 +                    ['delete_link', 'edit_link', $link['shorturl']]
 +            );
          }
  
          header('Location: ' . $location); // After deleting the link, redirect to appropriate location
@@@ -1614,8 -1630,8 +1614,8 @@@ function buildLinkList($PAGE,$LINKSDB, 
          }
      } else {
          // Filter links according search parameters.
-         $privateonly = !empty($_SESSION['privateonly']);
-         $linksToDisplay = $LINKSDB->filterSearch($_GET, false, $privateonly);
+         $visibility = ! empty($_SESSION['privateonly']) ? 'private' : 'all';
+         $linksToDisplay = $LINKSDB->filterSearch($_GET, false, $visibility);
      }
  
      // ---- Handle paging.