From 9d4736a3e95332198896f97ecc8a83abb0cbe85b Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 16 Dec 2017 12:36:59 +0100 Subject: Add a filter to only display public links When the key filter is clicked once, it only displays private link. When it is clicked on again, it becomes red and only public links are displayed. Another click and all links are displayed. The current visibility status is shown in the search banner Fixes #1030 --- application/PageBuilder.php | 24 +++++++++++++++++++++++- application/Updater.php | 12 ++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) (limited to 'application') diff --git a/application/PageBuilder.php b/application/PageBuilder.php index 468f144b..0902d00d 100644 --- a/application/PageBuilder.php +++ b/application/PageBuilder.php @@ -83,7 +83,9 @@ class PageBuilder ApplicationUtils::getVersionHash(SHAARLI_VERSION, $this->conf->get('credentials.salt')) ); $this->tpl->assign('scripturl', index_url($_SERVER)); - $this->tpl->assign('privateonly', !empty($_SESSION['privateonly'])); // Show only private links? + $visibility = ! empty($_SESSION['visibility']) ? $_SESSION['visibility'] : ''; + $this->tpl->assign('visibility', $visibility); + $this->tpl->assign('nextVisibility', $this->getNextVisibility($visibility)); $this->tpl->assign('untaggedonly', !empty($_SESSION['untaggedonly'])); $this->tpl->assign('pagetitle', $this->conf->get('general.title', 'Shaarli')); if ($this->conf->exists('general.header_link')) { @@ -170,4 +172,24 @@ class PageBuilder $this->tpl->assign('error_message', $message); $this->renderPage('404'); } + + /** + * Return the next visibility option: + * private -> public -> all + * + * @param string $current visibility value + * + * @return string next visibility value + */ + protected function getNextVisibility($current) + { + switch ($current) { + case 'private': + return 'public'; + case 'public': + return ''; + default: + return 'private'; + } + } } diff --git a/application/Updater.php b/application/Updater.php index 8d2bd577..f07e7697 100644 --- a/application/Updater.php +++ b/application/Updater.php @@ -445,6 +445,18 @@ class Updater $this->linkDB->save($this->conf->get('resource.page_cache')); return true; } + + /** + * Change privateonly session key to visibility. + */ + public function updateMethodVisibilitySession() + { + if (isset($_SESSION['privateonly'])) { + unset($_SESSION['privateonly']); + $_SESSION['visibility'] = 'private'; + } + return true; + } } /** -- cgit v1.2.3 From d2f6d909e529898c43b32defb890ec8e2d6b72f5 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Wed, 24 Jan 2018 18:46:31 +0100 Subject: Public/private filter: use two separate buttons #1038 --- application/PageBuilder.php | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'application') diff --git a/application/PageBuilder.php b/application/PageBuilder.php index 0902d00d..3233d6b6 100644 --- a/application/PageBuilder.php +++ b/application/PageBuilder.php @@ -85,7 +85,6 @@ class PageBuilder $this->tpl->assign('scripturl', index_url($_SERVER)); $visibility = ! empty($_SESSION['visibility']) ? $_SESSION['visibility'] : ''; $this->tpl->assign('visibility', $visibility); - $this->tpl->assign('nextVisibility', $this->getNextVisibility($visibility)); $this->tpl->assign('untaggedonly', !empty($_SESSION['untaggedonly'])); $this->tpl->assign('pagetitle', $this->conf->get('general.title', 'Shaarli')); if ($this->conf->exists('general.header_link')) { @@ -172,24 +171,4 @@ class PageBuilder $this->tpl->assign('error_message', $message); $this->renderPage('404'); } - - /** - * Return the next visibility option: - * private -> public -> all - * - * @param string $current visibility value - * - * @return string next visibility value - */ - protected function getNextVisibility($current) - { - switch ($current) { - case 'private': - return 'public'; - case 'public': - return ''; - default: - return 'private'; - } - } } -- cgit v1.2.3