From: joshuaruesweg Date: Mon, 13 Sep 2021 07:48:24 +0000 (+0200) Subject: Add `getSubscribedUserIDs()` function for article categories X-Git-Tag: 5.5.0_Alpha_1~447^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=fdf7f9b855bfe85bc11c691e77d9757c9bd04921;p=GitHub%2FWoltLab%2FWCF.git Add `getSubscribedUserIDs()` function for article categories --- 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. *