X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapiuserprofileimage.php;h=c9c8eab9af5fce75c3bcf2876a53dc9c752063b5;hb=d6b28c64830f632bb2f4b6f3c9369b9e56ad217a;hp=d2cf9a3e579fe21cd20df074ab5eace3fb87ccef;hpb=fb8312ebf4537033077917d0003f716206d0d23d;p=quix0rs-gnu-social.git diff --git a/actions/apiuserprofileimage.php b/actions/apiuserprofileimage.php index d2cf9a3e57..c9c8eab9af 100644 --- a/actions/apiuserprofileimage.php +++ b/actions/apiuserprofileimage.php @@ -31,8 +31,6 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR . '/lib/apiprivateauth.php'; - /** * Ouputs avatar URL for a user, specified by screen name. * Unlike most API endpoints, this returns an HTTP redirect rather than direct data. @@ -53,10 +51,15 @@ class ApiUserProfileImageAction extends ApiPrivateAuthAction * @return boolean success flag * */ - function prepare($args) + protected function prepare(array $args=array()) { parent::prepare($args); - $this->user = User::staticGet('nickname', $this->arg('screen_name')); + $user = User::getKV('nickname', $this->arg('screen_name')); + if (!($user instanceof User)) { + // TRANS: Client error displayed when requesting user information for a non-existing user. + $this->clientError(_('User not found.'), 404); + } + $this->target = $user->getProfile(); $this->size = $this->arg('size'); return true; @@ -67,35 +70,14 @@ class ApiUserProfileImageAction extends ApiPrivateAuthAction * * Check the format and show the user info * - * @param array $args $_REQUEST data (unused) - * * @return void */ - function handle($args) + protected function handle() { - parent::handle($args); - - if (empty($this->user)) { - // TRANS: Client error displayed when requesting user information for a non-existing user. - $this->clientError(_('User not found.'), 404, $this->format); - return; - } - - $profile = $this->user->getProfile(); - - if (empty($profile)) { - // TRANS: Client error displayed when requesting user information for a user without a profile. - $this->clientError(_('User has no profile.')); - return; - } + parent::handle(); $size = $this->avatarSize(); - $avatar = $profile->getAvatar($size); - if ($avatar) { - $url = $avatar->displayUrl(); - } else { - $url = Avatar::defaultImage($size); - } + $url = $this->target->avatarUrl($size); // We don't actually output JSON or XML data -- redirect! common_redirect($url, 302); @@ -128,7 +110,7 @@ class ApiUserProfileImageAction extends ApiPrivateAuthAction * * @return boolean is read only action? */ - function isReadOnly($args) + function isReadOnly(array $args=array()) { return true; }