3 * Retrieve user avatar by nickname action class.
9 * @author Evan Prodromou <evan@controlyourself.ca>
10 * @author Robin Millette <millette@controlyourself.ca>
11 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
12 * @link http://laconi.ca/
14 * Laconica - a distributed open-source microblogging tool
15 * Copyright (C) 2008, Controlez-Vous, Inc.
17 * This program is free software: you can redistribute it and/or modify
18 * it under the terms of the GNU Affero General Public License as published by
19 * the Free Software Foundation, either version 3 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU Affero General Public License for more details.
27 * You should have received a copy of the GNU Affero General Public License
28 * along with this program. If not, see <http://www.gnu.org/licenses/>.
31 if (!defined('LACONICA')) {
36 * Retrieve user avatar by nickname action class.
40 * @author Evan Prodromou <evan@controlyourself.ca>
41 * @author Robin Millette <millette@controlyourself.ca>
42 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
43 * @link http://laconi.ca/
45 class AvatarbynicknameAction extends Action
50 * @param array $args query arguments
52 * @return boolean false if nickname or user isn't found
54 function handle($args)
56 parent::handle($args);
57 $nickname = $this->trimmed('nickname');
59 $this->clientError(_('No nickname.'));
62 $size = $this->trimmed('size');
64 $this->clientError(_('No size.'));
67 $size = strtolower($size);
68 if (!in_array($size, array('original', '96', '48', '24'))) {
69 $this->clientError(_('Invalid size.'));
73 $user = User::staticGet('nickname', $nickname);
75 $this->clientError(_('No such user.'));
78 $profile = $user->getProfile();
80 $this->clientError(_('User has no profile.'));
83 if ($size == 'original') {
84 $avatar = $profile->getOriginal();
86 $avatar = $profile->getAvatar($size+0);
92 if ($size == 'original') {
93 $url = Avatar::defaultImage(AVATAR_PROFILE_SIZE);
95 $url = Avatar::defaultImage($size+0);
98 common_redirect($url, 302);
101 function isReadOnly($args)