From 9f15ca9ee76bc36832f12a952005fdaf52e2559d Mon Sep 17 00:00:00 2001 From: VirtualTam Date: Tue, 23 Jun 2015 22:34:07 +0200 Subject: LinkDB: add 'hidePublicLinks' parameter to the constructor Fixes #236 Relates to #237 Signed-off-by: VirtualTam --- application/LinkDB.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'application/LinkDB.php') 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 // 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; } -- cgit v1.2.3