Commit | Line | Data |
---|---|---|
8b467fcd MW |
1 | <?php |
2 | namespace wcf\system\user\notification\object\type; | |
750f3d00 | 3 | use wcf\data\conversation\Conversation; |
f586b354 MS |
4 | use wcf\data\conversation\ConversationList; |
5 | use wcf\system\user\notification\object\ConversationUserNotificationObject; | |
750f3d00 | 6 | use wcf\system\WCF; |
8b467fcd MW |
7 | |
8 | /** | |
9 | * Represents a conversation notification object type. | |
db864366 | 10 | * |
8b467fcd | 11 | * @author Marcel Werk |
a2df5242 | 12 | * @copyright 2001-2016 WoltLab GmbH |
8b467fcd | 13 | * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> |
c032049e | 14 | * @package WoltLabSuite\Core\System\User\Notification\Object\Type |
8b467fcd | 15 | */ |
546d4f1f | 16 | class ConversationNotificationObjectType extends AbstractUserNotificationObjectType { |
8b467fcd | 17 | /** |
9c3943b0 | 18 | * @inheritDoc |
8b467fcd | 19 | */ |
f586b354 | 20 | protected static $decoratorClassName = ConversationUserNotificationObject::class; |
db864366 | 21 | |
8b467fcd | 22 | /** |
9c3943b0 | 23 | * @inheritDoc |
8b467fcd | 24 | */ |
f586b354 | 25 | protected static $objectClassName = Conversation::class; |
546d4f1f MW |
26 | |
27 | /** | |
9c3943b0 | 28 | * @inheritDoc |
546d4f1f | 29 | */ |
f586b354 | 30 | protected static $objectListClassName = ConversationList::class; |
750f3d00 | 31 | |
be03f342 | 32 | /** @noinspection PhpMissingParentCallCommonInspection */ |
750f3d00 | 33 | /** |
9c3943b0 | 34 | * @inheritDoc |
750f3d00 MW |
35 | */ |
36 | public function getObjectsByIDs(array $objectIDs) { | |
37 | $objects = Conversation::getUserConversations($objectIDs, WCF::getUser()->userID); | |
38 | ||
39 | foreach ($objects as $objectID => $conversation) { | |
40 | $objects[$objectID] = new static::$decoratorClassName($conversation); | |
41 | } | |
42 | ||
43 | foreach ($objectIDs as $objectID) { | |
44 | // append empty objects for unknown ids | |
45 | if (!isset($objects[$objectID])) { | |
46 | // '__unknownNotificationObject' tells the notification API | |
47 | // that the object does not exist anymore so that the related | |
48 | // notification can be deleted automatically | |
eaf1c8eb | 49 | $objects[$objectID] = new static::$decoratorClassName(new static::$objectClassName(null, [ |
750f3d00 MW |
50 | '__unknownNotificationObject' => true, |
51 | 'conversationID' => $objectID | |
eaf1c8eb | 52 | ])); |
750f3d00 MW |
53 | } |
54 | } | |
249da2b9 | 55 | |
750f3d00 MW |
56 | return $objects; |
57 | } | |
8b467fcd | 58 | } |