ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilPublicUserProfileGUI Class Reference

GUI class for public user profile presentation. More...

+ Inheritance diagram for ilPublicUserProfileGUI:
+ Collaboration diagram for ilPublicUserProfileGUI:

Public Member Functions

 setUserId (int $a_userid)
 
 getUserId ()
 
 setAdditional (array $a_additional)
 Set Additonal Information. More...
 
 getAdditional ()
 
 setBackUrl (string $backurl)
 Set Back Link URL. More...
 
 getBackUrl ()
 
 setCustomPrefs (array $a_prefs)
 Set custom preferences for public profile fields. More...
 
 setEmbedded (bool $a_value, bool $a_offline=false)
 
 executeCommand ()
 
 view ()
 View. More...
 
 getHTML ()
 
 getEmbeddable (bool $a_add_goto=false)
 get public profile html code Used in Personal Profile (as preview) and Portfolio (as page block) More...
 
 deliverVCard ()
 Deliver vcard information. More...
 
 renderTitle ()
 

Static Public Member Functions

static getAutocompleteResult (string $a_field_id, string $a_term)
 

Protected Member Functions

 getPublicPref (ilObjUser $a_user, string $a_id)
 Get user preference for public profile. More...
 
 isProfilePublic ()
 
 validateUser (int $usrId)
 Check if given user id is valid. More...
 
 getProfilePortfolio ()
 Check if current profile portfolio is accessible. More...
 
 doProfileAutoComplete ()
 
 approveContactRequest ()
 
 ignoreContactRequest ()
 

Private Attributes

bool $offline = false
 
ilUserDefinedFields $user_defined_fields
 
GUIRequest $profile_request
 
int $userid = 0
 
string $backurl = ''
 
array $additional = []
 
bool $embedded = false
 
array $custom_prefs = []
 
ilObjUser $current_user
 
ilSetting $setting
 
ilCtrl $ctrl
 
ilTabsGUI $tabs
 
ilGlobalTemplateInterface $tpl
 
ilRbacSystem $rbac_system
 
Language $lng
 
PublicUserProfileBadgesRenderer $badges_renderer
 

Detailed Description

GUI class for public user profile presentation.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de ilPublicUserProfileGUI: ilObjPortfolioGUI

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

Member Function Documentation

◆ approveContactRequest()

ilPublicUserProfileGUI::approveContactRequest ( )
protected

Definition at line 797 of file class.ilPublicUserProfileGUI.php.

References ILIAS\Repository\ctrl(), and getUserId().

797  : void
798  {
799  $osd_id = $this->profile_request->getOsdId();
800  if ($osd_id) {
801  $this->ctrl->setParameterByClass('ilBuddySystemGUI', 'osd_id', $osd_id);
802  }
803  $this->ctrl->setParameterByClass('ilBuddySystemGUI', 'user_id', $this->getUserId());
804  $this->ctrl->redirectByClass(['ilPublicUserProfileGUI', 'ilBuddySystemGUI'], 'link');
805  }
+ Here is the call graph for this function:

◆ deliverVCard()

ilPublicUserProfileGUI::deliverVCard ( )

Deliver vcard information.

Definition at line 593 of file class.ilPublicUserProfileGUI.php.

References ilObject\_exists(), ilUtil\deliverData(), getUserId(), and null.

