From: Brion Vibber Date: Mon, 6 Dec 2010 20:44:19 +0000 (-0800) Subject: Merge branch 'master' of gitorious.org:statusnet/mainline into 0.9.x X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2617c40e048aee071b72b4b5f664fab36e6c632d;p=quix0rs-gnu-social.git Merge branch 'master' of gitorious.org:statusnet/mainline into 0.9.x Conflicts: classes/User.php --- 2617c40e048aee071b72b4b5f664fab36e6c632d diff --cc classes/User.php index 041c64c38f,c824ddb0c2..8a3190cbf2 --- a/classes/User.php +++ b/classes/User.php @@@ -928,22 -918,35 +928,54 @@@ class User extends Memcached_DataObjec } } + /** + * 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. + * + * By default, links will be left untouched if the text is shorter than the + * configured maximum notice length. Pass true for the $always parameter + * to force all links to be shortened regardless. + * + * Side effects: may save file and file_redirection records for referenced URLs. + * + * @param string $text + * @param boolean $always + * @return string + */ + public function shortenLinks($text, $always=false) + { + return common_shorten_links($text, $always, $this); + } }