From 4eb6707dc9e793f37c2d5726a18922d9e776714d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 23 Jul 2018 03:18:21 +0200 Subject: [PATCH] Cleanup: (#5463) - rewrote x() to empty() as it is deprecated - fixed indending for some entries --- src/Model/User.php | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/Model/User.php b/src/Model/User.php index 125b722bcf..bebfce3e00 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -314,16 +314,19 @@ class User public static function isNicknameBlocked($nickname) { $forbidden_nicknames = Config::get('system', 'forbidden_nicknames', ''); + // if the config variable is empty return false - if (!x($forbidden_nicknames)) { + if (empty($forbidden_nicknames)) { return false; } + // check if the nickname is in the list of blocked nicknames $forbidden = explode(',', $forbidden_nicknames); $forbidden = array_map('trim', $forbidden); if (in_array(strtolower($nickname), $forbidden)) { return true; } + // else return false return false; } @@ -352,20 +355,20 @@ class User $using_invites = Config::get('system', 'invitation_only'); $num_invites = Config::get('system', 'number_invites'); - $invite_id = x($data, 'invite_id') ? notags(trim($data['invite_id'])) : ''; - $username = x($data, 'username') ? notags(trim($data['username'])) : ''; - $nickname = x($data, 'nickname') ? notags(trim($data['nickname'])) : ''; - $email = x($data, 'email') ? notags(trim($data['email'])) : ''; - $openid_url = x($data, 'openid_url') ? notags(trim($data['openid_url'])) : ''; - $photo = x($data, 'photo') ? notags(trim($data['photo'])) : ''; - $password = x($data, 'password') ? trim($data['password']) : ''; - $password1 = x($data, 'password1') ? trim($data['password1']) : ''; - $confirm = x($data, 'confirm') ? trim($data['confirm']) : ''; - $blocked = x($data, 'blocked') ? intval($data['blocked']) : 0; - $verified = x($data, 'verified') ? intval($data['verified']) : 0; - $language = x($data, 'language') ? notags(trim($data['language'])) : 'en'; - - $publish = x($data, 'profile_publish_reg') && intval($data['profile_publish_reg']) ? 1 : 0; + $invite_id = !empty($data['invite_id']) ? notags(trim($data['invite_id'])) : ''; + $username = !empty($data['username']) ? notags(trim($data['username'])) : ''; + $nickname = !empty($data['nickname']) ? notags(trim($data['nickname'])) : ''; + $email = !empty($data['email']) ? notags(trim($data['email'])) : ''; + $openid_url = !empty($data['openid_url']) ? notags(trim($data['openid_url'])) : ''; + $photo = !empty($data['photo']) ? notags(trim($data['photo'])) : ''; + $password = !empty($data['password']) ? trim($data['password']) : ''; + $password1 = !empty($data['password1']) ? trim($data['password1']) : ''; + $confirm = !empty($data['confirm']) ? trim($data['confirm']) : ''; + $blocked = !empty($data['blocked']) ? intval($data['blocked']) : 0; + $verified = !empty($data['verified']) ? intval($data['verified']) : 0; + $language = !empty($data['language']) ? notags(trim($data['language'])) : 'en'; + + $publish = !empty($data['profile_publish_reg']) && intval($data['profile_publish_reg']) ? 1 : 0; $netpublish = strlen(Config::get('system', 'directory')) ? $publish : 0; if ($password1 != $confirm) { @@ -384,7 +387,7 @@ class User } } - if (!x($username) || !x($email) || !x($nickname)) { + if (empty($username) || empty($email) || empty($nickname)) { if ($openid_url) { if (!Network::isUrlValid($openid_url)) { throw new Exception(L10n::t('Invalid OpenID url')); -- 2.39.5