]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
events for blocking a user
authorEvan Prodromou <evan@status.net>
Mon, 28 Dec 2009 18:42:55 +0000 (10:42 -0800)
committerEvan Prodromou <evan@status.net>
Mon, 28 Dec 2009 18:42:55 +0000 (10:42 -0800)
EVENTS.txt
actions/apiblockcreate.php
actions/block.php

index 96250f64c784dc665d78d1a0fdadf8653c9fe556..42aecfaf90765ff0cd79468806f8466c5ee63473 100644 (file)
@@ -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
index e79dec32d0521ced06d3da89c6a4226ac05e89d0..c26485f591b23196917eb07f3fcc8b65e6ab72d3 100644 (file)
@@ -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);
index 71a34e08793d1bdd0796748fd9c3a4bb5a3528b3..5fae45dffcd46b0140d00e1cb79488abc707a9c1 100644 (file)
@@ -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
         }
     }
 }
-