From fdf7f9b855bfe85bc11c691e77d9757c9bd04921 Mon Sep 17 00:00:00 2001 From: joshuaruesweg Date: Mon, 13 Sep 2021 09:48:24 +0200 Subject: [PATCH] Add `getSubscribedUserIDs()` function for article categories --- .../category/ArticleCategory.class.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/wcfsetup/install/files/lib/data/article/category/ArticleCategory.class.php b/wcfsetup/install/files/lib/data/article/category/ArticleCategory.class.php index 44015523ed..fee8d6160e 100644 --- a/wcfsetup/install/files/lib/data/article/category/ArticleCategory.class.php +++ b/wcfsetup/install/files/lib/data/article/category/ArticleCategory.class.php @@ -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. * -- 2.20.1