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