ILIAS  release_8 Revision v8.24
ilForumAuthorInformation Class Reference

ilForumAuthorInformation More...

+ Collaboration diagram for ilForumAuthorInformation:

Public Member Functions

 __construct (int $author_id, int $display_id, string $alias, string $import_name, array $public_profile_link_attributes=[], ?ilLanguage $lng=null)
 
 getProfilePicture ()
 
 getAuthor ()
 
 getAuthorName (bool $without_short_name=false)
 
 getAuthorShortName ()
 
 getLinkedAuthorName ()
 
 getLinkedAuthorShortName ()
 
 hasSuffix ()
 
 getSuffix ()
 
 isDeleted ()
 
 getAlias ()
 

Protected Member Functions

 initUserInstance ()
 
 doesAuthorAccountExists ()
 
 isAuthorAnonymous ()
 
 isCurrentUserSessionLoggedIn ()
 
 buildAuthorProfileLink (bool $with_profile_link)
 
 init ()
 
 getUserImagePath (ilObjUser $user)
 

Private Attributes

int $display_id
 
string $alias
 
string $import_name
 
array $public_profile_link_attributes
 
string $author_name = ''
 
string $author_short_name = ''
 
string $linked_public_name = ''
 
string $linked_short_name = ''
 
string $suffix = ''
 
string $profilePicture
 
ilObjUser $author = null
 
int $author_id
 
ilLanguage $lng = null
 
ilLanguage $globalLng
 
ilObjUser $globalUser
 
bool $is_deleted = false
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilForumAuthorInformation::__construct ( int  $author_id,
int  $display_id,
string  $alias,
string  $import_name,
array  $public_profile_link_attributes = [],
?ilLanguage  $lng = null 
)

Definition at line 46 of file class.ilForumAuthorInformation.php.

53 {
54 global $DIC;
55
56 $this->globalUser = $DIC->user();
57 $this->globalLng = $DIC->language();
58
59 $this->author_id = $author_id;
60 $this->display_id = $display_id;
61 $this->alias = $alias;
62 $this->import_name = $import_name;
63 $this->public_profile_link_attributes = $public_profile_link_attributes;
64 $this->lng = $lng;
65
66 $this->init();
67 }
global $DIC
Definition: feed.php:28

