<definitionname>com.woltlab.wcf.moderation.report</definitionname>
<classname>wcf\system\moderation\queue\report\ArticleModerationQueueReportHandler</classname>
</type>
+ <type>
+ <name>com.woltlab.wcf.article.category</name>
+ <definitionname>com.woltlab.wcf.user.objectWatch</definitionname>
+ <classname>wcf\system\user\object\watch\ArticleCategoryUserObjectWatch</classname>
+ </type>
<!-- /articles -->
<type>
{if ARTICLE_ENABLE_VISIT_TRACKING}
<li class="jsOnly"><a href="#" title="{lang}wcf.article.markAllAsRead{/lang}" class="markAllAsReadButton jsTooltip"><span class="icon icon16 fa-check"></span> <span class="invisible">{lang}wcf.article.markAllAsRead{/lang}</span></a></li>
{/if}
+ {if $__wcf->user->userID}
+ <li class="jsOnly"><a href="#" title="{lang}wcf.user.objectWatch.manageSubscription{/lang}" class="jsSubscribeButton jsTooltip" data-object-type="com.woltlab.wcf.article.category" data-object-id="{@$category->categoryID}"><span class="icon icon16 fa-bookmark{if !$category->isSubscribed()}-o{/if}"></span> <span class="invisible">{lang}wcf.user.objectWatch.manageSubscription{/lang}</span></a></li>
+ {/if}
{/capture}
{if $__wcf->getSession()->getPermission('admin.content.article.canManageArticle')}
</script>
{/if}
+<script data-relocate="true">
+ $(function() {
+ WCF.Language.addObject({
+ 'wcf.user.objectWatch.manageSubscription': '{lang}wcf.user.objectWatch.manageSubscription{/lang}'
+ });
+
+ new WCF.User.ObjectWatch.Subscribe();
+ });
+</script>
+
{include file='footer'}
use wcf\system\category\CategoryPermissionHandler;
use wcf\system\label\LabelHandler;
use wcf\system\request\LinkHandler;
+use wcf\system\user\object\watch\UserObjectWatchHandler;
+use wcf\system\user\storage\UserStorageHandler;
use wcf\system\WCF;
/**
*/
protected $userPermissions = [];
+ /**
+ * subscribed categories
+ * @var integer[]
+ */
+ protected static $subscribedCategories;
+
/**
* @inheritDoc
*/
return LabelHandler::getInstance()->getLabelGroups(array_unique($groupIDs));
}
+
+ /**
+ * Returns true if the active user has subscribed to this category.
+ *
+ * @return boolean
+ * @since 3.2
+ */
+ public function isSubscribed() {
+ return in_array($this->categoryID, self::getSubscribedCategoryIDs());
+ }
+
+ /**
+ * Returns the list of subscribed categories.
+ *
+ * @return integer[]
+ * @since 3.2
+ */
+ public static function getSubscribedCategoryIDs() {
+ if (self::$subscribedCategories === null) {
+ self::$subscribedCategories = [];
+
+ if (WCF::getUser()->userID) {
+ $data = UserStorageHandler::getInstance()->getField('articleSubscribedCategories');
+
+ // cache does not exist or is outdated
+ if ($data === null) {
+ $objectTypeID = UserObjectWatchHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.article.category');
+
+ $sql = "SELECT objectID
+ FROM wcf".WCF_N."_user_object_watch
+ WHERE objectTypeID = ?
+ AND userID = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute([$objectTypeID, WCF::getUser()->userID]);
+ self::$subscribedCategories = $statement->fetchAll(\PDO::FETCH_COLUMN);
+
+ // update storage data
+ UserStorageHandler::getInstance()->update(WCF::getUser()->userID, 'articleSubscribedCategories', serialize(self::$subscribedCategories));
+ }
+ else {
+ self::$subscribedCategories = unserialize($data);
+ }
+ }
+ }
+
+ return self::$subscribedCategories;
+ }
}
--- /dev/null
+<?php
+namespace wcf\system\user\object\watch;
+use wcf\data\article\category\ArticleCategory;
+use wcf\data\object\type\AbstractObjectTypeProcessor;
+use wcf\system\user\storage\UserStorageHandler;
+use wcf\system\exception\IllegalLinkException;
+use wcf\system\exception\PermissionDeniedException;
+
+/**
+ * Implementation of IUserObjectWatch for watched article categories.
+ *
+ * @author Joshua Ruesweg
+ * @copyright 2001-2018 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\User\Object\Watch
+ */
+class ArticleCategoryUserObjectWatch extends AbstractObjectTypeProcessor implements IUserObjectWatch {
+ /**
+ * @inheritDoc
+ */
+ public function validateObjectID($objectID) {
+ $category = ArticleCategory::getCategory($objectID);
+ if ($category === null) {
+ throw new IllegalLinkException();
+ }
+ if (!$category->isAccessible()) {
+ throw new PermissionDeniedException();
+ }
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function resetUserStorage(array $userIDs) {
+ UserStorageHandler::getInstance()->reset($userIDs, 'unreadWatchedArticles');
+ UserStorageHandler::getInstance()->reset($userIDs, 'articleSubscribedCategories');
+ }
+}
<category name="wcf.user.objectWatch">
<item name="wcf.user.objectWatch.manageSubscription"><![CDATA[Abonnement verwalten]]></item>
+ <item name="wcf.user.objectWatch.subscribe.com.woltlab.wcf.article.category"><![CDATA[Kategorie abonnieren]]></item>
+ <item name="wcf.user.objectWatch.enableNotification.com.woltlab.wcf.article.category"><![CDATA[Benachrichtigung über neue Artikel aus dieser Kategorie aktivieren]]></item>
+ <item name="wcf.user.objectWatch.unsubscribe.com.woltlab.wcf.article.category"><![CDATA[Kategorie nicht abonnieren]]></item>
</category>
<category name="wcf.user.option">
<category name="wcf.user.objectWatch">
<item name="wcf.user.objectWatch.manageSubscription"><![CDATA[Manage Subscription]]></item>
+ <item name="wcf.user.objectWatch.subscribe.com.woltlab.wcf.article.category"><![CDATA[Watch this category]]></item>
+ <item name="wcf.user.objectWatch.enableNotification.com.woltlab.wcf.article.category"><![CDATA[Notify me of new articles.]]></item>
+ <item name="wcf.user.objectWatch.unsubscribe.com.woltlab.wcf.article.category"><![CDATA[Unwatch this category]]></item>
</category>
<category name="wcf.user.option">