X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FUser.php;h=3fbbc6e86b13496f27e86595451ff20e4ddc386e;hb=82cef6c9e7326303d9790451d0a757978246b28c;hp=8d4e52cacc79640d0375a58133143f4b64f93b78;hpb=f051ae169868905d3f3debbed37c8cf0f8b2be35;p=friendica.git diff --git a/src/Model/User.php b/src/Model/User.php index 8d4e52cacc..3fbbc6e86b 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -14,7 +14,6 @@ use Friendica\Core\PConfig; use Friendica\Core\System; use Friendica\Core\Worker; use Friendica\Database\DBA; -use Friendica\Database\DBM; use Friendica\Object\Image; use Friendica\Util\Crypto; use Friendica\Util\DateTimeFormat; @@ -56,7 +55,7 @@ class User LIMIT 1", $uid ); - if (!DBM::is_result($r)) { + if (!DBA::isResult($r)) { return false; } return $r; @@ -71,7 +70,7 @@ class User public static function getOwnerDataByNick($nick) { $user = DBA::selectFirst('user', ['uid'], ['nickname' => $nick]); - if (!DBM::is_result($user)) { + if (!DBA::isResult($user)) { return false; } return self::getOwnerDataById($user['uid']); @@ -99,7 +98,7 @@ class User $user = DBA::selectFirst('user', ['def_gid'], ['uid' => $uid]); - if (DBM::is_result($user)) { + if (DBA::isResult($user)) { $default_group = $user["def_gid"]; } @@ -215,7 +214,7 @@ class User $user = DBA::selectFirst('user', $fields, $condition); } - if (!DBM::is_result($user)) { + if (!DBA::isResult($user)) { throw new Exception(L10n::t('User not found')); } } @@ -314,16 +313,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 +354,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 +386,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')); @@ -727,7 +729,8 @@ class User Worker::add(PRIORITY_HIGH, "Notifier", "removeme", $uid); // Send an update to the directory - Worker::add(PRIORITY_LOW, "Directory", $user['url']); + $self = DBA::selectFirst('contact', ['url'], ['uid' => $uid, 'self' => true]); + Worker::add(PRIORITY_LOW, "Directory", $self['url']); if ($uid == local_user()) { unset($_SESSION['authenticated']);