References $alias, $author_id, $DIC, $display_id, $import_name, $lng, $public_profile_link_attributes, init(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

Member Function Documentation

◆ buildAuthorProfileLink()

ilForumAuthorInformation::buildAuthorProfileLink ( bool  $with_profile_link)
protected

Definition at line 103 of file class.ilForumAuthorInformation.php.

103 : void
104 {
105 $link = '';
106
107 if ($with_profile_link && $this->public_profile_link_attributes) {
108 $link = '<a';
109
110 foreach ($this->public_profile_link_attributes as $attr => $value) {
111 $link .= ' ' . $attr . '="' . $value . '"';
112 }
113
114 $link .= '>';
115 }
116
117 $linked_login = $link . $this->author_short_name;
118 $link .= $this->author_name;
119
120 if ($with_profile_link && $this->public_profile_link_attributes) {
121 $link .= '</a>';
122 $linked_login .= '</a>';
123 }
124
125 $this->linked_public_name = $link;
126 $this->linked_short_name = $linked_login;
127 }

References $author_name, and $author_short_name.

Referenced by init().

+ Here is the caller graph for this function:

◆ doesAuthorAccountExists()

ilForumAuthorInformation::doesAuthorAccountExists ( )
protected

Definition at line 88 of file class.ilForumAuthorInformation.php.

88 : bool
89 {
90 return $this->getAuthor() instanceof ilObjUser && $this->getAuthor()->getId();
91 }
User class.

References getAuthor().

Referenced by init(), and isAuthorAnonymous().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAlias()

ilForumAuthorInformation::getAlias ( )

Definition at line 276 of file class.ilForumAuthorInformation.php.

276 : string
277 {
278 return $this->alias;
279 }

References $alias.

◆ getAuthor()

ilForumAuthorInformation::getAuthor ( )

Definition at line 232 of file class.ilForumAuthorInformation.php.

232 : ilObjUser
233 {
234 return $this->author;
235 }

References $author.

Referenced by doesAuthorAccountExists(), init(), and isAuthorAnonymous().

+ Here is the caller graph for this function:

◆ getAuthorName()

ilForumAuthorInformation::getAuthorName ( bool  $without_short_name = false)

Definition at line 237 of file class.ilForumAuthorInformation.php.

237 : string
238 {
239 if (!$without_short_name) {
240 return $this->author_name;
241 }
242
243 return trim(preg_replace('/\‍(' . preg_quote($this->getAuthorShortName(), '/') . '\‍)/', '', $this->author_name));
244 }

References $author_name, and getAuthorShortName().

Referenced by ilForumCronNotificationDataProvider\getPublicUserInformation(), and ilForumNotificationDataProvider\getPublicUserInformation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAuthorShortName()

ilForumAuthorInformation::getAuthorShortName ( )

Definition at line 246 of file class.ilForumAuthorInformation.php.

246 : string
247 {
249 }

References $author_short_name.

Referenced by getAuthorName(), ilForumCronNotificationDataProvider\getPublicUserInformation(), and ilForumNotificationDataProvider\getPublicUserInformation().

+ Here is the caller graph for this function:

◆ getLinkedAuthorName()

ilForumAuthorInformation::getLinkedAuthorName ( )

Definition at line 251 of file class.ilForumAuthorInformation.php.

251 : string
252 {
254 }

References $linked_public_name.

◆ getLinkedAuthorShortName()

ilForumAuthorInformation::getLinkedAuthorShortName ( )

Definition at line 256 of file class.ilForumAuthorInformation.php.

256 : string
257 {
259 }

References $linked_short_name.

◆ getProfilePicture()

ilForumAuthorInformation::getProfilePicture ( )

Definition at line 227 of file class.ilForumAuthorInformation.php.

227 : string
228 {
230 }

References $profilePicture.

◆ getSuffix()

ilForumAuthorInformation::getSuffix ( )

Definition at line 266 of file class.ilForumAuthorInformation.php.

266 : string
267 {
268 return $this->suffix;
269 }

References $suffix.

◆ getUserImagePath()

ilForumAuthorInformation::getUserImagePath ( ilObjUser  $user)
protected

Definition at line 202 of file class.ilForumAuthorInformation.php.

202 : string
203 {
204 if (!ilContext::hasHTML()) {
205 return '';
206 }
207
208 return $user->getPersonalPicturePath('xsmall');
209 }
static hasHTML()
Has HTML output.
getPersonalPicturePath(string $a_size="small", bool $a_force_pic=false)

References ilObjUser\getPersonalPicturePath(), and ilContext\hasHTML().

Referenced by init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasSuffix()

ilForumAuthorInformation::hasSuffix ( )

Definition at line 261 of file class.ilForumAuthorInformation.php.

261 : bool
262 {
263 return $this->suffix !== '';
264 }

Referenced by ilForumCronNotificationDataProvider\getPublicUserInformation(), and ilForumNotificationDataProvider\getPublicUserInformation().

+ Here is the caller graph for this function:

◆ init()

ilForumAuthorInformation::init ( )
protected

Definition at line 129 of file class.ilForumAuthorInformation.php.

129 : void
130 {
131 $translationLanguage = $this->globalLng;
132 if ($this->lng instanceof ilLanguage) {
133 $translationLanguage = $this->lng;
134 }
135
136 $this->initUserInstance();
137
138 if ($this->doesAuthorAccountExists()) {
139 if (!$this->isAuthorAnonymous()
140 && (($this->isCurrentUserSessionLoggedIn()
141 && $this->getAuthor()->getPref('public_profile') === 'y')
142 || $this->getAuthor()->getPref('public_profile') === 'g')
143 ) {
144 // Author is NOT anonymous and (the current user session is logged in and the profile is public (y) or the profile is globally public (g))
145 $this->author_name = $this->getAuthor()->getPublicName();
146 $this->author_short_name = $this->getAuthor()->getLogin();
147
148 if ($this->getAuthor()->getPref('public_upload') === 'y') {
149 $this->profilePicture = $this->getUserImagePath($this->getAuthor());
150 } else {
151 $this->profilePicture = $this->getAvatarImageSource(
153 $this->getAuthor()->getFirstname(),
154 0,
155 1
156 ) . ilStr::subStr($this->getAuthor()->getLastname(), 0, 1),
157 $this->getAuthor()->getId()
158 );
159 }
160
161 if ($this->getAuthor()->getPref('public_gender') !== 'y') {
162 $this->getAuthor()->setGender('');
163 }
164
165 $this->buildAuthorProfileLink(true);
166 } else {
167 $this->getAuthor()->setGender('');
168 $this->author_short_name = $this->author_name = $this->getAuthor()->getLogin();
169 $this->buildAuthorProfileLink(false);
170 $this->profilePicture = $this->getAvatarImageSource(
171 $this->author_short_name,
172 $this->getAuthor()->getId()
173 );
174 }
175 } elseif ($this->display_id > 0 && $this->alias !== '' && $this->doesAuthorAccountExists() === false) {
176 // The author did use a pseudonym and the account does not exist anymore (deleted, lost on import etc.)
177 $this->author_short_name = $this->author_name = $translationLanguage->txt('deleted');
178 $this->is_deleted = true;
179 $this->suffix = $translationLanguage->txt('deleted');
180 $this->buildAuthorProfileLink(false);
181 $this->profilePicture = $this->getAvatarImageSource($this->author_short_name);
182 } elseif ($this->import_name !== '') {
183 // We have no user instance,so we check the import name
184 $this->author_short_name = $this->author_name = $this->import_name . ' (' . $translationLanguage->txt('imported') . ')';
185 $this->suffix = $translationLanguage->txt('imported');
186 $this->buildAuthorProfileLink(false);
187 $this->profilePicture = $this->getAvatarImageSource($this->author_short_name);
188 } elseif ($this->alias !== '') {
189 // We have no import name,so we check the pseudonym
190 $this->author_short_name = $this->author_name = $this->alias . ' (' . $translationLanguage->txt('frm_pseudonym') . ')';
191 $this->suffix = $translationLanguage->txt('frm_pseudonym');
192 $this->buildAuthorProfileLink(false);
193 $this->profilePicture = $this->getAvatarImageSource($this->author_short_name);
194 } else {
195 // If we did not find a pseudonym, the author could not be determined
196 $this->author_short_name = $this->author_name = $translationLanguage->txt('forums_anonymous');
197 $this->buildAuthorProfileLink(false);
198 $this->profilePicture = $this->getAvatarImageSource($this->author_short_name);
199 }
200 }
buildAuthorProfileLink(bool $with_profile_link)
language handling
static subStr(string $a_str, int $a_start, ?int $a_length=null)
Definition: class.ilStr.php:24

