Fix for possible notice "Undefined offset: 0"

This commit is contained in:
Michael 2019-02-10 06:04:11 +00:00
parent b2c2971551
commit 81ef96fd16

View file

@ -28,20 +28,21 @@ function friendica_init(App $a)
$register_policy = $register_policies[$register_policy_int];
}
$sql_extra = '';
if (Config::get('config', 'admin_nickname') !== null) {
$sql_extra = sprintf(" AND `nickname` = '%s' ", DBA::escape(Config::get('config', 'admin_nickname')));
$condition = [];
$admin = false;
if (!empty(Config::get('config', 'admin_nickname'))) {
$condition['nickname'] = Config::get('config', 'admin_nickname');
}
if (!empty(Config::get('config', 'admin_email'))) {
$adminlist = explode(",", str_replace(" ", "", Config::get('config', 'admin_email')));
$r = q("SELECT `username`, `nickname` FROM `user` WHERE `email` = '%s' $sql_extra", DBA::escape($adminlist[0]));
$condition['email'] = $adminlist[0];
$administrator = DBA::selectFirst('user', ['username', 'nickname'], $condition);
if (DBA::isResult($administrator)) {
$admin = [
'name' => $r[0]['username'],
'profile'=> System::baseUrl() . '/profile/' . $r[0]['nickname'],
'name' => $administrator['username'],
'profile'=> System::baseUrl() . '/profile/' . $administrator['nickname'],
];
} else {
$admin = false;
}
}
$visible_addons = Addon::getVisibleList();