summaryrefslogtreecommitdiff
path: root/classes/User.php
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-10-25 13:08:57 -0700
committerBrion Vibber <brion@pobox.com>2010-10-25 13:08:57 -0700
commitca489631db840e33757a71a7e4cb56b187c182d3 (patch)
tree92c71b81b6870a8fd2d9c94bed8571b653d95413 /classes/User.php
parent90c87553ee7566593529199374215ae80bb3e209 (diff)
parent01637bcd32921d6857fb7f5c0bbd40fba6bdb830 (diff)
Merge branch '0.9.x' into 1.0.x
Conflicts: actions/subscriptions.php lib/router.php lib/xmppmanager.php lib/xmppoutqueuehandler.php
Diffstat (limited to 'classes/User.php')
-rw-r--r--classes/User.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/classes/User.php b/classes/User.php
index 259df7e2c..9188938b1 100644
--- a/classes/User.php
+++ b/classes/User.php
@@ -870,4 +870,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.'));
+ }
+ }
}