123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- class ApiUserProfileImageAction extends ApiPrivateAuthAction
- {
-
- protected function prepare(array $args=array())
- {
- parent::prepare($args);
- $user = User::getKV('nickname', $this->arg('screen_name'));
- if (!($user instanceof User)) {
-
- $this->clientError(_('User not found.'), 404);
- }
- $this->target = $user->getProfile();
- $this->size = $this->arg('size');
- return true;
- }
-
- protected function handle()
- {
- parent::handle();
- $size = $this->avatarSize();
- $url = $this->target->avatarUrl($size);
-
- common_redirect($url, 302);
- }
-
- private function avatarSize()
- {
- switch ($this->size) {
- case 'mini':
- return AVATAR_MINI_SIZE;
- case 'bigger':
- return AVATAR_PROFILE_SIZE;
- case 'normal':
- default:
- return AVATAR_STREAM_SIZE;
- }
- }
-
- function isReadOnly($args)
- {
- return true;
- }
- }
|