]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/UserFlag/UserFlagPlugin.php
optionally flag a profile for review when blocked
[quix0rs-gnu-social.git] / plugins / UserFlag / UserFlagPlugin.php
index 21af506a99960a79230dbd76159ef9afd1ee066b..0fca5f9cf90c22111773e667fe5e1654bb5f63c4 100644 (file)
@@ -46,6 +46,8 @@ class UserFlagPlugin extends Plugin
     const REVIEWFLAGS = 'UserFlagPlugin::reviewflags';
     const CLEARFLAGS  = 'UserFlagPlugin::clearflags';
 
+    public $flagOnBlock = true;
+
     /**
      * Hook for ensuring our tables are created
      *
@@ -235,4 +237,23 @@ class UserFlagPlugin extends Plugin
 
         return true; // unchanged!
     }
+
+    /**
+     * Optionally flag profile when a block happens
+     *
+     * We optionally add a flag when a profile has been blocked
+     *
+     * @param User    $user    User doing the block
+     * @param Profile $profile Profile being blocked
+     *
+     * @return boolean hook result
+     */
+
+    function onEndBlockProfile($user, $profile)
+    {
+        if ($this->flagOnBlock) {
+            User_flag_profile::create($user->id, $profile->id);
+        }
+        return true;
+    }
 }