X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapiaccountupdateprofile.php;h=60fed1e3c58215a6fd1ee98640615b4984d128e4;hb=b3bf036975593db27c6e7e653f18160d086f7b2d;hp=aea10e33e3fb1a72fba08392af7d6f2f0b791996;hpb=bfdb8385ecc745002b8c45510caf2fdf7c2d2c9f;p=quix0rs-gnu-social.git diff --git a/actions/apiaccountupdateprofile.php b/actions/apiaccountupdateprofile.php index aea10e33e3..60fed1e3c5 100644 --- a/actions/apiaccountupdateprofile.php +++ b/actions/apiaccountupdateprofile.php @@ -31,8 +31,6 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR . '/lib/apiauth.php'; - /** * API analog to the profile settings page * Only the parameters specified will be updated. @@ -45,15 +43,16 @@ require_once INSTALLDIR . '/lib/apiauth.php'; */ class ApiAccountUpdateProfileAction extends ApiAuthAction { + protected $needPost = true; + /** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag - * */ - function prepare($args) + protected function prepare(array $args=array()) { parent::prepare($args); @@ -72,44 +71,27 @@ class ApiAccountUpdateProfileAction extends ApiAuthAction * * See which request params have been set, and update the profile * - * @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(); if (!in_array($this->format, array('xml', 'json'))) { - $this->clientError( - _('API method not found.'), - 404, - $this->format - ); - return; + // TRANS: Client error displayed when coming across a non-supported API method. + $this->clientError(_('API method not found.'), 404); } if (empty($this->user)) { // TRANS: Client error displayed if a user could not be found. - $this->clientError(_('No such user.'), 404, $this->format); - return; + $this->clientError(_('No such user.'), 404); } $profile = $this->user->getProfile(); if (empty($profile)) { - // TRANS: Client error displayed if a user profile could not be found. + // TRANS: Error message displayed when referring to a user without a profile. $this->clientError(_('User has no profile.')); - return; } $original = clone($profile); @@ -145,16 +127,13 @@ class ApiAccountUpdateProfileAction extends ApiAuthAction common_log_db_error($profile, 'UPDATE', __FILE__); // TRANS: Server error displayed if a user profile could not be saved. $this->serverError(_('Could not save profile.')); - return; } - common_broadcast_profile($profile); - $twitter_user = $this->twitterUserArray($profile, true); if ($this->format == 'xml') { $this->initDocument('xml'); - $this->showTwitterXmlUser($twitter_user); + $this->showTwitterXmlUser($twitter_user, 'user', true); $this->endDocument('xml'); } elseif ($this->format == 'json') { $this->initDocument('json');