3 * Retrieve user avatar by nickname action class.
9 * @author Evan Prodromou <evan@status.net>
10 * @author Robin Millette <millette@status.net>
11 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
12 * @link http://status.net/
14 * StatusNet - the distributed open-source microblogging tool
15 * Copyright (C) 2008, 2009, StatusNet, 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('STATUSNET') && !defined('LACONICA')) {
36 * Retrieve user avatar by nickname action class.
40 * @author Evan Prodromou <evan@status.net>
41 * @author Robin Millette <millette@status.net>
42 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
43 * @link http://status.net/
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 // TRANS: Client error displayed trying to get an avatar without providing a nickname.
60 $this->clientError(_('No nickname.'));
63 $size = $this->trimmed('size');
65 // TRANS: Client error displayed trying to get an avatar without providing an avatar size.
66 $this->clientError(_('No size.'));
69 $size = strtolower($size);
70 if (!in_array($size, array('original', '96', '48', '24'))) {
71 // TRANS: Client error displayed trying to get an avatar providing an invalid avatar size.
72 $this->clientError(_('Invalid size.'));
76 $user = User::staticGet('nickname', $nickname);
78 // TRANS: Client error displayed trying to get an avatar for a non-existing user.
79 $this->clientError(_('No such user.'));
82 $profile = $user->getProfile();
84 // TRANS: Error message displayed when referring to a user without a profile.
85 $this->clientError(_('User has no profile.'));
88 if ($size == 'original') {
89 $avatar = $profile->getOriginal();
91 $avatar = $profile->getAvatar($size+0);
97 if ($size == 'original') {
98 $url = Avatar::defaultImage(AVATAR_PROFILE_SIZE);
100 $url = Avatar::defaultImage($size+0);
103 common_redirect($url, 302);
106 function isReadOnly($args)