events for blocking a user

This commit is contained in:
Evan Prodromou 2009-12-28 10:42:55 -08:00
parent c07f221040
commit c5de326231
3 changed files with 23 additions and 5 deletions

View File

@ -640,3 +640,10 @@ EndLog: After writing to the logs
- $msg - $msg
- $filename - $filename
StartBlockProfile: when we're about to block
- $user: the person doing the block
- $profile: the person getting blocked, can be remote
EndBlockProfile: when a block has succeeded
- $user: the person doing the block
- $profile: the person blocked, can be remote

View File

@ -109,9 +109,16 @@ class ApiBlockCreateAction extends ApiAuthAction
return; return;
} }
if ($this->user->hasBlocked($this->other) if (!$this->user->hasBlocked($this->other)) {
|| $this->user->block($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->initDocument($this->format);
$this->showProfile($this->other, $this->format); $this->showProfile($this->other, $this->format);
$this->endDocument($this->format); $this->endDocument($this->format);

View File

@ -156,7 +156,12 @@ class BlockAction extends ProfileFormAction
{ {
$cur = common_current_user(); $cur = common_current_user();
if (Event::handle('StartBlockProfile', array($cur, $this->profile))) {
$result = $cur->block($this->profile); $result = $cur->block($this->profile);
if ($result) {
Event::handle('EndBlockProfile', array($cur, $this->profile));
}
}
if (!$result) { if (!$result) {
$this->serverError(_('Failed to save block information.')); $this->serverError(_('Failed to save block information.'));
@ -164,4 +169,3 @@ class BlockAction extends ProfileFormAction
} }
} }
} }