593  : void
594  {
595  // get user object
596  if (!ilObject::_exists($this->getUserId())) {
597  return;
598  }
599  $user = new ilObjUser($this->getUserId());
600 
601  $vcard = new VCard();
602 
603  // ilsharedresourceGUI: embedded in shared portfolio
604  if ($user->getPref('public_profile') != 'y' &&
605  $user->getPref('public_profile') != 'g' &&
606  strtolower($this->profile_request->getBaseClass()) != 'ilsharedresourcegui' &&
607  $this->current_user->getId() != $this->getUserId()
608  ) {
609  return;
610  }
611 
612  $vcard->setName($user->getLastname(), $user->getFirstname(), '', $user->getUTitle());
613  $vcard->setNickname($user->getLogin());
614 
615  list($image, $type) = (new ilUserAvatarResolver($this->getUserId()))->getUserPictureForVCard();
616  if ($image !== null) {
617  $vcard->setPhoto($image, $type);
618  }
619 
620  $val_arr = [
621  'getOrgUnitsRepresentation' => 'org_units', 'getInstitution' => 'institution',
622  'getDepartment' => 'department', 'getStreet' => 'street',
623  'getZipcode' => 'zipcode', 'getCity' => 'city', 'getCountry' => 'country',
624  'getPhoneOffice' => 'phone_office', 'getPhoneHome' => 'phone_home',
625  'getPhoneMobile' => 'phone_mobile', 'getFax' => 'fax', 'getEmail' => 'email',
626  'getHobby' => 'hobby', 'getMatriculation' => 'matriculation',
627  'getClientIP' => 'client_ip', 'dummy' => 'location'
628  ];
629 
630  $org = [];
631  $adr = [];
632  foreach ($val_arr as $key => $value) {
633  // if value 'y' show information
634  if ($user->getPref('public_' . $value) == 'y') {
635  switch ($value) {
636  case 'institution':
637  $org[0] = $user->$key();
638  break;
639  case 'department':
640  $org[1] = $user->$key();
641  break;
642  case 'street':
643  $adr[2] = $user->$key();
644  break;
645  case 'zipcode':
646  $adr[5] = $user->$key();
647  break;
648  case 'city':
649  $adr[3] = $user->$key();
650  break;
651  case 'country':
652  $adr[6] = $user->$key();
653  break;
654  case 'phone_office':
655  $vcard->setPhone($user->$key(), VCard::TEL_TYPE_WORK);
656  break;
657  case 'phone_home':
658  $vcard->setPhone($user->$key(), VCard::TEL_TYPE_HOME);
659  break;
660  case 'phone_mobile':
661  $vcard->setPhone($user->$key(), VCard::TEL_TYPE_CELL);
662  break;
663  case 'fax':
664  $vcard->setPhone($user->$key(), VCard::TEL_TYPE_FAX);
665  break;
666  case 'email':
667  $vcard->setEmail($user->$key());
668  break;
669  case 'hobby':
670  $vcard->setNote($user->$key());
671  break;
672  case 'location':
673  $vcard->setPosition($user->getLatitude(), $user->getLongitude());
674  break;
675  }
676  }
677  }
678 
679  if (count($org)) {
680  $vcard->setOrganization(implode(';', $org));
681  }
682  if (count($adr)) {
683  $vcard->setAddress(
684  $adr[0] ?? '',
685  $adr[1] ?? '',
686  $adr[2] ?? '',
687  $adr[3] ?? '',
688  $adr[4] ?? '',
689  $adr[5] ?? '',
690  $adr[6] ?? ''
691  );
692  }
693 
694  ilUtil::deliverData($vcard->buildVCard(), $vcard->getFilename(), $vcard->getMimetype());
695  }
static deliverData(string $a_data, string $a_filename, string $mime="application/octet-stream")
RFC 2426 vCard MIME Directory Profile 3.0 class.
Definition: VCard.php:27
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
Class ilUserAvatarResolver.
+ Here is the call graph for this function:

◆ doProfileAutoComplete()

ilPublicUserProfileGUI::doProfileAutoComplete ( )
protected

Definition at line 786 of file class.ilPublicUserProfileGUI.php.

References exit.

786  : void
787  {
788  $field_id = $this->profile_request->getFieldId();
789  $term = $this->profile_request->getTerm();
790 
791  $result = self::getAutocompleteResult($field_id, $term);
792 
793  echo json_encode($result, JSON_THROW_ON_ERROR);
794  exit();
795  }
exit

◆ executeCommand()

ilPublicUserProfileGUI::executeCommand ( )

Definition at line 155 of file class.ilPublicUserProfileGUI.php.

References ILIAS\Repository\ctrl(), getAdditional(), getProfilePortfolio(), getUserId(), and validateUser().

155  : string
156  {
157  $ret = '';
158  if (!$this->validateUser($this->getUserId())) {
159  return '';
160  }
161  $next_class = $this->ctrl->getNextClass($this);
162  $cmd = $this->ctrl->getCmd();
163 
164  $this->tpl->loadStandardTemplate();
165 
166  switch ($next_class) {
167  case 'ilbuddysystemgui':
168  $gui = new ilBuddySystemGUI();
169  $this->ctrl->setReturn($this, 'view');
170  $this->ctrl->forwardCommand($gui);
171  break;
172  case 'ilobjportfoliogui':
173  $portfolio_id = $this->getProfilePortfolio();
174  if ($portfolio_id
175  && $cmd !== 'deliverVCard') {
176  $gui = new ilObjPortfolioGUI($portfolio_id); // #11876
177  $gui->setAdditional($this->getAdditional());
178  $gui->setPermaLink($this->getUserId(), 'usr');
179  $this->ctrl->forwardCommand($gui);
180  break;
181  }
182  // no break
183  default:
184  $ret = $this->$cmd();
185  $this->tpl->setContent($ret);
186  break;
187  }
188 
189  // only for direct links
190  if (strtolower($this->profile_request->getBaseClass()) == 'ilpublicuserprofilegui') {
191  $this->tpl->printToStdout();
192  }
193  return (string) $ret;
194  }
Class ilBuddySystemGUI.
getProfilePortfolio()
Check if current profile portfolio is accessible.
ilObjPortfolioGUI: ilPortfolioPageGUI, ilPageObjectGUI ilObjPortfolioGUI: ilWorkspaceAccessGUI, ilCommentGUI, ilCommonActionDispatcherGUI ilObjPortfolioGUI: ilObjectContentStyleSettingsGUI, ilPortfolioExerciseGUI ilObjPortfolioGUI: ILIAS
validateUser(int $usrId)
Check if given user id is valid.
+ Here is the call graph for this function:

