Improved functionality to fetch the admin user

This commit is contained in:
Michael 2020-07-29 14:55:55 +00:00
parent e06d9f20cf
commit 2a243b747d

View file

@ -193,18 +193,15 @@ class User
*/ */
public static function getFirstAdmin(array $fields = []) public static function getFirstAdmin(array $fields = [])
{ {
$condition = [];
if (!empty(DI::config()->get('config', 'admin_nickname'))) { if (!empty(DI::config()->get('config', 'admin_nickname'))) {
$condition['nickname'] = DI::config()->get('config', 'admin_nickname'); $administrator = self::getByNickname(DI::config()->get('config', 'admin_nickname'), $fields);
} } elseif (!empty(DI::config()->get('config', 'admin_email'))) {
if (!empty(DI::config()->get('config', 'admin_email'))) {
$adminList = explode(',', str_replace(' ', '', DI::config()->get('config', 'admin_email'))); $adminList = explode(',', str_replace(' ', '', DI::config()->get('config', 'admin_email')));
$condition['email'] = $adminList[0];
$administrator = self::getByEmail($adminList[0], $fields); $administrator = self::getByEmail($adminList[0], $fields);
}
if (!empty($administrator)) { if (!empty($administrator)) {
return $administrator; return $administrator;
} }
}
return []; return [];
} }