Add `getSubscribedUserIDs()` function for article categories
authorjoshuaruesweg <ruesweg@woltlab.com>
Mon, 13 Sep 2021 07:48:24 +0000 (09:48 +0200)
committerjoshuaruesweg <ruesweg@woltlab.com>
Mon, 13 Sep 2021 07:48:24 +0000 (09:48 +0200)
wcfsetup/install/files/lib/data/article/category/ArticleCategory.class.php

index 44015523edbdd9391613288bff60582e23e440a0..fee8d6160e3dbb1a778e32e35dbcffe7543ac4ae 100644 (file)
@@ -196,6 +196,25 @@ class ArticleCategory extends AbstractDecoratedCategory implements IAccessibleOb
         return [];
     }
 
+    /**
+     * Returns all userIDs which have subscribed this category.
+     *
+     * @return  int[]
+     * @since   5.5
+     */
+    public function getSubscribedUserIDs(): array
+    {
+        $objectTypeID = UserObjectWatchHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.article.category');
+        $sql = "SELECT  userID
+                FROM    wcf" . WCF_N . "_user_object_watch
+                WHERE   objectTypeID = ?
+                    AND objectID = ?";
+        $statement = WCF::getDB()->prepareStatement($sql);
+        $statement->execute([$objectTypeID, $this->categoryID]);
+
+        return $statement->fetchAll(\PDO::FETCH_COLUMN);
+    }
+
     /**
      * Returns true if the active user has subscribed to this category.
      *