aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/dir_fns.php42
-rw-r--r--include/taxonomy.php4
-rw-r--r--mod/directory.php27
3 files changed, 34 insertions, 39 deletions
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
+}
diff --git a/mod/directory.php b/mod/directory.php
index 6d066a21b..6dea0e992 100644
--- a/mod/directory.php
+++ b/mod/directory.php
@@ -19,6 +19,7 @@ function directory_init(&$a) {
$observer = get_observer_hash();
$global_changed = false;
$safe_changed = false;
+ $pubforums_changed = false;
if(array_key_exists('global',$_REQUEST)) {
$globaldir = intval($_REQUEST['global']);
@@ -28,7 +29,7 @@ function directory_init(&$a) {
$_SESSION['globaldir'] = $globaldir;
if($observer)
set_xconfig($observer,'directory','globaldir',$globaldir);
- }
+ }
if(array_key_exists('safe',$_REQUEST)) {
$safemode = intval($_REQUEST['safe']);
@@ -37,9 +38,19 @@ function directory_init(&$a) {
if($safe_changed) {
$_SESSION['safemode'] = $safemode;
if($observer)
- set_xconfig($observer,'directory','safe_mode',$safemode);
- }
+ set_xconfig($observer,'directory','safemode',$safemode);
+ }
+
+ if(array_key_exists('pubforums',$_REQUEST)) {
+ $pubforums = intval($_REQUEST['pubforums']);
+ $pubforums_changed = true;
+ }
+ if($pubforums_changed) {
+ $_SESSION['pubforums'] = $pubforums;
+ if($observer)
+ set_xconfig($observer,'directory','pubforums',$pubforums);
+ }
}
function directory_content(&$a) {
@@ -51,18 +62,14 @@ function directory_content(&$a) {
$observer = get_observer_hash();
- $globaldir = get_globaldir_setting($observer);
+ $globaldir = get_directory_settings($observer, 'globaldir');
// override your personal global search pref if we're doing a navbar search of the directory
if(intval($_REQUEST['navsearch']))
$globaldir = 1;
- $safe_mode = get_safemode_setting($observer);
+ $safe_mode = get_directory_settings($observer, 'safemode');
- $pubforums = null;
- if(array_key_exists('pubforums',$_REQUEST))
- $pubforums = intval($_REQUEST['pubforums']);
- if(! $pubforums)
- $pubforums = null;
+ $pubforums = get_directory_settings($observer, 'pubforums');
$o = '';
nav_set_selected('directory');