References $globalLng, $lng, buildAuthorProfileLink(), doesAuthorAccountExists(), getAuthor(), ILIAS\Survey\Mode\getId(), getUserImagePath(), initUserInstance(), isAuthorAnonymous(), isCurrentUserSessionLoggedIn(), ILIAS\Repository\lng(), and ilStr\subStr().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initUserInstance()

ilForumAuthorInformation::initUserInstance ( )
protected

Definition at line 69 of file class.ilForumAuthorInformation.php.

69 : void
70 {
71 if ($this->display_id > 0) {
72 // Try to read user instance from preloaded cache array
73 $this->author = ilForumAuthorInformationCache::getUserObjectById($this->display_id);
74 if (!$this->author) {
75 // Get a user instance from forum module's cache method
76 $this->author = ilObjForumAccess::getCachedUserInstance($this->display_id);
77 }
78 }
79
80 if (!$this->author instanceof ilObjUser) {
81 $this->author = new ilObjUser();
82 $this->author->setId(0);
83 $this->author->setPref('public_profile', 'n');
84 $this->author->setGender('n');
85 }
86 }
static getCachedUserInstance(int $usr_id)

References ilObjForumAccess\getCachedUserInstance(), and ilForumAuthorInformationCache\getUserObjectById().

Referenced by init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isAuthorAnonymous()