◆ getAdditional()

ilPublicUserProfileGUI::getAdditional ( )

Definition at line 104 of file class.ilPublicUserProfileGUI.php.

References $additional.

Referenced by executeCommand(), and getEmbeddable().

104  : array
105  {
106  return $this->additional;
107  }
+ Here is the caller graph for this function:

◆ getAutocompleteResult()

static ilPublicUserProfileGUI::getAutocompleteResult ( string  $a_field_id,
string  $a_term 
)
static

Definition at line 750 of file class.ilPublicUserProfileGUI.php.

References $DIC, $user_id, ANONYMOUS_USER_ID, ilObjUser\findInterests(), and null.

Referenced by ilAccountRegistrationGUI\doProfileAutoComplete().

753  : array {
754  global $DIC;
755 
756  $ilUser = $DIC['ilUser'];
757  $result = [];
758 
759  $multi_fields = [
760  'interests_general',
761  'interests_help_offered',
762  'interests_help_looking'
763  ];
764  if (in_array($a_field_id, $multi_fields) && $a_term) {
765  // registration has no current user
766  $user_id = null;
767  if ($ilUser && $ilUser->getId() && $ilUser->getId() != ANONYMOUS_USER_ID) {
768  $user_id = $ilUser->getId();
769  }
770 
771  $result = [];
772  $cnt = 0;
773 
774  // term is searched in ALL interest fields, no distinction
775  foreach (ilObjUser::findInterests($a_term, $ilUser->getId()) as $item) {
776  $result[$cnt] = new stdClass();
777  $result[$cnt]->value = $item;
778  $result[$cnt]->label = $item;
779  $cnt++;
780  }
781  }
782 
783  return $result;
784  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:26
static findInterests(string $a_term, ?int $a_user_id=null, ?string $a_field_id=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBackUrl()

ilPublicUserProfileGUI::getBackUrl ( )

Definition at line 124 of file class.ilPublicUserProfileGUI.php.

References $backurl.

Referenced by getEmbeddable().

124  : string
125  {
126  return $this->backurl;
127  }
+ Here is the caller graph for this function:

◆ getEmbeddable()

ilPublicUserProfileGUI::getEmbeddable ( bool  $a_add_goto = false)

get public profile html code Used in Personal Profile (as preview) and Portfolio (as page block)

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

References $_SERVER, $tpl, ilObject\_exists(), ilUserDefinedFields\_getInstance(), ilObjUser\_getPersonalPicturePath(), ilLink\_getStaticLink(), ilObjUser\_isAnonymous(), ANONYMOUS_USER_ID, ILIAS\Repository\ctrl(), ilDatePresentation\formatDate(), ILIAS\UICore\GlobalTemplate\get(), getAdditional(), ilObjPortfolio\getAvailablePortfolioLinksForUserIds(), getBackUrl(), ilBuddySystemLinkButton\getInstanceByUserId(), ilMailFormCall\getLinkTarget(), ilMailGlobalServices\getMailObjectRefId(), ilMapUtil\getMapGUI(), ilUserUtil\getNamePresentation(), getPublicPref(), getUserId(), IL_CAL_DATE, ilMapUtil\isActivated(), isProfilePublic(), ILIAS\Repository\lng(), ILIAS\UICore\GlobalTemplate\parseCurrentBlock(), ILIAS\UICore\GlobalTemplate\setCurrentBlock(), ILIAS\UICore\GlobalTemplate\setPermanentLink(), and ILIAS\UICore\GlobalTemplate\setVariable().

Referenced by getHTML().

261  : string
262  {
263  $h = $v = '';
264 
265  // get user object
266  if (!ilObject::_exists($this->getUserId())) {
267  return '';
268  }
269  $user = new ilObjUser($this->getUserId());
270 
271  $tpl = new ilTemplate(
272  'tpl.usr_public_profile.html',
273  true,
274  true,
275  'components/ILIAS/User'
276  );
277 
278 
279  $tpl->setVariable('ROWCOL1', 'tblrow1');
280  $tpl->setVariable('ROWCOL2', 'tblrow2');
281 
282  if (!$this->offline && $this->current_user->getId() != ANONYMOUS_USER_ID) {
283  $ref_url = str_replace('&', '&', $this->getBackUrl());
284  if (!$ref_url) {
285  $ref_url = basename($_SERVER['REQUEST_URI']);
286  }
287 
288  $mail_url = '';
289  if ($this->rbac_system->checkAccess('internal_mail', ilMailGlobalServices::getMailObjectRefId())) {
290  $mail_url = ilMailFormCall::getLinkTarget(
291  $ref_url,
292  '',
293  [],
294  [
295  'type' => 'new',
296  'rcp_to' => $user->getLogin()
297  ]
298  );
299  } elseif ($user->getPref('public_profile') === 'g' ||
300  (!$this->current_user->isAnonymous() && $user->getPref('public_profile') === 'y') &&
301  $user->getPref('public_email') &&
302  $user->getEmail() !== '') {
303  $mail_url = 'mailto:' . $user->getEmail();
304  }
305 
306  if ($mail_url !== '') {
307  $tpl->setCurrentBlock('mail');
308  $tpl->setVariable('TXT_MAIL', $this->lng->txt('send_mail'));
309  $tpl->setVariable('HREF_MAIL', $mail_url);
311  }
312  }
313 
314 
315  // short version, fixes e.g. #27242
316  if (!$this->isProfilePublic()) {
317  $tpl->setVariable('TXT_NAME', $this->lng->txt('name'));
318  $tpl->setVariable('FIRSTNAME', ilUserUtil::getNamePresentation($user->getId()));
319  return $tpl->get();
320  }
321 
322  $first_name = '';
323  if ($this->getPublicPref($user, 'public_title') == 'y') {
324  $first_name .= $user->getUTitle() . ' ';
325  }
326  $first_name .= $user->getFirstname();
327 
328  if ($this->getPublicPref($user, 'public_gender') == 'y' && in_array($user->getGender(), ['m', 'f'])) {
329  $sal = $this->lng->txt('salutation_' . $user->getGender()) . ' ';
330  $tpl->setVariable('SALUTATION', $sal);
331  }
332 
333  $tpl->setVariable('TXT_NAME', $this->lng->txt('name'));
334  $tpl->setVariable('FIRSTNAME', $first_name);
335  $tpl->setVariable('LASTNAME', $user->getLastname());
336 
337  if ($user->getBirthday() &&
338  $this->getPublicPref($user, 'public_birthday') == 'y') {
339  // #17574
340  $tpl->setCurrentBlock('bday_bl');
341  $tpl->setVariable('TXT_BIRTHDAY', $this->lng->txt('birthday'));
342  $tpl->setVariable('VAL_BIRTHDAY', ilDatePresentation::formatDate(new ilDate($user->getBirthday(), IL_CAL_DATE)));
344  }
345 
346  if (!$this->offline) {
347  // vcard
348  $tpl->setCurrentBlock('vcard');
349  $tpl->setVariable('TXT_VCARD', $this->lng->txt('vcard'));
350  $tpl->setVariable('TXT_DOWNLOAD_VCARD', $this->lng->txt('vcard_download'));
351  $this->ctrl->setParameter($this, 'user_id', $this->getUserId());
352  $tpl->setVariable('HREF_VCARD', $this->ctrl->getLinkTarget($this, 'deliverVCard'));
353  }
354 
355  $imagefile = ilObjUser::_getPersonalPicturePath($user->getId(), 'big', false, true);
356  if ($this->getPublicPref($user, 'public_upload') === 'y' && $imagefile !== ''
357  && ($this->current_user->getId() !== ANONYMOUS_USER_ID || $user->getPref('public_profile') === 'g')) {
358 
359  $tpl->setCurrentBlock('image');
360  $tpl->setVariable('TXT_IMAGE', $this->lng->txt('image'));
361  $tpl->setVariable('IMAGE_PATH', $imagefile);
362  $tpl->setVariable('IMAGE_ALT', $this->lng->txt('personal_picture'));
364  }
365 
366  // address
367  if ($this->getPublicPref($user, 'public_street') == 'y' ||
368  $this->getPublicPref($user, 'public_zipcode') == 'y' ||
369  $this->getPublicPref($user, 'public_city') == 'y' ||
370  $this->getPublicPref($user, 'public_country') == 'y') {
371  $address = [];
372  $val_arr = [
373  'getStreet' => 'street',
374  'getZipcode' => 'zipcode',
375  'getCity' => 'city',
376  'getCountry' => 'country',
377  'getSelectedCountry' => 'sel_country'
378  ];
379  foreach ($val_arr as $key => $value) {
380  // if value 'y' show information
381  if ($this->getPublicPref($user, 'public_' . $value) == 'y') {
382  $address_value = $user->$key();
383 
384  // only if set
385  if (trim($address_value) != '') {
386  switch ($value) {
387  case 'street':
388  $address[0] = $address_value;
389  break;
390 
391  case 'zipcode':
392  case 'city':
393  $address[1] = isset($address[1])
394  ? "{$address[1]} {$address_value}"
395  : $address_value;
396  break;
397 
398  case 'sel_country':
399  $this->lng->loadLanguageModule('meta');
400  $address[2] = $this->lng->txt('meta_c_' . $address_value);
401  break;
402 
403  case 'country':
404  $address[2] = $address_value;
405  break;
406  }
407  }
408  }
409  }
410  if (count($address)) {
411  $tpl->setCurrentBlock('address_line');
412  foreach ($address as $line) {
413  if (trim($line)) {
414  $tpl->setVariable('TXT_ADDRESS_LINE', trim($line));
416  }
417  }
418  $tpl->setCurrentBlock('address');
419  $tpl->setVariable('TXT_ADDRESS', $this->lng->txt('address'));
421  }
422  }
423 
424  // if value 'y' show information
425  if ($this->getPublicPref($user, 'public_org_units') == 'y') {
426  $tpl->setCurrentBlock('org_units');
427  $tpl->setVariable('TXT_ORG_UNITS', $this->lng->txt('objs_orgu'));
428  $tpl->setVariable('ORG_UNITS', $user->getOrgUnitsRepresentation());
430  }
431 
432  if ($this->getPublicPref($user, 'public_institution') == 'y' ||
433  $this->getPublicPref($user, 'public_department') == 'y') {
434  $tpl->setCurrentBlock('inst_dep');
435  $sep = '';
436  if ($this->getPublicPref($user, 'public_institution') == 'y') {
437  $h = $this->lng->txt('institution');
438  $v = $user->getInstitution();
439  $sep = ' / ';
440  }
441  if ($this->getPublicPref($user, 'public_department') == 'y') {
442  $h .= $sep . $this->lng->txt('department');
443  $v .= $sep . $user->getDepartment();
444  }
445  $tpl->setVariable('TXT_INST_DEP', $h);
446  $tpl->setVariable('INST_DEP', $v);
448  }
449 
450  // contact
451  $val_arr = [
452  'getPhoneOffice' => 'phone_office', 'getPhoneHome' => 'phone_home',
453  'getPhoneMobile' => 'phone_mobile', 'getFax' => 'fax', 'getEmail' => 'email', 'getSecondEmail' => 'second_email'
454  ];
455  $v = $sep = '';
456  foreach ($val_arr as $key => $value) {
457  // if value 'y' show information
458  if ($this->getPublicPref($user, 'public_' . $value) == 'y') {
459  $v .= $sep . $this->lng->txt($value) . ': ' . $user->$key();
460  $sep = '<br />';
461  }
462  }
463  if ($v != '') {
464  $tpl->parseCurrentBlock('contact');
465  $tpl->setVariable('TXT_CONTACT', $this->lng->txt('contact'));
466  $tpl->setVariable('CONTACT', $v);
468  }
469 
470 
471  $val_arr = [
472  'getHobby' => 'hobby',
473  'getGeneralInterestsAsText' => 'interests_general',
474  'getOfferingHelpAsText' => 'interests_help_offered',
475  'getLookingForHelpAsText' => 'interests_help_looking',
476  'getMatriculation' => 'matriculation',
477  'getClientIP' => 'client_ip'
478  ];
479 
480  foreach ($val_arr as $key => $value) {
481  // if value 'y' show information
482  if ($this->getPublicPref($user, 'public_' . $value) == 'y') {
483  $tpl->setCurrentBlock('profile_data');
484  $tpl->setVariable('TXT_DATA', $this->lng->txt($value));
485  $tpl->setVariable('DATA', $user->$key());
487  }
488  }
489 
490  // portfolios
491  $back = ($this->getBackUrl() != '')
492  ? $this->getBackUrl()
493  : ilLink::_getStaticLink($this->getUserId(), 'usr', true);
495  [$this->getUserId()],
496  $back
497  );
498  $cnt = 0;
499  if (count($port) > 0) {
500  foreach ($port as $u) {
501  $tpl->setCurrentBlock('portfolio');
502  foreach ($u as $link => $title) {
503  $cnt++;
504  $tpl->setVariable('HREF_PORTFOLIO', $link);
505  $tpl->setVariable('TITLE_PORTFOLIO', $title);
507  }
508  }
509  $tpl->setCurrentBlock('portfolios');
510  if ($cnt > 1) {
511  $this->lng->loadLanguageModule('prtf');
512  $tpl->setVariable('TXT_PORTFOLIO', $this->lng->txt('prtf_portfolios'));
513  } else {
514  $tpl->setVariable('TXT_PORTFOLIO', $this->lng->txt('portfolio'));
515  }
517  }
518 
519  // map
520  if (ilMapUtil::isActivated() &&
521  $this->getPublicPref($user, 'public_location') == 'y' &&
522  $user->getLatitude() != '') {
523  $tpl->setVariable('TXT_LOCATION', $this->lng->txt('location'));
524 
525  $map_gui = ilMapUtil::getMapGUI();
526  $map_gui->setMapId('user_map')
527  ->setWidth('350px')
528  ->setHeight('230px')
529  ->setLatitude($user->getLatitude())
530  ->setLongitude($user->getLongitude())
531  ->setZoom($user->getLocationZoom())
532  ->setEnableNavigationControl(true)
533  ->addUserMarker($user->getId());
534 
535  $tpl->setVariable('MAP_CONTENT', $map_gui->getHtml());
536  }
537 
538  // additional defined user data fields
539  $this->user_defined_fields = ilUserDefinedFields::_getInstance();
540  $user_defined_data = $user->getUserDefinedData();
541  foreach ($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition) {
542  // public setting
543  if ($this->getPublicPref($user, 'public_udf_' . $definition['field_id']) == 'y') {
544  if ($user_defined_data['f_' . $definition['field_id']] != '') {
545  $tpl->setCurrentBlock('udf_data');
546  $tpl->setVariable('TXT_UDF_DATA', $definition['field_name']);
547  $tpl->setVariable('UDF_DATA', $user_defined_data['f_' . $definition['field_id']]);
549  }
550  }
551  }
552 
553  // additional information
554  $additional = $this->getAdditional();
555  if (is_array($additional)) {
556  foreach ($additional as $key => $val) {
557  $tpl->setCurrentBlock('profile_data');
558  $tpl->setVariable('TXT_DATA', $key);
559  $tpl->setVariable('DATA', $val);
561  }
562  }
563 
564  if (
565  $this->getUserId() != $this->current_user->getId() &&
566  !$this->current_user->isAnonymous() &&
568  ) {
569  $button = ilBuddySystemLinkButton::getInstanceByUserId($user->getId());
570  $tpl->setVariable('BUDDY_HTML', $button->getHtml());
571  }
572 
573  //badge
574  $tpl->setVariable('USER_BADGES', $this->badges_renderer->render($user->getId()));
575 
576  $goto = '';
577  if ($a_add_goto) {
578  $mtpl = $this->tpl;
579 
580  $mtpl->setPermanentLink(
581  'usr',
582  $user->getId(),
583  '',
584  '_top'
585  );
586  }
587  return $tpl->get() . $goto;
588  }
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
const ANONYMOUS_USER_ID
Definition: constants.php:27
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
static getLinkTarget( $gui, string $cmd, array $gui_params=[], array $mail_params=[], array $context_params=[])
setVariable(string $variable, $value='')
Sets the given variable to the given value.
getPublicPref(ilObjUser $a_user, string $a_id)
Get user preference for public profile.
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static getMapGUI()
Get an instance of the GUI class.
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path='ilpublicuserprofilegui')
Default behaviour is:
$_SERVER['HTTP_HOST']
Definition: raiseError.php:26
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
static _isAnonymous(int $usr_id)
static isActivated()
Checks whether Map feature is activated.
static _getPersonalPicturePath(int $a_usr_id, string $a_size='small', bool $a_force_pic=false, bool $a_prevent_no_photo_image=false, bool $html_export=false)
const IL_CAL_DATE
setPermanentLink(string $a_type, ?int $a_id, string $a_append="", string $a_target="", string $a_title="")
Generates and sets a permanent ilias link.
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
static getAvailablePortfolioLinksForUserIds(array $a_owner_ids, ?string $a_back_url=null)
ilGlobalTemplateInterface $tpl
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHTML()

