summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2009-12-28 10:42:55 -0800
committerEvan Prodromou <evan@status.net>2009-12-28 10:42:55 -0800
commitc5de3262312f814bc44e596d9031c2df22420e27 (patch)
tree1fac8a2904c0a9a40b5b1e66de1110d589782ee0
parentc07f22104094d26f7f6266c2b59f7999030fda1a (diff)
events for blocking a user
-rw-r--r--EVENTS.txt7
-rw-r--r--actions/apiblockcreate.php13
-rw-r--r--actions/block.php8
3 files changed, 23 insertions, 5 deletions
diff --git a/EVENTS.txt b/EVENTS.txt
index 96250f64c..42aecfaf9 100644
--- a/EVENTS.txt
+++ b/EVENTS.txt
@@ -640,3 +640,10 @@ EndLog: After writing to the logs
- $msg
- $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
diff --git a/actions/apiblockcreate.php b/actions/apiblockcreate.php
index e79dec32d..c26485f59 100644
--- a/actions/apiblockcreate.php
+++ b/actions/apiblockcreate.php
@@ -109,9 +109,16 @@ class ApiBlockCreateAction extends ApiAuthAction
return;
}
- if ($this->user->hasBlocked($this->other)
- || $this->user->block($this->other)
- ) {
+ 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);
diff --git a/actions/block.php b/actions/block.php
index 71a34e087..5fae45dff 100644
--- a/actions/block.php
+++ b/actions/block.php
@@ -156,7 +156,12 @@ class BlockAction extends ProfileFormAction
{
$cur = common_current_user();
- $result = $cur->block($this->profile);
+ if (Event::handle('StartBlockProfile', array($cur, $this->profile))) {
+ $result = $cur->block($this->profile);
+ if ($result) {
+ Event::handle('EndBlockProfile', array($cur, $this->profile));
+ }
+ }
if (!$result) {
$this->serverError(_('Failed to save block information.'));
@@ -164,4 +169,3 @@ class BlockAction extends ProfileFormAction
}
}
}
-