|
| 1 | +# Migrating from WSC 5.4 - WoltLab Suite Forum |
| 2 | + |
| 3 | +## Subscriptions |
| 4 | + |
| 5 | +With WoltLab Suite Forum 5.5 we introduced a new system to subscribe threads and boards including the possibility to ignore threads and boards. |
| 6 | +[You can read more about this feature in our blog](https://www.woltlab.com/article/260-new-features-in-woltlab-suite-5-5-revision-of-buttons-and-ignoring-threads/). |
| 7 | +The new system uses an own system to manage the subscribed forums as well as the subscribed threads. |
| 8 | +This has made the previously used object type `com.woltlab.wcf.user.objectWatch` obsolete, as it no longer meets the requirements we need for the new more flexible system. |
| 9 | +In addition, having our own implementation also makes it much easier to use, as we work with our own tables and we can thus create correct foreign keys. |
| 10 | +Therefore, we had to create a new API to manage subscriptions. |
| 11 | + |
| 12 | +### Subscribe to threads |
| 13 | + |
| 14 | +#### Previously |
| 15 | + |
| 16 | +```php |
| 17 | +$action = new UserObjectWatchAction([], 'subscribe', [ |
| 18 | + 'data' => [ |
| 19 | + 'objectID' => $threadID, |
| 20 | + 'objectType' => 'com.woltlab.wbb.thread', |
| 21 | + ] |
| 22 | +]); |
| 23 | +$action->executeAction(); |
| 24 | +``` |
| 25 | + |
| 26 | +#### Now |
| 27 | +```php |
| 28 | +ThreadStatusHandler::saveSubscriptionStatus( |
| 29 | + $threadID, |
| 30 | + ThreadStatusHandler::SUBSCRIPTION_MODE_WATCHING |
| 31 | +); |
| 32 | +``` |
| 33 | + |
| 34 | +### Filter Ignored Threads |
| 35 | + |
| 36 | +To filter ignored threads from a given `ThreadList`, you can use the method `ThreadStatusHandler::addFilterForIgnoredThreads()` to append the filter for ignored threads. |
| 37 | +The `ViewableThreadList` filters ignored threads by default. |
| 38 | + |
| 39 | +As an example: |
| 40 | + |
| 41 | +```php |
| 42 | +$threadList = new ThreadList(); |
| 43 | +ThreadStatusHandler::addFilterForIgnoredThreads( |
| 44 | + $threadList, |
| 45 | + // This parameter is optional. If null, the current user will be used. Otherwise, the filter is executed |
| 46 | + // for the given user. |
| 47 | + WCF::getUser() |
| 48 | +); |
| 49 | +$threadList->readObjects(); |
| 50 | +``` |
| 51 | + |
| 52 | +### Filter Ignored Users |
| 53 | + |
| 54 | +Ignoring threads should surpress the notifications for the user. |
| 55 | +Therefore we ship also a method, which can filter the `userIDs`, which are ignoring a specific thread. |
| 56 | + |
| 57 | +```php |
| 58 | +$userIDs = [1, 2, 3]; |
| 59 | +$users = ThreadStatusHandler::filterIgnoredUserIDs( |
| 60 | + $userIDs, |
| 61 | + $thread->threadID |
| 62 | +); |
| 63 | +``` |
| 64 | + |
| 65 | +### Subscribe to boards |
| 66 | + |
| 67 | +#### Previously |
| 68 | + |
| 69 | +```php |
| 70 | +$action = new UserObjectWatchAction([], 'subscribe', [ |
| 71 | + 'data' => [ |
| 72 | + 'objectID' => $boardID, |
| 73 | + 'objectType' => 'com.woltlab.wbb.board', |
| 74 | + ] |
| 75 | +]); |
| 76 | +$action->executeAction(); |
| 77 | +``` |
| 78 | + |
| 79 | +#### Now |
| 80 | +```php |
| 81 | +BoardStatusHandler::saveSubscriptionStatus( |
| 82 | + $boardID, |
| 83 | + ThreadStatusHandler::SUBSCRIPTION_MODE_WATCHING |
| 84 | +); |
| 85 | +``` |
| 86 | + |
| 87 | +### Filter Ignored Boards |
| 88 | + |
| 89 | +With the new system, notifications from ignored boards should be surpressed. |
| 90 | +Therefore, we introduced a method, which filters userIDs which ignoring a specific board. |
| 91 | + |
| 92 | +```php |
| 93 | +$userIDs = [1, 2, 3]; |
| 94 | +$users = BoardStatusHandler::filterIgnoredUserIDs( |
| 95 | + $userIDs, |
| 96 | + $board->boardID |
| 97 | +); |
| 98 | +``` |
0 commit comments