ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilForumAuthorInformation Class Reference

ilForumAuthorInformation More...

+ Collaboration diagram for ilForumAuthorInformation:

Public Member Functions

 __construct ($author_id, $display_id, $alias, $import_name, array $public_profile_link_attributes=array(), \ilLanguage $lng=null)
 
 getProfilePicture ()
 
 getAuthor ()
 
 getAuthorName ($without_short_name=false)
 
 getAuthorShortName ()
 
 getLinkedAuthorName ()
 
 getLinkedAuthorShortName ()
 
 hasSuffix ()
 
 getSuffix ()
 
 isDeleted ()
 
 getAlias ()
 

Protected Member Functions

 initUserInstance ()
 
 doesAuthorAccountExists ()
 
 isAuthorAnonymous ()
 
 isCurrentUserSessionLoggedIn ()
 
 buildAuthorProfileLink ($with_profile_link=false)
 
 init ()
 
 getUserImagePath (\ilObjUser $user)
 

Protected Attributes

 $display_id
 
 $alias
 
 $import_name
 
 $public_profile_link_attributes = array()
 
 $author_name
 
 $author_short_name
 
 $linked_public_name
 
 $linked_short_name
 
 $suffix = ''
 
 $profilePicture
 
 $author
 
 $files = array()
 
 $author_id
 
 $lng
 
 $globalLng
 
 $globalUser
 
 $is_deleted = false
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilForumAuthorInformation::__construct (   $author_id,
  $display_id,
  $alias,
  $import_name,
array  $public_profile_link_attributes = array(),
\ilLanguage  $lng = null 
)
Parameters
int$author_id
int$display_id
string$alias
string$import_name
array$public_profile_link_attributes
\ilLanguage | null$lng

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

104 {
105 global $DIC;
106
107 $this->globalUser = $DIC->user();
108 $this->globalLng = $DIC->language();
109
110 $this->author_id = $author_id;
111 $this->display_id = $display_id;
112 $this->alias = $alias;
113 $this->import_name = $import_name;
114 $this->public_profile_link_attributes = $public_profile_link_attributes;
115 $this->lng = $lng;
116
117 $this->init();
118 }
$DIC
Definition: xapitoken.php:46

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

+ Here is the call graph for this function:

Member Function Documentation

◆ buildAuthorProfileLink()

ilForumAuthorInformation::buildAuthorProfileLink (   $with_profile_link = false)
protected
Parameters
bool$with_profile_link

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

170 {
171 $link = '';
172
173 if ($with_profile_link && $this->public_profile_link_attributes) {
174 $link = '<a';
175
176 foreach ($this->public_profile_link_attributes as $attr => $value) {
177 $link .= ' ' . $attr . '="' . $value . '"';
178 }
179
180 $link .= '>';
181 }
182
183 $linked_login = $link . $this->author_short_name;
184 $link .= $this->author_name;
185
186 if ($with_profile_link && $this->public_profile_link_attributes) {
187 $link .= '</a>';
188 $linked_login .= '</a>';
189 }
190
191 $this->linked_public_name = $link;
192 $this->linked_short_name = $linked_login;
193 }

References $author_name, and $author_short_name.

Referenced by init().

+ Here is the caller graph for this function:

◆ doesAuthorAccountExists()

ilForumAuthorInformation::doesAuthorAccountExists ( )
protected
Returns
bool

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

146 {
147 return $this->getAuthor() instanceof ilObjUser && $this->getAuthor()->getId();
148 }

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 ( )
Returns
string

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

380 {
381 return $this->alias;
382 }

References $alias.

◆ getAuthor()

ilForumAuthorInformation::getAuthor ( )
Returns
ilObjUser

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

References $author.

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

+ Here is the caller graph for this function:

◆ getAuthorName()

ilForumAuthorInformation::getAuthorName (   $without_short_name = false)
Parameters
bool$without_short_name
Returns
string

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

320 {
321 if (!$without_short_name) {
322 return $this->author_name;
323 } else {
324 return trim(preg_replace('/\‍(' . preg_quote($this->getAuthorShortName()) . '\‍)/', '', $this->author_name));
325 }
326 }

