]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/silence.php
New domain regexp for WebFinger matching.
[quix0rs-gnu-social.git] / actions / silence.php
index c44aa3a6d788a1764cd33a9ac1d3730f0c93ee29..dccaf70a37521ae57db85472761d93d5c5bb1b8f 100644 (file)
@@ -27,9 +27,7 @@
  * @link      http://status.net/
  */
 
-if (!defined('STATUSNET')) {
-    exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 /**
  * Silence a user.
@@ -42,47 +40,11 @@ if (!defined('STATUSNET')) {
  */
 class SilenceAction extends ProfileFormAction
 {
-    /**
-     * Check parameters
-     *
-     * @param array $args action arguments (URL, GET, POST)
-     *
-     * @return boolean success flag
-     */
-    function prepare($args)
-    {
-        if (!parent::prepare($args)) {
-            return false;
-        }
-
-        $cur = common_current_user();
-
-        assert(!empty($cur)); // checked by parent
-
-        if (!$cur->hasRight(Right::SILENCEUSER)) {
-            // TRANS: Client error displayed trying to silence a user on a site where the feature is not enabled.
-            $this->clientError(_('You cannot silence users on this site.'));
-            return false;
-        }
-
-        assert(!empty($this->profile)); // checked by parent
-
-        if ($this->profile->isSilenced()) {
-            // TRANS: Client error displayed trying to silence an already silenced user.
-            $this->clientError(_('User is already silenced.'));
-            return false;
-        }
-
-        return true;
-    }
-
-    /**
-     * Silence a user.
-     *
-     * @return void
-     */
     function handlePost()
     {
-        $this->profile->silence();
+        assert($this->scoped instanceof Profile);
+        assert($this->profile instanceof Profile);
+
+        $this->profile->silenceAs($this->scoped);
     }
 }