- if (empty($this->user) || empty($this->other)) {
- $this->clientError(_('No such user!'), 404, $this->format);
- return;
+ // Don't allow blocking yourself!
+
+ if ($this->user->id == $this->other->id) {
+ // TRANS: Client error displayed when users try to block themselves.
+ $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));
+ }
+ }