References $author_name, and getAuthorShortName().

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

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

◆ getAuthorShortName()

ilForumAuthorInformation::getAuthorShortName ( )
Returns
string

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

332 {
334 }

References $author_short_name.

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

+ Here is the caller graph for this function:

◆ getLinkedAuthorName()

ilForumAuthorInformation::getLinkedAuthorName ( )
Returns
string

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

References $linked_public_name.

◆ getLinkedAuthorShortName()

ilForumAuthorInformation::getLinkedAuthorShortName ( )
Returns
string

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

References $linked_short_name.

◆ getProfilePicture()

ilForumAuthorInformation::getProfilePicture ( )
Returns
string

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

References $profilePicture.

◆ getSuffix()

ilForumAuthorInformation::getSuffix ( )
Returns
string

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

References $suffix.

◆ getUserImagePath()

ilForumAuthorInformation::getUserImagePath ( \ilObjUser  $user)
protected
Parameters
ilObjUser$user
Returns
string

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

270 {
271 if (!\ilContext::hasHTML()) {
272 return'';
273 }
274
275 return $user->getPersonalPicturePath('xsmall');
276 }
static hasHTML()
Has HTML output.

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 ( )
Returns
bool

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

356 {
357 return strlen($this->suffix);
358 }

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

+ Here is the caller graph for this function:

◆ init()

ilForumAuthorInformation::init ( )
protected

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

199 {
200 $translationLanguage = $this->globalLng;
201 if ($this->lng instanceof \ilLanguage) {
202 $translationLanguage = $this->lng;
203 }
204
205 $this->initUserInstance();
206
207 if ($this->doesAuthorAccountExists()) {
208 if (!$this->isAuthorAnonymous()
209 && (($this->isCurrentUserSessionLoggedIn()
210 && $this->getAuthor()->getPref('public_profile') == 'y')
211 || $this->getAuthor()->getPref('public_profile') == 'g')
212 ) {
213 // 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))
214 $this->author_name = $this->getAuthor()->getPublicName();
215 $this->author_short_name = $this->getAuthor()->getLogin();
216
217 if ($this->getAuthor()->getPref('public_upload') == 'y') {
218 $this->profilePicture = $this->getUserImagePath($this->getAuthor());
219 } else {
220 $this->profilePicture = $this->getAvatarImageSource(
221 ilStr::subStr($this->getAuthor()->getFirstname(), 0, 1) . ilStr::subStr($this->getAuthor()->getLastname(), 0, 1),
222 $this->getAuthor()->getId()
223 );
224 }
225
226 if ($this->getAuthor()->getPref('public_gender') != 'y') {
227 $this->getAuthor()->setGender('');
228 }
229
230 $this->buildAuthorProfileLink(true);
231 } else {
232 $this->getAuthor()->setGender('');
233 $this->author_short_name = $this->author_name = $this->getAuthor()->getLogin();
234 $this->buildAuthorProfileLink(false);
235 $this->profilePicture = $this->getAvatarImageSource($this->author_short_name, $this->getAuthor()->getId());
236 }
237 } elseif ($this->display_id > 0 && !$this->doesAuthorAccountExists() && strlen($this->alias)) {
238 // The author does not use a pseudonym, but the id does not exist anymore (deleted, lost on import etc.)
239 // We have no import name,so we check the pseudonym
240 $this->author_short_name = $this->author_name = $translationLanguage->txt('deleted');
241 $this->is_deleted = true;
242 $this->suffix = $translationLanguage->txt('deleted');
243 $this->buildAuthorProfileLink(false);
244 $this->profilePicture = $this->getAvatarImageSource($this->author_short_name);
245 } elseif (strlen($this->import_name)) {
246 // We have no user instance,so we check the import name
247 $this->author_short_name = $this->author_name = $this->import_name . ' (' . $translationLanguage->txt('imported') . ')';
248 $this->suffix = $translationLanguage->txt('imported');
249 $this->buildAuthorProfileLink(false);
250 $this->profilePicture = $this->getAvatarImageSource($this->author_short_name);
251 } elseif (strlen($this->alias)) {
252 // We have no import name,so we check the pseudonym
253 $this->author_short_name = $this->author_name = $this->alias . ' (' . $translationLanguage->txt('frm_pseudonym') . ')';
254 $this->suffix = $translationLanguage->txt('frm_pseudonym');
255 $this->buildAuthorProfileLink(false);
256 $this->profilePicture = $this->getAvatarImageSource($this->author_short_name);
257 } else {
258 // If we did not find a pseudonym, the author could not be determined
259 $this->author_short_name = $this->author_name = $translationLanguage->txt('forums_anonymous');
260 $this->buildAuthorProfileLink(false);
261 $this->profilePicture = $this->getAvatarImageSource($this->author_short_name);
262 }
263 }
buildAuthorProfileLink($with_profile_link=false)
language handling
static subStr($a_str, $a_start, $a_length=null)
Definition: class.ilStr.php:15

