add events for unblocking a profile
This commit is contained in:
parent
c5de326231
commit
2ae04bb6d5
|
@ -647,3 +647,11 @@ StartBlockProfile: when we're about to block
|
||||||
EndBlockProfile: when a block has succeeded
|
EndBlockProfile: when a block has succeeded
|
||||||
- $user: the person doing the block
|
- $user: the person doing the block
|
||||||
- $profile: the person blocked, can be remote
|
- $profile: the person blocked, can be remote
|
||||||
|
|
||||||
|
StartUnblockProfile: when we're about to unblock
|
||||||
|
- $user: the person doing the unblock
|
||||||
|
- $profile: the person getting unblocked, can be remote
|
||||||
|
|
||||||
|
EndUnblockProfile: when an unblock has succeeded
|
||||||
|
- $user: the person doing the unblock
|
||||||
|
- $profile: the person unblocked, can be remote
|
||||||
|
|
|
@ -97,9 +97,16 @@ class ApiBlockDestroyAction extends ApiAuthAction
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->user->hasBlocked($this->other)
|
if ($this->user->hasBlocked($this->other)) {
|
||||||
|| $this->user->unblock($this->other)
|
if (Event::handle('StartUnblockProfile', array($this->user, $this->other))) {
|
||||||
) {
|
$result = $this->user->unblock($this->other);
|
||||||
|
if ($result) {
|
||||||
|
Event::handle('EndUnblockProfile', 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);
|
||||||
|
|
|
@ -71,8 +71,17 @@ class UnblockAction extends ProfileFormAction
|
||||||
|
|
||||||
function handlePost()
|
function handlePost()
|
||||||
{
|
{
|
||||||
$cur = common_current_user();
|
$cur = common_current_user();
|
||||||
$result = $cur->unblock($this->profile);
|
|
||||||
|
$result = false;
|
||||||
|
|
||||||
|
if (Event::handle('StartUnblockProfile', array($cur, $this->profile))) {
|
||||||
|
$result = $cur->unblock($this->profile);
|
||||||
|
if ($result) {
|
||||||
|
Event::handle('EndUnblockProfile', array($cur, $this->profile));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
$this->serverError(_('Error removing the block.'));
|
$this->serverError(_('Error removing the block.'));
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user