From c65a5cc0d52ef0a72f4f65cf59dd552c99f2f1bf Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 13 Jan 2020 17:03:04 +0000 Subject: [PATCH 1/3] Use "http_build_query" to build queries --- mod/network.php | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/mod/network.php b/mod/network.php index 0308e4a10e..22282335f0 100644 --- a/mod/network.php +++ b/mod/network.php @@ -936,9 +936,15 @@ function network_tabs(App $a) ], ]; + $parameters = ['conv' => true]; + if (!empty($_GET['cid'])) { + $parameters['cid'] = $_GET['cid']; + } + $query = '?' . http_build_query($parameters); + $tabs[] = [ 'label' => L10n::t('Personal'), - 'url' => str_replace('/new', '', $cmd) . (!empty($_GET['cid']) ? '/?cid=' . $_GET['cid'] : '/?f=') . '&conv=1', + 'url' => str_replace('/new', '', $cmd) . $query, 'sel' => $conv_active, 'title' => L10n::t('Posts that mention or involve you'), 'id' => 'personal-tab', @@ -946,9 +952,15 @@ function network_tabs(App $a) ]; if (Feature::isEnabled(local_user(), 'new_tab')) { + $parameters = []; + if (!empty($_GET['cid'])) { + $parameters['cid'] = $_GET['cid']; + } + $query = '?' . http_build_query($parameters); + $tabs[] = [ 'label' => L10n::t('New'), - 'url' => 'network/new' . (!empty($_GET['cid']) ? '/?cid=' . $_GET['cid'] : ''), + 'url' => 'network/new' . $query, 'sel' => $new_active, 'title' => L10n::t('Activity Stream - by date'), 'id' => 'activitiy-by-date-tab', @@ -957,9 +969,15 @@ function network_tabs(App $a) } if (Feature::isEnabled(local_user(), 'link_tab')) { + $parameters = ['bmark' => true]; + if (!empty($_GET['cid'])) { + $parameters['cid'] = $_GET['cid']; + } + $query = '?' . http_build_query($parameters); + $tabs[] = [ 'label' => L10n::t('Shared Links'), - 'url' => str_replace('/new', '', $cmd) . (!empty($_GET['cid']) ? '/?cid=' . $_GET['cid'] : '/?f=') . '&bmark=1', + 'url' => str_replace('/new', '', $cmd) . $query, 'sel' => $bookmarked_active, 'title' => L10n::t('Interesting Links'), 'id' => 'shared-links-tab', @@ -967,9 +985,15 @@ function network_tabs(App $a) ]; } + $parameters = ['tar' => true]; + if (!empty($_GET['cid'])) { + $parameters['cid'] = $_GET['cid']; + } + $query = '?' . http_build_query($parameters); + $tabs[] = [ 'label' => L10n::t('Starred'), - 'url' => str_replace('/new', '', $cmd) . (!empty($_GET['cid']) ? '/?cid=' . $_GET['cid'] : '/?f=') . '&star=1', + 'url' => str_replace('/new', '', $cmd) . $query, 'sel' => $starred_active, 'title' => L10n::t('Favourite Posts'), 'id' => 'starred-posts-tab', From 1c9fa4451a4b900479478762453395eaa5b4d04c Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 13 Jan 2020 17:07:05 +0000 Subject: [PATCH 2/3] Improved query --- mod/network.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mod/network.php b/mod/network.php index 22282335f0..e71bbe910e 100644 --- a/mod/network.php +++ b/mod/network.php @@ -952,11 +952,11 @@ function network_tabs(App $a) ]; if (Feature::isEnabled(local_user(), 'new_tab')) { - $parameters = []; if (!empty($_GET['cid'])) { - $parameters['cid'] = $_GET['cid']; + $query = '?' . http_build_query(['cid' => $_GET['cid']]); + } else { + $query = ''; } - $query = '?' . http_build_query($parameters); $tabs[] = [ 'label' => L10n::t('New'), From ac04ff88b849a331b3628d74fc5d83f440cee3dd Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 13 Jan 2020 17:10:11 +0000 Subject: [PATCH 3/3] Improved code --- mod/network.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/mod/network.php b/mod/network.php index e71bbe910e..acf6c62716 100644 --- a/mod/network.php +++ b/mod/network.php @@ -940,11 +940,10 @@ function network_tabs(App $a) if (!empty($_GET['cid'])) { $parameters['cid'] = $_GET['cid']; } - $query = '?' . http_build_query($parameters); $tabs[] = [ 'label' => L10n::t('Personal'), - 'url' => str_replace('/new', '', $cmd) . $query, + 'url' => str_replace('/new', '', $cmd) . '?' . http_build_query($parameters), 'sel' => $conv_active, 'title' => L10n::t('Posts that mention or involve you'), 'id' => 'personal-tab', @@ -973,11 +972,10 @@ function network_tabs(App $a) if (!empty($_GET['cid'])) { $parameters['cid'] = $_GET['cid']; } - $query = '?' . http_build_query($parameters); $tabs[] = [ 'label' => L10n::t('Shared Links'), - 'url' => str_replace('/new', '', $cmd) . $query, + 'url' => str_replace('/new', '', $cmd) . '?' . http_build_query($parameters), 'sel' => $bookmarked_active, 'title' => L10n::t('Interesting Links'), 'id' => 'shared-links-tab', @@ -989,11 +987,10 @@ function network_tabs(App $a) if (!empty($_GET['cid'])) { $parameters['cid'] = $_GET['cid']; } - $query = '?' . http_build_query($parameters); $tabs[] = [ 'label' => L10n::t('Starred'), - 'url' => str_replace('/new', '', $cmd) . $query, + 'url' => str_replace('/new', '', $cmd) . '?' . http_build_query($parameters), 'sel' => $starred_active, 'title' => L10n::t('Favourite Posts'), 'id' => 'starred-posts-tab',