References $globalLng, $lng, buildAuthorProfileLink(), doesAuthorAccountExists(), getAuthor(), getUserImagePath(), initUserInstance(), isAuthorAnonymous(), isCurrentUserSessionLoggedIn(), 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 123 of file class.ilForumAuthorInformation.php.

124 {
125 if (is_numeric($this->display_id) && $this->display_id > 0) {
126 // Try to read user instance from preloaded cache array
127 $this->author = ilForumAuthorInformationCache::getUserObjectById($this->display_id);
128 if (!$this->author) {
129 // Get a user instance from forum module's cache method
130 $this->author = ilObjForumAccess::getCachedUserInstance($this->display_id);
131 }
132 }
133
134 if (!$this->author) {
135 $this->author = new ilObjUser();
136 $this->author->setId(0);
137 $this->author->setPref('public_profile', 'n');
138 $this->author->setGender('');
139 }
140 }
static getCachedUserInstance($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
Returns
bool

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

154 {
155 return $this->doesAuthorAccountExists() && $this->getAuthor()->isAnonymous();
156 }

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
Returns
bool

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

162 {
163 return !$this->globalUser->isAnonymous();
164 }

Referenced by init().

+ Here is the caller graph for this function:

◆ isDeleted()

ilForumAuthorInformation::isDeleted ( )
Returns
bool

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

References $is_deleted.

Field Documentation

◆ $alias

ilForumAuthorInformation::$alias
protected

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

Referenced by __construct(), and getAlias().

◆ $author

ilForumAuthorInformation::$author
protected

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

Referenced by getAuthor().

◆ $author_id

ilForumAuthorInformation::$author_id
protected

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

Referenced by __construct().

◆ $author_name

ilForumAuthorInformation::$author_name
protected

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

Referenced by buildAuthorProfileLink(), and getAuthorName().

◆ $author_short_name

ilForumAuthorInformation::$author_short_name
protected

◆ $display_id

ilForumAuthorInformation::$display_id
protected

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

Referenced by __construct().

◆ $files

ilForumAuthorInformation::$files = array()
protected

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

◆ $globalLng

ilForumAuthorInformation::$globalLng
protected

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

Referenced by init().

◆ $globalUser

ilForumAuthorInformation::$globalUser
protected

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

◆ $import_name

ilForumAuthorInformation::$import_name
protected

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

Referenced by __construct().

◆ $is_deleted

ilForumAuthorInformation::$is_deleted = false
protected

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

Referenced by isDeleted().

◆ $linked_public_name

ilForumAuthorInformation::$linked_public_name
protected

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

Referenced by getLinkedAuthorName().

◆ $linked_short_name

ilForumAuthorInformation::$linked_short_name
protected

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

Referenced by getLinkedAuthorShortName().

◆ $lng

ilForumAuthorInformation::$lng
protected

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

Referenced by __construct(), and init().

◆ $profilePicture

ilForumAuthorInformation::$profilePicture
protected

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

Referenced by getProfilePicture().

◆ $public_profile_link_attributes

ilForumAuthorInformation::$public_profile_link_attributes = array()
protected

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

Referenced by __construct().

◆ $suffix

ilForumAuthorInformation::$suffix = ''
protected

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

Referenced by getSuffix().


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