ilForumAuthorInformation::isAuthorAnonymous ( )
protected

Definition at line 93 of file class.ilForumAuthorInformation.php.

93 : bool
94 {
95 return $this->doesAuthorAccountExists() && $this->getAuthor()->isAnonymous();
96 }

References doesAuthorAccountExists(), and getAuthor().

Referenced by init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isCurrentUserSessionLoggedIn()

ilForumAuthorInformation::isCurrentUserSessionLoggedIn ( )
protected

Definition at line 98 of file class.ilForumAuthorInformation.php.

98 : bool
99 {
100 return !$this->globalUser->isAnonymous();
101 }

Referenced by init().

+ Here is the caller graph for this function:

◆ isDeleted()

ilForumAuthorInformation::isDeleted ( )

Definition at line 271 of file class.ilForumAuthorInformation.php.

271 : bool
272 {
273 return $this->is_deleted;
274 }

References $is_deleted.

Field Documentation

◆ $alias

string ilForumAuthorInformation::$alias
private

Definition at line 30 of file class.ilForumAuthorInformation.php.

Referenced by __construct(), and getAlias().

◆ $author

ilObjUser ilForumAuthorInformation::$author = null
private

Definition at line 39 of file class.ilForumAuthorInformation.php.

Referenced by getAuthor().

◆ $author_id

int ilForumAuthorInformation::$author_id
private

Definition at line 40 of file class.ilForumAuthorInformation.php.

Referenced by __construct().

◆ $author_name

string ilForumAuthorInformation::$author_name = ''
private

Definition at line 33 of file class.ilForumAuthorInformation.php.

Referenced by buildAuthorProfileLink(), and getAuthorName().

◆ $author_short_name

string ilForumAuthorInformation::$author_short_name = ''
private

◆ $display_id

int ilForumAuthorInformation::$display_id
private

Definition at line 29 of file class.ilForumAuthorInformation.php.

Referenced by __construct().

◆ $globalLng

ilLanguage ilForumAuthorInformation::$globalLng
private

Definition at line 42 of file class.ilForumAuthorInformation.php.

Referenced by init().

◆ $globalUser

ilObjUser ilForumAuthorInformation::$globalUser
private

Definition at line 43 of file class.ilForumAuthorInformation.php.

◆ $import_name

string ilForumAuthorInformation::$import_name
private

Definition at line 31 of file class.ilForumAuthorInformation.php.

Referenced by __construct().

◆ $is_deleted

bool ilForumAuthorInformation::$is_deleted = false
private

Definition at line 44 of file class.ilForumAuthorInformation.php.

Referenced by isDeleted().

◆ $linked_public_name

string ilForumAuthorInformation::$linked_public_name = ''
private

Definition at line 35 of file class.ilForumAuthorInformation.php.

Referenced by getLinkedAuthorName().

◆ $linked_short_name

string ilForumAuthorInformation::$linked_short_name = ''
private

Definition at line 36 of file class.ilForumAuthorInformation.php.

Referenced by getLinkedAuthorShortName().

◆ $lng

ilLanguage ilForumAuthorInformation::$lng = null
private

Definition at line 41 of file class.ilForumAuthorInformation.php.

Referenced by __construct(), and init().

◆ $profilePicture

string ilForumAuthorInformation::$profilePicture
private

Definition at line 38 of file class.ilForumAuthorInformation.php.

Referenced by getProfilePicture().

◆ $public_profile_link_attributes

array ilForumAuthorInformation::$public_profile_link_attributes
private

Definition at line 32 of file class.ilForumAuthorInformation.php.

Referenced by __construct().

◆ $suffix

string ilForumAuthorInformation::$suffix = ''
private

Definition at line 37 of file class.ilForumAuthorInformation.php.

Referenced by getSuffix().


The documentation for this class was generated from the following file: