aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/LinkDB.php
diff options
context:
space:
mode:
authorVirtualTam <virtualtam@flibidi.net>2015-06-23 22:34:07 +0200
committernodiscc <nodiscc@gmail.com>2015-06-24 00:26:59 +0200
commit9f15ca9ee76bc36832f12a952005fdaf52e2559d (patch)
treeb29e109d2eccad7b13a6dd5d6f59571f4023686f /application/LinkDB.php
parentae630270109bf78b5f561c887d35b7b099d30271 (diff)
downloadShaarli-9f15ca9ee76bc36832f12a952005fdaf52e2559d.tar.gz
Shaarli-9f15ca9ee76bc36832f12a952005fdaf52e2559d.tar.zst
Shaarli-9f15ca9ee76bc36832f12a952005fdaf52e2559d.zip
LinkDB: add 'hidePublicLinks' parameter to the constructor
Fixes #236 Relates to #237 Signed-off-by: VirtualTam <virtualtam@flibidi.net>
Diffstat (limited to 'application/LinkDB.php')
-rw-r--r--application/LinkDB.php8
1 files changed, 6 insertions, 2 deletions
diff --git a/application/LinkDB.php b/application/LinkDB.php
index 137f42e5..47dbcaf3 100644
--- a/application/LinkDB.php
+++ b/application/LinkDB.php
@@ -45,6 +45,9 @@ class LinkDB implements Iterator, Countable, ArrayAccess
45 // Is the user logged in? (used to filter private links) 45 // Is the user logged in? (used to filter private links)
46 private $loggedIn; 46 private $loggedIn;
47 47
48 // Hide public links
49 private $hidePublicLinks;
50
48 /** 51 /**
49 * Creates a new LinkDB 52 * Creates a new LinkDB
50 * 53 *
@@ -52,10 +55,11 @@ class LinkDB implements Iterator, Countable, ArrayAccess
52 * 55 *
53 * @param $isLoggedIn is the user logged in? 56 * @param $isLoggedIn is the user logged in?
54 */ 57 */
55 function __construct($isLoggedIn) 58 function __construct($isLoggedIn, $hidePublicLinks)
56 { 59 {
57 // FIXME: do not access $GLOBALS, pass the datastore instead 60 // FIXME: do not access $GLOBALS, pass the datastore instead
58 $this->loggedIn = $isLoggedIn; 61 $this->loggedIn = $isLoggedIn;
62 $this->hidePublicLinks = $hidePublicLinks;
59 $this->checkDB(); 63 $this->checkDB();
60 $this->readdb(); 64 $this->readdb();
61 } 65 }
@@ -210,7 +214,7 @@ class LinkDB implements Iterator, Countable, ArrayAccess
210 { 214 {
211 215
212 // Public links are hidden and user not logged in => nothing to show 216 // Public links are hidden and user not logged in => nothing to show
213 if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn()) { 217 if ($this->hidePublicLinks && !$this->loggedIn) {
214 $this->links = array(); 218 $this->links = array();
215 return; 219 return;
216 } 220 }