ilPublicUserProfileGUI::getHTML ( )

Definition at line 215 of file class.ilPublicUserProfileGUI.php.

References ILIAS\Repository\ctrl(), getEmbeddable(), getProfilePortfolio(), getUserId(), ilUtil\redirect(), and renderTitle().

Referenced by view().

215  : string
216  {
217  if ($this->embedded) {
218  return $this->getEmbeddable();
219  }
220 
221  // #15438 - (currently) inactive user?
222  $is_active = true;
223  $user = new ilObjUser($this->getUserId());
224  if (!$user->getActive() ||
225  !$user->checkTimeLimit()) {
226  $is_active = false;
227  }
228 
229  if ($is_active && $this->getProfilePortfolio()) {
230  $this->ctrl->redirectByClass('ilobjportfoliogui', 'preview');
231  } else {
232  if (!$is_active) {
233  ilUtil::redirect('ilias.php?baseClass=ilDashboardGUI');
234  }
235 
236  // Check from Database if value
237  // of public_profile = 'y' show user infomation
238  $user = new ilObjUser($this->getUserId());
239  $current = $user->getPref('public_profile');
240  if ($user->getPref('public_profile') == 'g' && !$this->setting->get('enable_global_profiles')) {
241  $current = 'y';
242  }
243 
244  if ($current != 'y' &&
245  ($current != 'g' || !$this->setting->get('enable_global_profiles')) &&
246  !$this->custom_prefs) {
247  ilUtil::redirect('ilias.php?baseClass=ilDashboardGUI');
248  }
249 
250  $this->renderTitle();
251  return $this->getEmbeddable(true);
252  }
253  return '';
254  }
getProfilePortfolio()
Check if current profile portfolio is accessible.
getEmbeddable(bool $a_add_goto=false)
get public profile html code Used in Personal Profile (as preview) and Portfolio (as page block) ...
static redirect(string $a_script)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getProfilePortfolio()

