123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- class ApiBlockCreateAction extends ApiAuthAction
- {
- protected $needPost = true;
- var $other = null;
-
- protected function prepare(array $args=array())
- {
- parent::prepare($args);
- $this->other = $this->getTargetProfile($this->arg('id'));
- return true;
- }
-
- protected function handle()
- {
- parent::handle();
- if (empty($this->user) || empty($this->other)) {
-
- $this->clientError(_('No such user.'), 404);
- }
-
- if ($this->user->id == $this->other->id) {
-
- $this->clientError(_("You cannot block yourself!"), 403);
- }
- if (!$this->user->hasBlocked($this->other)) {
- if (Event::handle('StartBlockProfile', array($this->user, $this->other))) {
- $result = $this->user->block($this->other);
- if ($result) {
- Event::handle('EndBlockProfile', array($this->user, $this->other));
- }
- }
- }
- if ($this->user->hasBlocked($this->other)) {
- $this->initDocument($this->format);
- $this->showProfile($this->other, $this->format);
- $this->endDocument($this->format);
- } else {
-
- $this->serverError(_('Block user failed.'), 500);
- }
- }
- }
|