X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FUser.php;h=71e2c8a81200d2942ad64f62dd642a4146688e6f;hb=8dc0ab9bb3379fec0be442160db1ae29ef8cea9d;hp=57d5560a47cec7d4ad7e68c64f01b829c3309da7;hpb=edcfeaf66d797cc6bc9edf966b91b5eb95e5f127;p=friendica.git diff --git a/src/Model/User.php b/src/Model/User.php index 57d5560a47..71e2c8a812 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -1,6 +1,6 @@ $uid]); if (DBA::isResult($user)) { @@ -499,26 +500,6 @@ class User return $default_group; } - - /** - * Authenticate a user with a clear text password - * - * @param mixed $user_info - * @param string $password - * @param bool $third_party - * @return int|boolean - * @deprecated since version 3.6 - * @see User::getIdFromPasswordAuthentication() - */ - public static function authenticate($user_info, $password, $third_party = false) - { - try { - return self::getIdFromPasswordAuthentication($user_info, $password, $third_party); - } catch (Exception $ex) { - return false; - } - } - /** * Authenticate a user with a clear text password * @@ -871,19 +852,46 @@ class User break; } - $updated = ''; - $imagetype = IMAGETYPE_JPEG; + $updated = ''; + $mimetype = ''; $photo = Photo::selectFirst(['type', 'created', 'edited', 'updated'], ["scale" => $scale, 'uid' => $user['uid'], 'profile' => true]); if (!empty($photo)) { - $updated = max($photo['created'], $photo['edited'], $photo['updated']); + $updated = max($photo['created'], $photo['edited'], $photo['updated']); + $mimetype = $photo['type']; + } - if (in_array($photo['type'], ['image/png', 'image/gif'])) { - $imagetype = IMAGETYPE_PNG; - } + return $url . $user['nickname'] . Images::getExtensionByMimeType($mimetype) . ($updated ? '?ts=' . strtotime($updated) : ''); + } + + /** + * Get banner link for given user + * + * @param array $user + * @return string banner link + * @throws Exception + */ + public static function getBannerUrl(array $user):string + { + if (empty($user['nickname'])) { + DI::logger()->warning('Missing user nickname key', ['trace' => System::callstack(20)]); + } + + $url = DI::baseUrl() . '/photo/banner/'; + + $updated = ''; + $mimetype = ''; + + $photo = Photo::selectFirst(['type', 'created', 'edited', 'updated'], ["scale" => 3, 'uid' => $user['uid'], 'photo-type' => Photo::USER_BANNER]); + if (!empty($photo)) { + $updated = max($photo['created'], $photo['edited'], $photo['updated']); + $mimetype = $photo['type']; + } else { + // Only for the RC phase: Don't return an image link for the default picture + return ''; } - return $url . $user['nickname'] . image_type_to_extension($imagetype) . ($updated ? '?ts=' . strtotime($updated) : ''); + return $url . $user['nickname'] . Images::getExtensionByMimeType($mimetype) . ($updated ? '?ts=' . strtotime($updated) : ''); } /** @@ -1144,8 +1152,9 @@ class User $photo_failure = false; $filename = basename($photo); - $curlResult = DI::httpClient()->get($photo); + $curlResult = DI::httpClient()->get($photo, HttpClientAccept::IMAGE); if ($curlResult->isSuccess()) { + Logger::debug('Got picture', ['Content-Type' => $curlResult->getHeader('Content-Type'), 'url' => $photo]); $img_str = $curlResult->getBody(); $type = $curlResult->getContentType(); } else { @@ -1279,7 +1288,7 @@ class User $profile = DBA::selectFirst('profile', ['net-publish'], ['uid' => $register['uid']]); - if (DBA::isResult($profile) && $profile['net-publish'] && DI::config()->get('system', 'directory')) { + if (DBA::isResult($profile) && $profile['net-publish'] && Search::getGlobalDirectory()) { $url = DI::baseUrl() . '/profile/' . $user['nickname']; Worker::add(PRIORITY_LOW, "Directory", $url); }