ilPublicUserProfileGUI::getProfilePortfolio ( )
protected

Check if current profile portfolio is accessible.

Definition at line 738 of file class.ilPublicUserProfileGUI.php.

References ilObjPortfolio\getDefaultPortfolio(), getUserId(), and null.

Referenced by executeCommand(), and getHTML().

738  : ?int
739  {
740  $portfolio_id = ilObjPortfolio::getDefaultPortfolio($this->getUserId());
741  if ($portfolio_id) {
742  $access_handler = new ilPortfolioAccessHandler();
743  if ($access_handler->checkAccess('read', '', $portfolio_id)) {
744  return $portfolio_id;
745  }
746  }
747  return null;
748  }
static getDefaultPortfolio(int $a_user_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Access handler for portfolio NOTE: This file needs to stay in the classes directory, WAC will be confused otherwise.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPublicPref()

ilPublicUserProfileGUI::getPublicPref ( ilObjUser  $a_user,
string  $a_id 
)
protected

Get user preference for public profile.

Definition at line 140 of file class.ilPublicUserProfileGUI.php.

References ilObjUser\getPref().

Referenced by getEmbeddable().

140  : string
141  {
142  if (!$this->custom_prefs) {
143  return (string) $a_user->getPref($a_id);
144  } else {
145  return (string) ($this->custom_prefs[$a_id] ?? '');
146  }
147  }
getPref(string $a_keyword)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUserId()

ilPublicUserProfileGUI::getUserId ( )

Definition at line 91 of file class.ilPublicUserProfileGUI.php.

References $userid.

Referenced by approveContactRequest(), deliverVCard(), executeCommand(), getEmbeddable(), getHTML(), getProfilePortfolio(), ignoreContactRequest(), isProfilePublic(), and renderTitle().

91  : int
92  {
93  return $this->userid;
94  }
+ Here is the caller graph for this function:

◆ ignoreContactRequest()

ilPublicUserProfileGUI::ignoreContactRequest ( )
protected

Definition at line 807 of file class.ilPublicUserProfileGUI.php.

References ILIAS\Repository\ctrl(), and getUserId().

807  : void
808  {
809  $osd_id = $this->profile_request->getOsdId();
810  if ($osd_id > 0) {
811  $this->ctrl->setParameterByClass('ilBuddySystemGUI', 'osd_id', $osd_id);
812  }
813 
814  $this->ctrl->setParameterByClass('ilBuddySystemGUI', 'user_id', $this->getUserId());
815  $this->ctrl->redirectByClass(['ilPublicUserProfileGUI', 'ilBuddySystemGUI'], 'ignore');
816  }
+ Here is the call graph for this function:

◆ isProfilePublic()

ilPublicUserProfileGUI::isProfilePublic ( )
protected

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

References getUserId().

Referenced by getEmbeddable().

204  : bool
205  {
206  $user = new ilObjUser($this->getUserId());
207  $current = $user->getPref('public_profile');
208  // #17462 - see ilPersonalProfileGUI::initPublicProfileForm()
209  if ($user->getPref('public_profile') === 'g' && !$this->setting->get('enable_global_profiles')) {
210  $current = 'y';
211  }
212  return in_array($current, ['g', 'y']);
213  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderTitle()

ilPublicUserProfileGUI::renderTitle ( )

Definition at line 728 of file class.ilPublicUserProfileGUI.php.

References ilObjUser\_getPersonalPicturePath(), ilUserUtil\getNamePresentation(), and getUserId().

Referenced by getHTML().

728  : void
729  {
730  $this->tpl->resetHeaderBlock();
731  $this->tpl->setTitle(ilUserUtil::getNamePresentation($this->getUserId()));
732  $this->tpl->setTitleIcon(ilObjUser::_getPersonalPicturePath($this->getUserId(), 'xsmall'));
733  }
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path='ilpublicuserprofilegui')
Default behaviour is:
static _getPersonalPicturePath(int $a_usr_id, string $a_size='small', bool $a_force_pic=false, bool $a_prevent_no_photo_image=false, bool $html_export=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAdditional()

ilPublicUserProfileGUI::setAdditional ( array  $a_additional)

Set Additonal Information.

Definition at line 99 of file class.ilPublicUserProfileGUI.php.

99  : void
100  {
101  $this->additional = $a_additional;
102  }

◆ setBackUrl()

ilPublicUserProfileGUI::setBackUrl ( string  $backurl)

Set Back Link URL.

Definition at line 112 of file class.ilPublicUserProfileGUI.php.

References $backurl, $parts, and ILIAS\Repository\ctrl().

Referenced by ilWorkspaceAccessGUI\executeCommand(), ilInfoScreenGUI\executeCommand(), and ilPersonalProfileGUI\executeCommand().

112  : void
113  {
114  // we only allow relative links
115  $parts = parse_url($backurl);
116  $host = $parts['host'] ?? '';
117  if ($host !== '') {
118  $backurl = '#';
119  }
120  $this->backurl = $backurl;
121  $this->ctrl->setParameter($this, 'back_url', rawurlencode($backurl));
122  }
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCustomPrefs()

ilPublicUserProfileGUI::setCustomPrefs ( array  $a_prefs)

Set custom preferences for public profile fields.

Definition at line 132 of file class.ilPublicUserProfileGUI.php.

132  : void // Missing array type.
133  {
134  $this->custom_prefs = $a_prefs;
135  }

◆ setEmbedded()

ilPublicUserProfileGUI::setEmbedded ( bool  $a_value,
bool  $a_offline = false 
)

Definition at line 149 of file class.ilPublicUserProfileGUI.php.

149  : void
150  {
151  $this->embedded = $a_value;
152  $this->offline = $a_offline;
153  }

◆ setUserId()

ilPublicUserProfileGUI::setUserId ( int  $a_userid)

Definition at line 86 of file class.ilPublicUserProfileGUI.php.

86  : void
87  {
88  $this->userid = $a_userid;
89  }

◆ validateUser()

ilPublicUserProfileGUI::validateUser ( int  $usrId)
protected

Check if given user id is valid.

Definition at line 700 of file class.ilPublicUserProfileGUI.php.

References ilObject\_lookupType(), and ILIAS\Repository\ctrl().

Referenced by executeCommand().

700  : bool
701  {
702  if (ilObject::_lookupType($usrId) != 'usr') {
703  return false;
704  }
705 
706  $user = new ilObjUser($usrId);
707 
708  if ($this->current_user->isAnonymous()) {
709  if (strtolower($this->ctrl->getCmd()) == strtolower('approveContactRequest')) {
710  $this->ctrl->redirectToURL('login.php?cmd=force_login&target=usr_' . $usrId . '_contact_approved');
711  } elseif (strtolower($this->ctrl->getCmd()) == strtolower('ignoreContactRequest')) {
712  $this->ctrl->redirectToURL('login.php?cmd=force_login&target=usr_' . $usrId . '_contact_ignored');
713  }
714 
715  if ($user->getPref('public_profile') != 'g') {
716  // #12151
717  if ($user->getPref('public_profile') == 'y') {
718  $this->ctrl->redirectToURL('login.php?cmd=force_login&target=usr_' . $usrId);
719  }
720 
721  return false;
722  }
723  }
724 
725  return true;
726  }
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ view()

ilPublicUserProfileGUI::view ( )

View.

This one is called e.g. through the goto script

Definition at line 199 of file class.ilPublicUserProfileGUI.php.

References getHTML().

199  : string
200  {
201  return $this->getHTML();
202  }
+ Here is the call graph for this function:

Field Documentation

◆ $additional

array ilPublicUserProfileGUI::$additional = []
private

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

Referenced by getAdditional().

◆ $backurl

string ilPublicUserProfileGUI::$backurl = ''
private

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

Referenced by getBackUrl(), and setBackUrl().

◆ $badges_renderer

PublicUserProfileBadgesRenderer ilPublicUserProfileGUI::$badges_renderer
private

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

◆ $ctrl

ilCtrl ilPublicUserProfileGUI::$ctrl
private

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

◆ $current_user

ilObjUser ilPublicUserProfileGUI::$current_user
private

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

◆ $custom_prefs

array ilPublicUserProfileGUI::$custom_prefs = []
private

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

◆ $embedded

bool ilPublicUserProfileGUI::$embedded = false
private

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

◆ $lng

Language ilPublicUserProfileGUI::$lng
private

Definition at line 47 of file class.ilPublicUserProfileGUI.php.

◆ $offline

bool ilPublicUserProfileGUI::$offline = false
private

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

◆ $profile_request

GUIRequest ilPublicUserProfileGUI::$profile_request
private

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

◆ $rbac_system

ilRbacSystem ilPublicUserProfileGUI::$rbac_system
private

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

◆ $setting

ilSetting ilPublicUserProfileGUI::$setting
private

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

◆ $tabs

ilTabsGUI ilPublicUserProfileGUI::$tabs
private

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

◆ $tpl

ilGlobalTemplateInterface ilPublicUserProfileGUI::$tpl
private

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

Referenced by getEmbeddable().

◆ $user_defined_fields

ilUserDefinedFields ilPublicUserProfileGUI::$user_defined_fields
private

Definition at line 34 of file class.ilPublicUserProfileGUI.php.

◆ $userid

int ilPublicUserProfileGUI::$userid = 0
private

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

Referenced by getUserId().


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