From 8004e2809d98bdd535a3c59bd7d15c3fa2dd7ba9 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 20 Oct 2010 14:34:25 -0700 Subject: Fix for ticket #2845: singleuser nickname configuration was being overridden by site owner in router setup. I've consolidated the checks for which user to use for single-user mode into User::singleUser(), which now uses the configured nickname by preference, falling back to the site owner if it's unset. This is now called consistently from the places that needed to use the primary user's nickname in routing setup. Setting $config['singleuser']['nickname'] should now work again as expected. --- lib/action.php | 3 ++- lib/router.php | 12 ++---------- lib/util.php | 3 ++- 3 files changed, 6 insertions(+), 12 deletions(-) (limited to 'lib') diff --git a/lib/action.php b/lib/action.php index 55ee83bde..e273b5d04 100644 --- a/lib/action.php +++ b/lib/action.php @@ -419,8 +419,9 @@ class Action extends HTMLOutputter // lawsuit 'class' => 'vcard')); if (Event::handle('StartAddressData', array($this))) { if (common_config('singleuser', 'enabled')) { + $user = User::singleUser(); $url = common_local_url('showstream', - array('nickname' => common_config('singleuser', 'nickname'))); + array('nickname' => $user->nickname)); } else { $url = common_local_url('public'); } diff --git a/lib/router.php b/lib/router.php index b1cc8d529..8c682cefa 100644 --- a/lib/router.php +++ b/lib/router.php @@ -701,16 +701,8 @@ class Router if (common_config('singleuser', 'enabled')) { - $user = User::siteOwner(); - - if (!empty($user)) { - $nickname = $user->nickname; - } else { - $nickname = common_config('singleuser', 'nickname'); - if (empty($nickname)) { - throw new ServerException(_("No single user defined for single-user mode.")); - } - } + $user = User::singleUser(); + $nickname = $user->nickname; foreach (array('subscriptions', 'subscribers', 'all', 'foaf', 'xrds', diff --git a/lib/util.php b/lib/util.php index 5a94182bd..86380af28 100644 --- a/lib/util.php +++ b/lib/util.php @@ -974,8 +974,9 @@ function common_tag_link($tag) $canonical = common_canonical_tag($tag); if (common_config('singleuser', 'enabled')) { // regular TagAction isn't set up in 1user mode + $user = User::singleUser(); $url = common_local_url('showstream', - array('nickname' => common_config('singleuser', 'nickname'), + array('nickname' => $user->nickname, 'tag' => $canonical)); } else { $url = common_local_url('tag', array('tag' => $canonical)); -- cgit v1.2.3-54-g00ecf