Renamed WCF to WSC / Removed obsolete phpdoc tags
[GitHub/WoltLab/com.woltlab.wcf.conversation.git] / files / lib / data / conversation / message / ViewableConversationMessage.class.php
CommitLineData
9544b6b4
MW
1<?php
2namespace wcf\data\conversation\message;
9544b6b4 3use wcf\data\user\UserProfile;
232cdc4b 4use wcf\data\DatabaseObjectDecorator;
30901bc2 5use wcf\data\TLegacyUserPropertyAccess;
95ed3132 6use wcf\system\cache\runtime\UserProfileRuntimeCache;
9544b6b4 7
db864366
MS
8/**
9 * Represents a viewable conversation message.
10 *
11 * @author Marcel Werk
c78f419d 12 * @copyright 2001-2016 WoltLab GmbH
db864366 13 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
c032049e 14 * @package WoltLabSuite\Core\Data\Conversation\Message
c78f419d
MS
15 *
16 * @method ConversationMessage getDecoratedObject()
17 * @mixin ConversationMessage
db864366 18 */
9544b6b4 19class ViewableConversationMessage extends DatabaseObjectDecorator {
30901bc2
MS
20 use TLegacyUserPropertyAccess;
21
9544b6b4 22 /**
c78f419d 23 * @inheritDoc
9544b6b4 24 */
c78f419d 25 protected static $baseClass = ConversationMessage::class;
9544b6b4
MW
26
27 /**
28 * user profile object
c78f419d 29 * @var UserProfile
9544b6b4
MW
30 */
31 protected $userProfile = null;
32
33 /**
34 * Returns the user profile object.
35 *
c78f419d 36 * @return UserProfile
9544b6b4
MW
37 */
38 public function getUserProfile() {
39 if ($this->userProfile === null) {
30901bc2 40 if ($this->userID) {
95ed3132 41 $this->userProfile = UserProfileRuntimeCache::getInstance()->getObject($this->userID);
30901bc2
MS
42 }
43 else {
334be964 44 $this->userProfile = UserProfile::getGuestUserProfile($this->username);
30901bc2 45 }
9544b6b4
MW
46 }
47
48 return $this->userProfile;
49 }
ec14dd18
MS
50
51 /**
52 * Returns the viewable conversation message with the given id.
53 *
54 * @param integer $messageID
c78f419d 55 * @return ViewableConversationMessage
ec14dd18
MS
56 */
57 public static function getViewableConversationMessage($messageID) {
58 $messageList = new ViewableConversationMessageList();
c78f419d 59 $messageList->setObjectIDs([$messageID]);
ec14dd18
MS
60 $messageList->readObjects();
61
62 return $messageList->search($messageID);
63 }
78fd78a7 64}