19 declare(strict_types=1);
41 private readonly
int $author_id,
42 private readonly
int $display_id,
43 private readonly
string $alias,
44 private readonly
string $import_name,
45 private readonly array $public_profile_link_attributes = [],
50 $this->globalUser = $DIC->user();
51 $this->globalLng = $DIC->language();
58 if ($this->display_id > 0) {
61 if (!$this->author instanceof
ilObjUser) {
67 if (!$this->author instanceof
ilObjUser) {
68 $this->author =
new ilObjUser();
69 $this->author->setId(0);
70 $this->author->setPref(
'public_profile',
'n');
71 $this->author->setGender(
'n');
87 return !$this->globalUser->isAnonymous();
94 if ($with_profile_link && $this->public_profile_link_attributes) {
97 foreach ($this->public_profile_link_attributes as $attr => $value) {
98 $link .=
' ' . $attr .
'="' . $value .
'"';
107 if ($with_profile_link && $this->public_profile_link_attributes) {
109 $linked_login .=
'</a>';
112 $this->linked_public_name = $link;
113 $this->linked_short_name = $linked_login;
116 protected function init(): void
128 && $this->
getAuthor()->getPref(
'public_profile') ===
'y')
129 || $this->
getAuthor()->getPref(
'public_profile') ===
'g')
132 $this->author_name = $this->
getAuthor()->getPublicName();
133 $this->author_short_name = $this->
getAuthor()->getLogin();
135 if ($this->
getAuthor()->getPref(
'public_upload') ===
'y') {
138 $this->profilePicture = $this->getAvatarImageSource(
148 if ($this->
getAuthor()->getPref(
'public_gender') !==
'y') {
155 $this->author_short_name = $this->author_name = $this->
getAuthor()->getLogin();
157 $this->profilePicture = $this->getAvatarImageSource(
158 $this->author_short_name,
162 } elseif ($this->display_id > 0 && $this->alias !==
'') {
164 $this->author_short_name = $this->author_name = $translationLanguage->txt(
'deleted');
165 $this->is_deleted =
true;
166 $this->suffix = $translationLanguage->txt(
'deleted');
168 $this->profilePicture = $this->getAvatarImageSource($this->author_short_name);
169 } elseif ($this->import_name !==
'') {
171 $this->author_short_name = $this->author_name = $this->import_name .
' (' . $translationLanguage->txt(
'imported') .
')';
172 $this->suffix = $translationLanguage->txt(
'imported');
174 $this->profilePicture = $this->getAvatarImageSource($this->author_short_name);
175 } elseif ($this->alias !==
'') {
177 $this->author_short_name = $this->author_name = $this->alias .
' (' . $translationLanguage->txt(
'frm_pseudonym') .
')';
178 $this->suffix = $translationLanguage->txt(
'frm_pseudonym');
180 $this->profilePicture = $this->getAvatarImageSource($this->author_short_name);
183 $this->author_short_name = $this->author_name = $translationLanguage->txt(
'forums_anonymous');
185 $this->profilePicture = $this->getAvatarImageSource($this->author_short_name);
198 protected function getAvatarImageSource(
string $name,
int $usrId =
ANONYMOUS_USER_ID):
string 207 $avatar = $DIC[
"user.avatar.factory"]->avatar(
'xsmall');
208 $avatar->setUsrId($usrId);
211 return $avatar->getUrl();
226 if (!$without_short_name) {
230 return trim(preg_replace(
'/\(' . preg_quote($this->
getAuthorShortName(),
'/') .
'\)/',
'', $this->author_name));
250 return $this->suffix !==
'';
getPersonalPicturePath(string $a_size='small', bool $a_force_pic=false)
static subStr(string $a_str, int $a_start, ?int $a_length=null)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static hasHTML()
Has HTML output.
static getCachedUserInstance(int $usr_id)