diff options
author | Evan Prodromou <evan@status.net> | 2010-12-06 15:52:03 -0500 |
---|---|---|
committer | Evan Prodromou <evan@status.net> | 2010-12-06 15:52:03 -0500 |
commit | da8b268e06f4a6217c2bbb4918888001f8e7e4cd (patch) | |
tree | ddf92bbbf01ea46a49258a1ea58b9f24df5ab3ab /classes | |
parent | 0c0418bdfbb40f7fae02cca4cf1a09746bae8b3a (diff) | |
parent | 2617c40e048aee071b72b4b5f664fab36e6c632d (diff) |
Merge branch '0.9.x' of gitorious.org:statusnet/mainline into 0.9.x
Diffstat (limited to 'classes')
-rw-r--r-- | classes/User.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/classes/User.php b/classes/User.php index 041c64c38..8a3190cbf 100644 --- a/classes/User.php +++ b/classes/User.php @@ -929,6 +929,38 @@ class User extends Memcached_DataObject } /** + * This is kind of a hack for using external setup code that's trying to + * build single-user sites. + * + * Will still return a username if the config singleuser/nickname is set + * even if the account doesn't exist, which normally indicates that the + * site is horribly misconfigured. + * + * At the moment, we need to let it through so that router setup can + * complete, otherwise we won't be able to create the account. + * + * This will be easier when we can more easily create the account and + * *then* switch the site to 1user mode without jumping through hoops. + * + * @return string + * @throws ServerException if no valid single user account is present + * @throws ServerException if called when not in single-user mode + */ + static function singleUserNickname() + { + try { + $user = User::singleUser(); + return $user->nickname; + } catch (Exception $e) { + if (common_config('singleuser', 'enabled') && common_config('singleuser', 'nickname')) { + common_log(LOG_WARN, "Warning: code attempting to pull single-user nickname when the account does not exist. If this is not setup time, this is probably a bug."); + return common_config('singleuser', 'nickname'); + } + throw $e; + } + } + + /** * Find and shorten links in the given text using this user's URL shortening * settings. * |