X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapiaccountupdateprofileimage.php;h=383818415e5c211bc31329ecb48a26c4563bce12;hb=c498db147aaa427de9b1eb4ceef33e09c3b01596;hp=986a8f3f1eed69c5c11d46dec84112b1e29458cb;hpb=621a7cb36df9e3962aac7b473478c634e97e70e1;p=quix0rs-gnu-social.git diff --git a/actions/apiaccountupdateprofileimage.php b/actions/apiaccountupdateprofileimage.php index 986a8f3f1e..383818415e 100644 --- a/actions/apiaccountupdateprofileimage.php +++ b/actions/apiaccountupdateprofileimage.php @@ -31,8 +31,6 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR . '/lib/apiauth.php'; - /** * Updates the authenticating user's profile image. Note that this API method * expects raw multipart data, not a URL to an image. @@ -45,43 +43,18 @@ require_once INSTALLDIR . '/lib/apiauth.php'; */ class ApiAccountUpdateProfileImageAction extends ApiAuthAction { - /** - * Take arguments for running - * - * @param array $args $_REQUEST args - * - * @return boolean success flag - */ - function prepare($args) - { - parent::prepare($args); - - $this->user = $this->auth_user; - - return true; - } + protected $needPost = true; /** * Handle the request * * Check whether the credentials are valid and output the result * - * @param array $args $_REQUEST data (unused) - * * @return void */ - function handle($args) + protected function handle() { - parent::handle($args); - - if ($_SERVER['REQUEST_METHOD'] != 'POST') { - $this->clientError( - // TRANS: Client error. POST is a HTTP command. It should not be translated. - _('This method requires a POST.'), - 400, $this->format - ); - return; - } + parent::handle(); // Workaround for PHP returning empty $_POST and $_FILES when POST // length > post_max_size in php.ini @@ -96,20 +69,17 @@ class ApiAccountUpdateProfileImageAction extends ApiAuthAction 'The server was unable to handle that much POST data (%s bytes) due to its current configuration.', intval($_SERVER['CONTENT_LENGTH'])); $this->clientError(sprintf($msg, $_SERVER['CONTENT_LENGTH'])); - return; } if (empty($this->user)) { // TRANS: Client error displayed updating profile image without having a user object. - $this->clientError(_('No such user.'), 404, $this->format); - return; + $this->clientError(_('No such user.'), 404); } try { $imagefile = ImageFile::fromUpload('image'); } catch (Exception $e) { - $this->clientError($e->getMessage(), 400, $this->format); - return; + $this->clientError($e->getMessage()); } $type = $imagefile->preferredType(); @@ -125,17 +95,8 @@ class ApiAccountUpdateProfileImageAction extends ApiAuthAction $imagefile->copyTo($filepath); $profile = $this->user->getProfile(); - - if (empty($profile)) { - // TRANS: Client error displayed if a user profile could not be found updating a profile image. - $this->clientError(_('User has no profile.')); - return; - } - $profile->setOriginal($filename); - common_broadcast_profile($profile); - $twitter_user = $this->twitterUserArray($profile, true); if ($this->format == 'xml') {