Remove the `$type` parameter from the `IgnoredBy` methods in UserProfile
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 18 Mar 2021 13:22:16 +0000 (14:22 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 22 Apr 2021 10:03:46 +0000 (12:03 +0200)
The type of ignore is not relevant when checking whether one is ignored by
another user. In fact it might leak information that the ignoror might not want
to share with the ignoree.

com.woltlab.wcf/templates/userInformationButtons.tpl
wcfsetup/install/files/lib/data/user/UserProfile.class.php

index 41558108a6539563778c70494720e6ca9fa93217..63bdbfd20585c61f6365d0b022d5e1d47a3a9819 100644 (file)
@@ -13,7 +13,7 @@
                                {/if}
                                
                                {if $__wcf->user->userID && $user->userID != $__wcf->user->userID}
-                                       {if !$__wcf->getUserProfileHandler()->isIgnoredByUser($user->userID, 1)}
+                                       {if !$__wcf->getUserProfileHandler()->isIgnoredByUser($user->userID)}
                                                {if $__wcf->getUserProfileHandler()->isFollowing($user->userID)}
                                                        <li class="jsOnly"><a href="#" data-following="1" data-object-id="{@$user->userID}" class="jsFollowButton jsTooltip" title="{lang}wcf.user.button.unfollow{/lang}"><span class="icon icon16 fa-minus"></span> <span class="invisible">{lang}wcf.user.button.unfollow{/lang}</span></a></li>
                                                {else}
index 05dbacd9975c48cc77671ab18b61ac6ec8e34eb1..95db5a1b49c0dfd9d22efcc9387c7172a8c5ef45 100644 (file)
@@ -257,10 +257,9 @@ class UserProfile extends DatabaseObjectDecorator implements ITitledLinkObject
     /**
      * Returns a list of user ids that are ignoring this user.
      *
-     * @param  ?int  $type One of the UserIgnore::TYPE_* constants.
      * @return  int[]
      */
-    public function getIgnoredByUsers(?int $type = null)
+    public function getIgnoredByUsers()
     {
         if ($this->ignoredByUserIDs === null) {
             $this->ignoredByUserIDs = [];
@@ -290,17 +289,7 @@ class UserProfile extends DatabaseObjectDecorator implements ITitledLinkObject
             }
         }
 
-        return \array_keys(\array_filter($this->ignoredByUserIDs, static function ($userType) use ($type) {
-            if ($type === null) {
-                return true;
-            } elseif ($type === UserIgnore::TYPE_BLOCK_DIRECT_CONTACT) {
-                return \in_array($userType, [UserIgnore::TYPE_BLOCK_DIRECT_CONTACT, UserIgnore::TYPE_HIDE_MESSAGES]);
-            } elseif ($type === UserIgnore::TYPE_HIDE_MESSAGES) {
-                return $userType === UserIgnore::TYPE_HIDE_MESSAGES;
-            } else {
-                return false;
-            }
-        }));
+        return \array_keys($this->ignoredByUserIDs);
     }
 
     /**
@@ -341,12 +330,11 @@ class UserProfile extends DatabaseObjectDecorator implements ITitledLinkObject
      * Returns true if the given user ignores the current user.
      *
      * @param int $userID
-     * @param  ?int  $type One of the UserIgnore::TYPE_* constants.
      * @return  bool
      */
-    public function isIgnoredByUser($userID, ?int $type = null)
+    public function isIgnoredByUser($userID)
     {
-        return \in_array($userID, $this->getIgnoredByUsers($type));
+        return \in_array($userID, $this->getIgnoredByUsers());
     }
 
     /**