]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - application/LinkDB.php
LinkDB: add 'hidePublicLinks' parameter to the constructor
[github/shaarli/Shaarli.git] / application / LinkDB.php
index 137f42e5d5cde66aa1fb1d3eb9dc116e796ddfb9..47dbcaf3667315a55e6c6c4caa747b90a75e1b8d 100644 (file)
@@ -45,6 +45,9 @@ class LinkDB implements Iterator, Countable, ArrayAccess
     // Is the user logged in? (used to filter private links)
     private $loggedIn;
 
+    // Hide public links
+    private $hidePublicLinks;
+
     /**
      * Creates a new LinkDB
      *
@@ -52,10 +55,11 @@ class LinkDB implements Iterator, Countable, ArrayAccess
      *
      * @param $isLoggedIn is the user logged in?
      */
-    function __construct($isLoggedIn)
+    function __construct($isLoggedIn, $hidePublicLinks)
     {
         // FIXME: do not access $GLOBALS, pass the datastore instead
         $this->loggedIn = $isLoggedIn;
+        $this->hidePublicLinks = $hidePublicLinks;
         $this->checkDB();
         $this->readdb();
     }
@@ -210,7 +214,7 @@ class LinkDB implements Iterator, Countable, ArrayAccess
     {
 
         // Public links are hidden and user not logged in => nothing to show
-        if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn()) {
+        if ($this->hidePublicLinks && !$this->loggedIn) {
             $this->links = array();
             return;
         }