diff options
author | Zach Copley <zach@status.net> | 2010-10-20 17:28:28 -0700 |
---|---|---|
committer | Zach Copley <zach@status.net> | 2010-10-20 17:28:28 -0700 |
commit | bfdb8385ecc745002b8c45510caf2fdf7c2d2c9f (patch) | |
tree | 392196b097fafb10430bb7db763fd744a0639bf3 /classes | |
parent | e56385a7bb25336a72c1d37ad43d51ba8e238231 (diff) | |
parent | 31f52ec37c5a2be76c197a9c492d3a236af045cd (diff) |
Merge branch '0.9.x' of gitorious.org:statusnet/mainline into 0.9.x
Conflicts:
actions/apioauthauthorize.php
lib/apioauthstore.php
Diffstat (limited to 'classes')
-rw-r--r-- | classes/User.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/classes/User.php b/classes/User.php index e784fd9e9..f381ec607 100644 --- a/classes/User.php +++ b/classes/User.php @@ -875,4 +875,35 @@ class User extends Memcached_DataObject return $owner; } + + /** + * Pull the primary site account to use in single-user mode. + * If a valid user nickname is listed in 'singleuser':'nickname' + * in the config, this will be used; otherwise the site owner + * account is taken by default. + * + * @return User + * @throws ServerException if no valid single user account is present + * @throws ServerException if called when not in single-user mode + */ + static function singleUser() + { + if (common_config('singleuser', 'enabled')) { + $nickname = common_config('singleuser', 'nickname'); + if ($nickname) { + $user = User::staticGet('nickname', $nickname); + } else { + $user = User::siteOwner(); + } + if ($user) { + return $user; + } else { + // TRANS: Server exception. + throw new ServerException(_('No single user defined for single-user mode.')); + } + } else { + // TRANS: Server exception. + throw new ServerException(_('Single-user mode code called when not enabled.')); + } + } } |