Merge pull request #6621 from annando/notice

Fix for possible notice "Undefined offset: 0"
This commit is contained in:
Tobias Diekershoff 2019-02-10 08:03:30 +01:00 committed by GitHub
commit d65b29af57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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