From b50151d7bf5f05b4cac8afa2674605e195d12e9a Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 7 Jul 2015 14:46:47 +0200 Subject: make directory suggest work with directory options --- include/dir_fns.php | 8 ++++++-- include/widgets.php | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/dir_fns.php b/include/dir_fns.php index 77c78558c..046f05a50 100644 --- a/include/dir_fns.php +++ b/include/dir_fns.php @@ -113,6 +113,8 @@ function dir_sort_links() { $safe_mode = get_safemode_setting($observer); $globaldir = get_globaldir_setting($observer); + $suggest = ($_REQUEST['suggest']) ? '&suggest=' . $_REQUEST['suggest'] : ''; + // Build urls without order and pubforums so it's easy to tack on the changed value // Probably there's an easier way to do this @@ -126,18 +128,20 @@ function dir_sort_links() { $url = 'directory?f='; $tmp = array_merge($_GET,$_POST); + unset($tmp['suggest']); unset($tmp['order']); unset($tmp['q']); unset($tmp['f']); - $sorturl = $url . http_build_query($tmp); + $sorturl = $url . $suggest . http_build_query($tmp); $tmp = array_merge($_GET,$_POST); + unset($tmp['suggest']); unset($tmp['pubforums']); unset($tmp['global']); unset($tmp['safe']); unset($tmp['q']); unset($tmp['f']); - $forumsurl = $url . http_build_query($tmp); + $forumsurl = $url . $suggest . http_build_query($tmp); $o = replace_macros(get_markup_template('dir_sort_links.tpl'), array( '$header' => t('Directory Options'), diff --git a/include/widgets.php b/include/widgets.php index 4a9032a21..888e56733 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -132,7 +132,7 @@ function widget_suggestions($arr) { 'profile' => $rr['xchan_url'], 'name' => $rr['xchan_name'], 'photo' => $rr['xchan_photo_m'], - 'ignlnk' => z_root() . '/suggest?ignore=' . $rr['xchan_hash'], + 'ignlnk' => z_root() . '/directory?ignore=' . $rr['xchan_hash'], 'conntxt' => t('Connect'), 'connlnk' => $connlnk, 'ignore' => t('Ignore/Hide') -- cgit v1.2.3 From cc7eaa0d050cde57024eb7baff042513479ed0c4 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 7 Jul 2015 14:52:06 +0200 Subject: code style correction --- include/dir_fns.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/dir_fns.php b/include/dir_fns.php index 046f05a50..088c0ce96 100644 --- a/include/dir_fns.php +++ b/include/dir_fns.php @@ -113,8 +113,6 @@ function dir_sort_links() { $safe_mode = get_safemode_setting($observer); $globaldir = get_globaldir_setting($observer); - $suggest = ($_REQUEST['suggest']) ? '&suggest=' . $_REQUEST['suggest'] : ''; - // Build urls without order and pubforums so it's easy to tack on the changed value // Probably there's an easier way to do this @@ -123,8 +121,9 @@ function dir_sort_links() { if(! $directory_sort_order) $directory_sort_order = 'date'; - $current_order = (($_REQUEST['order']) ? $_REQUEST['order'] : $directory_sort_order); + $suggest = (($_REQUEST['suggest']) ? '&suggest=' . $_REQUEST['suggest'] : ''); + $url = 'directory?f='; $tmp = array_merge($_GET,$_POST); -- cgit v1.2.3 From 9c577e042292bd8227b40f9500d19eecd974a8e4 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 7 Jul 2015 21:41:37 +0200 Subject: make public forums only setting sticky and simplify function to get directory settings --- include/dir_fns.php | 42 +++++++++++++++--------------------------- include/taxonomy.php | 4 ++-- 2 files changed, 17 insertions(+), 29 deletions(-) (limited to 'include') diff --git a/include/dir_fns.php b/include/dir_fns.php index 088c0ce96..e13c05100 100644 --- a/include/dir_fns.php +++ b/include/dir_fns.php @@ -72,33 +72,20 @@ function check_upstream_directory() { set_config('system', 'directory_server', ''); } -function get_globaldir_setting($observer) { - - if($observer) - $globaldir = get_xconfig($observer,'directory','globaldir'); - else - $globaldir = ((array_key_exists('globaldir',$_SESSION)) ? intval($_SESSION['globaldir']) : false); - - if($globaldir === false) - $globaldir = get_config('directory','globaldir'); - - return $globaldir; -} - -function get_safemode_setting($observer) { +function get_directory_settings($observer, $setting) { if ($observer) - $safe_mode = get_xconfig($observer,'directory','safe_mode'); + $ret = get_xconfig($observer, 'directory', $setting); else - $safe_mode = ((array_key_exists('safemode',$_SESSION)) ? intval($_SESSION['safemode']) : false); + $ret = ((array_key_exists($setting,$_SESSION)) ? intval($_SESSION[$setting]) : false); - if($safe_mode === false) - $safe_mode = get_config('directory','safe_mode'); + if($ret === false) + $ret = get_config('directory', $setting); - if($safe_mode === false) - $safe_mode = 1; + if($setting == 'safe_mode' && $ret === false) + $ret = 1; - return $safe_mode; + return $ret; } /** @@ -110,8 +97,9 @@ function dir_sort_links() { $observer = get_observer_hash(); - $safe_mode = get_safemode_setting($observer); - $globaldir = get_globaldir_setting($observer); + $safe_mode = get_directory_settings($observer, 'safemode'); + $globaldir = get_directory_settings($observer, 'globaldir'); + $pubforums = get_directory_settings($observer, 'pubforums'); // Build urls without order and pubforums so it's easy to tack on the changed value // Probably there's an easier way to do this @@ -128,6 +116,7 @@ function dir_sort_links() { $tmp = array_merge($_GET,$_POST); unset($tmp['suggest']); + unset($tmp['pubforums']); unset($tmp['order']); unset($tmp['q']); unset($tmp['f']); @@ -152,10 +141,9 @@ function dir_sort_links() { '$selected_sort' => $current_order, '$sorturl' => $sorturl, '$forumsurl' => $forumsurl, - '$safemode' => array('safemode', t('Safe Mode'),$safe_mode,'','',' onchange=\'window.location.href="' . $forumsurl . '&safe="+(this.checked ? 1 : 0)\''), - - '$pubforums' => array('pubforums', t('Public Forums Only'),(x($_REQUEST,'pubforums') ? $_REQUEST['pubforums'] : ''),'','',' onchange=\'window.location.href="' . $forumsurl . '&pubforums="+(this.checked ? 1 : 0)\''), - '$globaldir' => array('globaldir', t('This Website Only'), 1-intval($globaldir),'','',' onchange=\'window.location.href="' . $forumsurl . '&global="+(this.checked ? 0 : 1)\''), + '$safemode' => array('safemode', t('Safe Mode'),$safe_mode,'',array(t('No'), t('Yes')),' onchange=\'window.location.href="' . $forumsurl . '&safe="+(this.checked ? 1 : 0)\''), + '$pubforums' => array('pubforums', t('Public Forums Only'),$pubforums,'',array(t('No'), t('Yes')),' onchange=\'window.location.href="' . $forumsurl . '&pubforums="+(this.checked ? 1 : 0)\''), + '$globaldir' => array('globaldir', t('This Website Only'), 1-intval($globaldir),'',array(t('No'), t('Yes')),' onchange=\'window.location.href="' . $forumsurl . '&global="+(this.checked ? 0 : 1)\''), )); return $o; diff --git a/include/taxonomy.php b/include/taxonomy.php index fa540ac56..135843614 100644 --- a/include/taxonomy.php +++ b/include/taxonomy.php @@ -276,7 +276,7 @@ function dir_tagblock($link,$r) { $o = ''; $observer = get_observer_hash(); - if(! get_globaldir_setting($observer)) + if(! get_directory_settings($observer, 'globaldir')) return $o; @@ -407,4 +407,4 @@ function get_things($profile_hash,$uid) { //logger('things: ' . print_r($sorted_things,true)); return $sorted_things; -} \ No newline at end of file +} -- cgit v1.2.3 From f67d9d59afea32a90ea546163da25e36cc4ad9fb Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 7 Jul 2015 22:29:27 +0200 Subject: rename function get_directory_settings => get_directory_setting and move sort options to directory title bar --- include/dir_fns.php | 24 ++++-------------------- include/taxonomy.php | 2 +- 2 files changed, 5 insertions(+), 21 deletions(-) (limited to 'include') diff --git a/include/dir_fns.php b/include/dir_fns.php index e13c05100..29f33f46e 100644 --- a/include/dir_fns.php +++ b/include/dir_fns.php @@ -72,7 +72,7 @@ function check_upstream_directory() { set_config('system', 'directory_server', ''); } -function get_directory_settings($observer, $setting) { +function get_directory_setting($observer, $setting) { if ($observer) $ret = get_xconfig($observer, 'directory', $setting); @@ -97,14 +97,13 @@ function dir_sort_links() { $observer = get_observer_hash(); - $safe_mode = get_directory_settings($observer, 'safemode'); - $globaldir = get_directory_settings($observer, 'globaldir'); - $pubforums = get_directory_settings($observer, 'pubforums'); + $safe_mode = get_directory_setting($observer, 'safemode'); + $globaldir = get_directory_setting($observer, 'globaldir'); + $pubforums = get_directory_setting($observer, 'pubforums'); // Build urls without order and pubforums so it's easy to tack on the changed value // Probably there's an easier way to do this - $directory_sort_order = get_config('system','directory_sort_order'); if(! $directory_sort_order) $directory_sort_order = 'date'; @@ -114,14 +113,6 @@ function dir_sort_links() { $url = 'directory?f='; - $tmp = array_merge($_GET,$_POST); - unset($tmp['suggest']); - unset($tmp['pubforums']); - unset($tmp['order']); - unset($tmp['q']); - unset($tmp['f']); - $sorturl = $url . $suggest . http_build_query($tmp); - $tmp = array_merge($_GET,$_POST); unset($tmp['suggest']); unset($tmp['pubforums']); @@ -133,13 +124,6 @@ function dir_sort_links() { $o = replace_macros(get_markup_template('dir_sort_links.tpl'), array( '$header' => t('Directory Options'), - '$normal' => t('Alphabetic'), - '$reverse' => t('Reverse Alphabetic'), - '$date' => t('Newest to Oldest'), - '$reversedate' => t('Oldest to Newest'), - '$sort' => t('Sort'), - '$selected_sort' => $current_order, - '$sorturl' => $sorturl, '$forumsurl' => $forumsurl, '$safemode' => array('safemode', t('Safe Mode'),$safe_mode,'',array(t('No'), t('Yes')),' onchange=\'window.location.href="' . $forumsurl . '&safe="+(this.checked ? 1 : 0)\''), '$pubforums' => array('pubforums', t('Public Forums Only'),$pubforums,'',array(t('No'), t('Yes')),' onchange=\'window.location.href="' . $forumsurl . '&pubforums="+(this.checked ? 1 : 0)\''), diff --git a/include/taxonomy.php b/include/taxonomy.php index 135843614..a5da190d4 100644 --- a/include/taxonomy.php +++ b/include/taxonomy.php @@ -276,7 +276,7 @@ function dir_tagblock($link,$r) { $o = ''; $observer = get_observer_hash(); - if(! get_directory_settings($observer, 'globaldir')) + if(! get_directory_setting($observer, 'globaldir')) return $o; -- cgit v1.2.3 From f6cf992aee86e69d1ea5790c22d4af40c266d79e Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 7 Jul 2015 22:48:01 +0200 Subject: fix sorting of channel suggestions --- include/dir_fns.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/dir_fns.php b/include/dir_fns.php index 29f33f46e..be8175d06 100644 --- a/include/dir_fns.php +++ b/include/dir_fns.php @@ -120,7 +120,7 @@ function dir_sort_links() { unset($tmp['safe']); unset($tmp['q']); unset($tmp['f']); - $forumsurl = $url . $suggest . http_build_query($tmp); + $forumsurl = $url . http_build_query($tmp) . $suggest; $o = replace_macros(get_markup_template('dir_sort_links.tpl'), array( '$header' => t('Directory Options'), -- cgit v1.2.3