summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--EVENTS.txt8
-rw-r--r--actions/apiblockdestroy.php13
-rw-r--r--actions/unblock.php13
3 files changed, 29 insertions, 5 deletions
diff --git a/EVENTS.txt b/EVENTS.txt
index 42aecfaf9..64e345b69 100644
--- a/EVENTS.txt
+++ b/EVENTS.txt
@@ -647,3 +647,11 @@ StartBlockProfile: when we're about to block
EndBlockProfile: when a block has succeeded
- $user: the person doing the block
- $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
diff --git a/actions/apiblockdestroy.php b/actions/apiblockdestroy.php
index 328f18ab0..666f308f4 100644
--- a/actions/apiblockdestroy.php
+++ b/actions/apiblockdestroy.php
@@ -97,9 +97,16 @@ class ApiBlockDestroyAction extends ApiAuthAction
return;
}
- if (!$this->user->hasBlocked($this->other)
- || $this->user->unblock($this->other)
- ) {
+ if ($this->user->hasBlocked($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->showProfile($this->other, $this->format);
$this->endDocument($this->format);
diff --git a/actions/unblock.php b/actions/unblock.php
index c60458cd3..0f63e1dae 100644
--- a/actions/unblock.php
+++ b/actions/unblock.php
@@ -71,8 +71,17 @@ class UnblockAction extends ProfileFormAction
function handlePost()
{
- $cur = common_current_user();
- $result = $cur->unblock($this->profile);
+ $cur = common_current_user();
+
+ $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) {
$this->serverError(_('Error removing the block.'));
return;