ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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)
 
 getAnonymousImagePath ()
 

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.

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

104  {
105  global $ilUser, $lng;
106 
107  $this->globalUser = $ilUser;
108  $this->globalLng = $lng;
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  }
$ilUser
Definition: imgupload.php:18
+ 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 172 of file class.ilForumAuthorInformation.php.

References $author_name, and $author_short_name.

Referenced by init().

173  {
174  $link = '';
175 
176  if($with_profile_link && $this->public_profile_link_attributes)
177  {
178  $link = '<a';
179 
180  foreach($this->public_profile_link_attributes as $attr => $value)
181  {
182  $link .= ' ' . $attr . '="' . $value . '"';
183  }
184 
185  $link .= '>';
186  }
187 
188  $linked_login = $link . $this->author_short_name;
189  $link .= $this->author_name;
190 
191  if($with_profile_link && $this->public_profile_link_attributes)
192  {
193  $link .= '</a>';
194  $linked_login .= '</a>';
195  }
196 
197  $this->linked_public_name = $link;
198  $this->linked_short_name = $linked_login;
199  }
+ Here is the caller graph for this function:

◆ doesAuthorAccountExists()

ilForumAuthorInformation::doesAuthorAccountExists ( )
protected
Returns
bool

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

References getAuthor().

Referenced by init(), and isAuthorAnonymous().

149  {
150  return $this->getAuthor() instanceof ilObjUser && $this->getAuthor()->getId();
151  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAnonymousImagePath()

ilForumAuthorInformation::getAnonymousImagePath ( )
protected
Returns
string

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

References ilUtil\getImagePath(), and ilContext\hasHTML().

Referenced by init().

302  {
303  if (!ilContext::hasHTML()) {
304  return'';
305  }
306 
307  return ilUtil::getImagePath('no_photo_xsmall.jpg');
308  }
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static hasHTML()
Has HTML output.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAuthor()

ilForumAuthorInformation::getAuthor ( )
Returns
ilObjUser

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

References $author_name, and getAuthorShortName().

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

331  {
332  if(!$without_short_name)
333  {
334  return $this->author_name;
335  }
336  else
337  {
338  return trim(preg_replace('/\(' . $this->getAuthorShortName() . '\)/', '', $this->author_name));
339  }
340  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAuthorShortName()

ilForumAuthorInformation::getAuthorShortName ( )

◆ getLinkedAuthorName()

ilForumAuthorInformation::getLinkedAuthorName ( )
Returns
string

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

References $linked_public_name.

◆ getLinkedAuthorShortName()

ilForumAuthorInformation::getLinkedAuthorShortName ( )
Returns
string

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

References $linked_short_name.

◆ getProfilePicture()

ilForumAuthorInformation::getProfilePicture ( )
Returns
string

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

References $profilePicture.

◆ getSuffix()

ilForumAuthorInformation::getSuffix ( )
Returns
string

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

References $suffix.

◆ getUserImagePath()

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

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

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

Referenced by init().

290  {
291  if (!ilContext::hasHTML()) {
292  return'';
293  }
294 
295  return $user->getPersonalPicturePath('xsmall');
296  }
static hasHTML()
Has HTML output.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasSuffix()

ilForumAuthorInformation::hasSuffix ( )
Returns
bool

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

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

370  {
371  return strlen($this->suffix);
372  }
+ Here is the caller graph for this function:

◆ init()

ilForumAuthorInformation::init ( )
protected

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

References $globalLng, $lng, buildAuthorProfileLink(), doesAuthorAccountExists(), getAnonymousImagePath(), getAuthor(), getUserImagePath(), initUserInstance(), isAuthorAnonymous(), and isCurrentUserSessionLoggedIn().

Referenced by __construct().

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

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

Referenced by init().

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

References doesAuthorAccountExists(), and getAuthor().

Referenced by init().

157  {
158  return $this->doesAuthorAccountExists() && $this->getAuthor()->isAnonymous();
159  }
+ 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 164 of file class.ilForumAuthorInformation.php.

Referenced by init().

165  {
166  return !$this->globalUser->isAnonymous();
167  }
+ 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: