ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 ()
 

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
 

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 }
global $DIC
Definition: saml.php:7

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:

◆ getAuthor()

ilForumAuthorInformation::getAuthor ( )
Returns
ilObjUser

Definition at line 311 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 320 of file class.ilForumAuthorInformation.php.

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

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 332 of file class.ilForumAuthorInformation.php.

333 {
335 }

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 340 of file class.ilForumAuthorInformation.php.

References $linked_public_name.

◆ getLinkedAuthorShortName()

ilForumAuthorInformation::getLinkedAuthorShortName ( )
Returns
string

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

References $linked_short_name.

◆ getProfilePicture()

ilForumAuthorInformation::getProfilePicture ( )
Returns
string

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

References $profilePicture.

◆ getSuffix()

ilForumAuthorInformation::getSuffix ( )
Returns
string

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

References $suffix.

◆ getUserImagePath()

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

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

271 {
272 if (!\ilContext::hasHTML()) {
273 return'';
274 }
275
276 return $user->getPersonalPicturePath('xsmall');
277 }
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 356 of file class.ilForumAuthorInformation.php.

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

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

Field Documentation

◆ $alias

ilForumAuthorInformation::$alias
protected

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

Referenced by __construct().

◆ $author

ilForumAuthorInformation::$author
protected

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

Referenced by getAuthor().

◆ $author_id

ilForumAuthorInformation::$author_id
protected

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

Referenced by __construct().

◆ $author_name

ilForumAuthorInformation::$author_name
protected

Definition at line 38 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 18 of file class.ilForumAuthorInformation.php.

Referenced by __construct().

◆ $files

ilForumAuthorInformation::$files = array()
protected

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

◆ $globalLng

ilForumAuthorInformation::$globalLng
protected

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

Referenced by init().

◆ $globalUser

ilForumAuthorInformation::$globalUser
protected

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

◆ $import_name

ilForumAuthorInformation::$import_name
protected

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

Referenced by __construct().

◆ $linked_public_name

ilForumAuthorInformation::$linked_public_name
protected

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

Referenced by getLinkedAuthorName().

◆ $linked_short_name

ilForumAuthorInformation::$linked_short_name
protected

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

Referenced by getLinkedAuthorShortName().

◆ $lng

ilForumAuthorInformation::$lng
protected

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

Referenced by __construct(), and init().

◆ $profilePicture

ilForumAuthorInformation::$profilePicture
protected

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

Referenced by getProfilePicture().

◆ $public_profile_link_attributes

ilForumAuthorInformation::$public_profile_link_attributes = array()
protected

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

Referenced by __construct().

◆ $suffix

ilForumAuthorInformation::$suffix = ''
protected

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

Referenced by getSuffix().


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