e74541247b349eed00ef49279a13f1581cc960b5
[GitHub/WoltLab/com.woltlab.wcf.conversation.git] / files / lib / data / modification / log / ViewableConversationModificationLog.class.php
1 <?php
2
3 namespace wcf\data\modification\log;
4
5 use wcf\data\DatabaseObjectDecorator;
6 use wcf\data\TLegacyUserPropertyAccess;
7 use wcf\data\user\UserProfile;
8 use wcf\system\cache\runtime\UserProfileRuntimeCache;
9 use wcf\system\WCF;
10
11 /**
12 * Provides a viewable conversation modification log.
13 *
14 * @author Alexander Ebert
15 * @copyright 2001-2019 WoltLab GmbH
16 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
17 * @package WoltLabSuite\Core\Data\Modification\Log
18 *
19 * @method ModificationLog getDecoratedObject()
20 * @mixin ModificationLog
21 */
22 class ViewableConversationModificationLog extends DatabaseObjectDecorator
23 {
24 use TLegacyUserPropertyAccess;
25
26 /**
27 * @inheritDoc
28 */
29 protected static $baseClass = ModificationLog::class;
30
31 /**
32 * user profile object
33 * @var UserProfile
34 */
35 protected $userProfile;
36
37 /**
38 * Returns readable representation of current log entry.
39 *
40 * @return string
41 */
42 public function __toString()
43 {
44 return WCF::getLanguage()->getDynamicVariable(
45 'wcf.conversation.log.conversation.' . $this->action,
46 ['additionalData' => $this->additionalData]
47 );
48 }
49
50 /**
51 * Returns the profile object of the user who created the modification entry.
52 *
53 * @return UserProfile
54 */
55 public function getUserProfile()
56 {
57 if ($this->userProfile === null) {
58 if ($this->userID) {
59 $this->userProfile = UserProfileRuntimeCache::getInstance()->getObject($this->userID);
60 } else {
61 $this->userProfile = UserProfile::getGuestUserProfile($this->username);
62 }
63 }
64
65 return $this->userProfile;
66 }
67 }