123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- if (!defined('GNUSOCIAL')) { exit(1); }
- class AvatarbynicknameAction extends Action
- {
-
- protected function handle()
- {
- parent::handle();
- $nickname = $this->trimmed('nickname');
- if (!$nickname) {
-
- $this->clientError(_('No nickname.'));
- }
- $size = $this->trimmed('size') ?: 'original';
- $user = User::getKV('nickname', $nickname);
- if (!$user) {
-
- $this->clientError(_('No such user.'));
- }
- $profile = $user->getProfile();
- if (!$profile) {
-
- $this->clientError(_('User has no profile.'));
- }
- if ($size === 'original') {
- try {
- $avatar = Avatar::getUploaded($profile);
- $url = $avatar->displayUrl();
- } catch (NoAvatarException $e) {
- $url = Avatar::defaultImage(AVATAR_PROFILE_SIZE);
- }
- } else {
- $url = $profile->avatarUrl($size);
- }
- common_redirect($url, 302);
- }
- function isReadOnly($args)
- {
- return true;
- }
- }
|