|
| 1 | +# Migrating from WSC 5.4 - WoltLab Suite Forum |
| 2 | + |
| 3 | +## Subscriptions |
| 4 | + |
| 5 | +With WoltLab Suite Forum 5.5 we have introduced a new system for subscribing to threads and boards, which also offers the possibility to ignore threads and boards. |
| 6 | +[You can learn 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 a separate mechanism to track the subscribed forums as well as the subscribed threads. |
| 8 | +The previously used object type `com.woltlab.wcf.user.objectWatch` is now discontinued, because the object watch system turned out to be too limited for the complex logic behind thread and forum subscriptions. |
| 9 | + |
| 10 | +### Subscribe to Threads |
| 11 | + |
| 12 | +Previously: |
| 13 | + |
| 14 | +```php |
| 15 | +$action = new UserObjectWatchAction([], 'subscribe', [ |
| 16 | + 'data' => [ |
| 17 | + 'objectID' => $threadID, |
| 18 | + 'objectType' => 'com.woltlab.wbb.thread', |
| 19 | + ] |
| 20 | +]); |
| 21 | +$action->executeAction(); |
| 22 | +``` |
| 23 | + |
| 24 | +Now: |
| 25 | + |
| 26 | +```php |
| 27 | +ThreadStatusHandler::saveSubscriptionStatus( |
| 28 | + $threadID, |
| 29 | + ThreadStatusHandler::SUBSCRIPTION_MODE_WATCHING |
| 30 | +); |
| 31 | +``` |
| 32 | + |
| 33 | +### Filter Ignored Threads |
| 34 | + |
| 35 | +To filter ignored threads from a given `ThreadList`, you can use the method `ThreadStatusHandler::addFilterForIgnoredThreads()` to append the filter for ignored threads. |
| 36 | +The `ViewableThreadList` filters out ignored threads by default. |
| 37 | + |
| 38 | +Example: |
| 39 | + |
| 40 | +```php |
| 41 | +$user = new User(123); |
| 42 | +$threadList = new ThreadList(); |
| 43 | +ThreadStatusHandler::addFilterForIgnoredThreads( |
| 44 | + $threadList, |
| 45 | + // This parameter specifies the target user. Defaults to the current user if the parameter |
| 46 | + // is omitted or `null`. |
| 47 | + $user |
| 48 | +); |
| 49 | +$threadList->readObjects(); |
| 50 | +``` |
| 51 | + |
| 52 | +### Filter Ignored Users |
| 53 | + |
| 54 | +Avoid issuing notifications to users that have ignored the target thread by filtering those out. |
| 55 | + |
| 56 | +```php |
| 57 | +$userIDs = [1, 2, 3]; |
| 58 | +$users = ThreadStatusHandler::filterIgnoredUserIDs( |
| 59 | + $userIDs, |
| 60 | + $thread->threadID |
| 61 | +); |
| 62 | +``` |
| 63 | + |
| 64 | +### Subscribe to Boards |
| 65 | + |
| 66 | +Previously: |
| 67 | + |
| 68 | +```php |
| 69 | +$action = new UserObjectWatchAction([], 'subscribe', [ |
| 70 | + 'data' => [ |
| 71 | + 'objectID' => $boardID, |
| 72 | + 'objectType' => 'com.woltlab.wbb.board', |
| 73 | + ] |
| 74 | +]); |
| 75 | +$action->executeAction(); |
| 76 | +``` |
| 77 | + |
| 78 | +Now: |
| 79 | + |
| 80 | +```php |
| 81 | +BoardStatusHandler::saveSubscriptionStatus( |
| 82 | + $boardID, |
| 83 | + ThreadStatusHandler::SUBSCRIPTION_MODE_WATCHING |
| 84 | +); |
| 85 | +``` |
| 86 | + |
| 87 | +### Filter Ignored Boards |
| 88 | + |
| 89 | +Similar to ignored threads you will also have to avoid issuing notifications for boards that a user has ignored. |
| 90 | + |
| 91 | +```php |
| 92 | +$userIDs = [1, 2, 3]; |
| 93 | +$users = BoardStatusHandler::filterIgnoredUserIDs( |
| 94 | + $userIDs, |
| 95 | + $board->boardID |
| 96 | +); |
| 97 | +``` |
0 commit comments