X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapiblockcreate.php;h=d73c24c38f041ddbafccae92addede0839728c7a;hb=a6e299a2fc83d7b4d0e82082f7622279f5d78aba;hp=6942a53bb875444864e95d345635d56575f7acf6;hpb=59a0b2a82da418f688faf182407146d9e7a7af7a;p=quix0rs-gnu-social.git diff --git a/actions/apiblockcreate.php b/actions/apiblockcreate.php index 6942a53bb8..d73c24c38f 100644 --- a/actions/apiblockcreate.php +++ b/actions/apiblockcreate.php @@ -32,8 +32,6 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR . '/lib/apiauth.php'; - /** * Blocks the user specified in the ID parameter as the authenticating user. * Destroys a friendship to the blocked user if it exists. Returns the @@ -48,6 +46,8 @@ require_once INSTALLDIR . '/lib/apiauth.php'; */ class ApiBlockCreateAction extends ApiAuthAction { + protected $needPost = true; + var $other = null; /** @@ -58,11 +58,10 @@ class ApiBlockCreateAction extends ApiAuthAction * @return boolean success flag * */ - function prepare($args) + protected function prepare(array $args=array()) { parent::prepare($args); - $this->user = $this->auth_user; $this->other = $this->getTargetProfile($this->arg('id')); return true; @@ -77,36 +76,20 @@ class ApiBlockCreateAction extends ApiAuthAction * * @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 (empty($this->user) || empty($this->other)) { - // TRANS: Client error displayed when trying to block a non-existing user or a user from another site. - $this->clientError(_('No such user.'), 404, $this->format); - return; + // TRANS: Client error displayed when trying to block a non-existing user or a user from another site. + $this->clientError(_('No such user.'), 404); } // Don't allow blocking yourself! if ($this->user->id == $this->other->id) { - $this->clientError( - // TRANS: Client error displayed when users try to block themselves. - _("You cannot block yourself!"), - 403, - $this->format - ); - return; + // TRANS: Client error displayed when users try to block themselves. + $this->clientError(_("You cannot block yourself!"), 403); } if (!$this->user->hasBlocked($this->other)) { @@ -124,7 +107,7 @@ class ApiBlockCreateAction extends ApiAuthAction $this->endDocument($this->format); } else { // TRANS: Server error displayed when blocking a user has failed. - $this->serverError(_('Block user failed.'), 500, $this->format); + $this->serverError(_('Block user failed.'), 500); } } }