]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
add events for unblocking a profile
authorEvan Prodromou <evan@status.net>
Mon, 28 Dec 2009 18:50:12 +0000 (10:50 -0800)
committerEvan Prodromou <evan@status.net>
Mon, 28 Dec 2009 18:50:12 +0000 (10:50 -0800)
EVENTS.txt
actions/apiblockdestroy.php
actions/unblock.php

index 42aecfaf90765ff0cd79468806f8466c5ee63473..64e345b6926b1800f12933d17453805a2de7dfcc 100644 (file)
@@ -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
index 328f18ab0dcf1765d688f807160b314ac4ba3dd2..666f308f4c5a3819ce1c83ff35e9fb9620c4b5d2 100644 (file)
@@ -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);
index c60458cd3ca810486714a1ea184e30d06cd51f45..0f63e1dae05802c4308f52e7f644d63fb81cbec1 100644 (file)
@@ -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;