ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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
 

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 30 of file class.ilPublicUserProfileGUI.php.

Member Function Documentation

◆ approveContactRequest()

ilPublicUserProfileGUI::approveContactRequest ( )
protected

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

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

833  : void
834  {
835  $osd_id = $this->profile_request->getOsdId();
836  if ($osd_id) {
837  $this->ctrl->setParameterByClass('ilBuddySystemGUI', 'osd_id', $osd_id);
838  }
839  $this->ctrl->setParameterByClass('ilBuddySystemGUI', 'user_id', $this->getUserId());
840  $this->ctrl->redirectByClass(['ilPublicUserProfileGUI', 'ilBuddySystemGUI'], 'link');
841  }
+ Here is the call graph for this function:

◆ deliverVCard()

ilPublicUserProfileGUI::deliverVCard ( )

Deliver vcard information.

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

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

629  : void
630  {
631  // get user object
632  if (!ilObject::_exists($this->getUserId())) {
633  return;
634  }
635  $user = new ilObjUser($this->getUserId());
636 
637  $vcard = new VCard();
638 
639  // ilsharedresourceGUI: embedded in shared portfolio
640  if ($user->getPref('public_profile') != 'y' &&
641  $user->getPref('public_profile') != 'g' &&
642  strtolower($this->profile_request->getBaseClass()) != 'ilsharedresourcegui' &&
643  $this->current_user->getId() != $this->getUserId()
644  ) {
645  return;
646  }
647 
648  $vcard->setName($user->getLastname(), $user->getFirstname(), '', $user->getUTitle());
649  $vcard->setNickname($user->getLogin());
650 
651  list($image, $type) = (new ilUserAvatarResolver($this->getUserId()))->getUserPictureForVCard();
652  if ($image !== null) {
653  $vcard->setPhoto($image, $type);
654  }
655 
656  $val_arr = [
657  'getOrgUnitsRepresentation' => 'org_units', 'getInstitution' => 'institution',
658  'getDepartment' => 'department', 'getStreet' => 'street',
659  'getZipcode' => 'zipcode', 'getCity' => 'city', 'getCountry' => 'country',
660  'getPhoneOffice' => 'phone_office', 'getPhoneHome' => 'phone_home',
661  'getPhoneMobile' => 'phone_mobile', 'getFax' => 'fax', 'getEmail' => 'email',
662  'getHobby' => 'hobby', 'getMatriculation' => 'matriculation',
663  'getClientIP' => 'client_ip', 'dummy' => 'location'
664  ];
665 
666  $org = [];
667  $adr = [];
668  foreach ($val_arr as $key => $value) {
669  // if value 'y' show information
670  if ($user->getPref('public_' . $value) == 'y') {
671  switch ($value) {
672  case 'institution':
673  $org[0] = $user->$key();
674  break;
675  case 'department':
676  $org[1] = $user->$key();
677  break;
678  case 'street':
679  $adr[2] = $user->$key();
680  break;
681  case 'zipcode':
682  $adr[5] = $user->$key();
683  break;
684  case 'city':
685  $adr[3] = $user->$key();
686  break;
687  case 'country':
688  $adr[6] = $user->$key();
689  break;
690  case 'phone_office':
691  $vcard->setPhone($user->$key(), VCard::TEL_TYPE_WORK);
692  break;
693  case 'phone_home':
694  $vcard->setPhone($user->$key(), VCard::TEL_TYPE_HOME);
695  break;
696  case 'phone_mobile':
697  $vcard->setPhone($user->$key(), VCard::TEL_TYPE_CELL);
698  break;
699  case 'fax':
700  $vcard->setPhone($user->$key(), VCard::TEL_TYPE_FAX);
701  break;
702  case 'email':
703  $vcard->setEmail($user->$key());
704  break;
705  case 'hobby':
706  $vcard->setNote($user->$key());
707  break;
708  case 'location':
709  $vcard->setPosition($user->getLatitude(), $user->getLongitude());
710  break;
711  }
712  }
713  }
714 
715  if (count($org)) {
716  $vcard->setOrganization(implode(';', $org));
717  }
718  if (count($adr)) {
719  $vcard->setAddress(
720  $adr[0] ?? '',
721  $adr[1] ?? '',
722  $adr[2] ?? '',
723  $adr[3] ?? '',
724  $adr[4] ?? '',
725  $adr[5] ?? '',
726  $adr[6] ?? ''
727  );
728  }
729 
730  ilUtil::deliverData($vcard->buildVCard(), $vcard->getFilename(), $vcard->getMimetype());
731  }
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 822 of file class.ilPublicUserProfileGUI.php.

References exit.

822  : void
823  {
824  $field_id = $this->profile_request->getFieldId();
825  $term = $this->profile_request->getTerm();
826 
827  $result = self::getAutocompleteResult($field_id, $term);
828 
829  echo json_encode($result, JSON_THROW_ON_ERROR);
830  exit();
831  }
exit
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ executeCommand()

ilPublicUserProfileGUI::executeCommand ( )

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

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

151  : string
152  {
153  $ret = '';
154  if (!$this->validateUser($this->getUserId())) {
155  return '';
156  }
157  $next_class = $this->ctrl->getNextClass($this);
158  $cmd = $this->ctrl->getCmd();
159 
160  $this->tpl->loadStandardTemplate();
161 
162  switch ($next_class) {
163  case 'ilbuddysystemgui':
164  $gui = new ilBuddySystemGUI();
165  $this->ctrl->setReturn($this, 'view');
166  $this->ctrl->forwardCommand($gui);
167  break;
168  case 'ilobjportfoliogui':
169  $portfolio_id = $this->getProfilePortfolio();
170  if ($portfolio_id
171  && $cmd !== 'deliverVCard') {
172  $gui = new ilObjPortfolioGUI($portfolio_id); // #11876
173  $gui->setAdditional($this->getAdditional());
174  $gui->setPermaLink($this->getUserId(), 'usr');
175  $this->ctrl->forwardCommand($gui);
176  break;
177  }
178  // no break
179  default:
180  $ret = $this->$cmd();
181  $this->tpl->setContent($ret);
182  break;
183  }
184 
185  // only for direct links
186  if (strtolower($this->profile_request->getBaseClass()) == 'ilpublicuserprofilegui') {
187  $this->tpl->printToStdout();
188  }
189  return (string) $ret;
190  }
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 100 of file class.ilPublicUserProfileGUI.php.

References $additional.

Referenced by executeCommand(), and getEmbeddable().

100  : array
101  {
102  return $this->additional;
103  }
+ Here is the caller graph for this function:

◆ getAutocompleteResult()

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

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

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

Referenced by ilAccountRegistrationGUI\doProfileAutoComplete().

789  : array {
790  global $DIC;
791 
792  $ilUser = $DIC['ilUser'];
793  $result = [];
794 
795  $multi_fields = [
796  'interests_general',
797  'interests_help_offered',
798  'interests_help_looking'
799  ];
800  if (in_array($a_field_id, $multi_fields) && $a_term) {
801  // registration has no current user
802  $user_id = null;
803  if ($ilUser && $ilUser->getId() && $ilUser->getId() != ANONYMOUS_USER_ID) {
804  $user_id = $ilUser->getId();
805  }
806 
807  $result = [];
808  $cnt = 0;
809 
810  // term is searched in ALL interest fields, no distinction
811  foreach (ilObjUser::findInterests($a_term, $ilUser->getId()) as $item) {
812  $result[$cnt] = new stdClass();
813  $result[$cnt]->value = $item;
814  $result[$cnt]->label = $item;
815  $cnt++;
816  }
817  }
818 
819  return $result;
820  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:22
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 120 of file class.ilPublicUserProfileGUI.php.

References $backurl.

Referenced by getEmbeddable().

120  : string
121  {
122  return $this->backurl;
123  }
+ 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 257 of file class.ilPublicUserProfileGUI.php.

References $_SERVER, $renderer, $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(), ilBadgeAssignment\getInstancesByUserId(), 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(), ILIAS\UICore\GlobalTemplate\setVariable(), and ILIAS\UICore\GlobalTemplate\touchBlock().

Referenced by getHTML().

257  : string
258  {
259  $h = $v = '';
260 
261  // get user object
262  if (!ilObject::_exists($this->getUserId())) {
263  return '';
264  }
265  $user = new ilObjUser($this->getUserId());
266 
267  $tpl = new ilTemplate(
268  'tpl.usr_public_profile.html',
269  true,
270  true,
271  'components/ILIAS/User'
272  );
273 
274 
275  $tpl->setVariable('ROWCOL1', 'tblrow1');
276  $tpl->setVariable('ROWCOL2', 'tblrow2');
277 
278  if (!$this->offline && $this->current_user->getId() != ANONYMOUS_USER_ID) {
279  $ref_url = str_replace('&', '&', $this->getBackUrl());
280  if (!$ref_url) {
281  $ref_url = basename($_SERVER['REQUEST_URI']);
282  }
283 
284  $mail_url = '';
285  if ($this->rbac_system->checkAccess('internal_mail', ilMailGlobalServices::getMailObjectRefId())) {
286  $mail_url = ilMailFormCall::getLinkTarget(
287  $ref_url,
288  '',
289  [],
290  [
291  'type' => 'new',
292  'rcp_to' => $user->getLogin()
293  ]
294  );
295  } elseif ($user->getPref('public_profile') === 'g' ||
296  (!$this->current_user->isAnonymous() && $user->getPref('public_profile') === 'y') &&
297  $user->getPref('public_email') &&
298  $user->getEmail() !== '') {
299  $mail_url = 'mailto:' . $user->getEmail();
300  }
301 
302  if ($mail_url !== '') {
303  $tpl->setCurrentBlock('mail');
304  $tpl->setVariable('TXT_MAIL', $this->lng->txt('send_mail'));
305  $tpl->setVariable('HREF_MAIL', $mail_url);
307  }
308  }
309 
310 
311  // short version, fixes e.g. #27242
312  if (!$this->isProfilePublic()) {
313  $tpl->setVariable('TXT_NAME', $this->lng->txt('name'));
314  $tpl->setVariable('FIRSTNAME', ilUserUtil::getNamePresentation($user->getId()));
315  return $tpl->get();
316  }
317 
318  $first_name = '';
319  if ($this->getPublicPref($user, 'public_title') == 'y') {
320  $first_name .= $user->getUTitle() . ' ';
321  }
322  $first_name .= $user->getFirstname();
323 
324  if ($this->getPublicPref($user, 'public_gender') == 'y' && in_array($user->getGender(), ['m', 'f'])) {
325  $sal = $this->lng->txt('salutation_' . $user->getGender()) . ' ';
326  $tpl->setVariable('SALUTATION', $sal);
327  }
328 
329  $tpl->setVariable('TXT_NAME', $this->lng->txt('name'));
330  $tpl->setVariable('FIRSTNAME', $first_name);
331  $tpl->setVariable('LASTNAME', $user->getLastname());
332 
333  if ($user->getBirthday() &&
334  $this->getPublicPref($user, 'public_birthday') == 'y') {
335  // #17574
336  $tpl->setCurrentBlock('bday_bl');
337  $tpl->setVariable('TXT_BIRTHDAY', $this->lng->txt('birthday'));
338  $tpl->setVariable('VAL_BIRTHDAY', ilDatePresentation::formatDate(new ilDate($user->getBirthday(), IL_CAL_DATE)));
340  }
341 
342  if (!$this->offline) {
343  // vcard
344  $tpl->setCurrentBlock('vcard');
345  $tpl->setVariable('TXT_VCARD', $this->lng->txt('vcard'));
346  $tpl->setVariable('TXT_DOWNLOAD_VCARD', $this->lng->txt('vcard_download'));
347  $this->ctrl->setParameter($this, 'user_id', $this->getUserId());
348  $tpl->setVariable('HREF_VCARD', $this->ctrl->getLinkTarget($this, 'deliverVCard'));
349  }
350 
351  $imagefile = ilObjUser::_getPersonalPicturePath($user->getId(), 'big', false, true);
352  if ($this->getPublicPref($user, 'public_upload') === 'y' && $imagefile !== ''
353  && ($this->current_user->getId() !== ANONYMOUS_USER_ID || $user->getPref('public_profile') === 'g')) {
354 
355  $tpl->setCurrentBlock('image');
356  $tpl->setVariable('TXT_IMAGE', $this->lng->txt('image'));
357  $tpl->setVariable('IMAGE_PATH', $imagefile);
358  $tpl->setVariable('IMAGE_ALT', $this->lng->txt('personal_picture'));
360  }
361 
362  // address
363  if ($this->getPublicPref($user, 'public_street') == 'y' ||
364  $this->getPublicPref($user, 'public_zipcode') == 'y' ||
365  $this->getPublicPref($user, 'public_city') == 'y' ||
366  $this->getPublicPref($user, 'public_country') == 'y') {
367  $address = [];
368  $val_arr = [
369  'getStreet' => 'street',
370  'getZipcode' => 'zipcode',
371  'getCity' => 'city',
372  'getCountry' => 'country',
373  'getSelectedCountry' => 'sel_country'
374  ];
375  foreach ($val_arr as $key => $value) {
376  // if value 'y' show information
377  if ($this->getPublicPref($user, 'public_' . $value) == 'y') {
378  $address_value = $user->$key();
379 
380  // only if set
381  if (trim($address_value) != '') {
382  switch ($value) {
383  case 'street':
384  $address[0] = $address_value;
385  break;
386 
387  case 'zipcode':
388  case 'city':
389  $address[1] = isset($address[1])
390  ? "{$address[1]} {$address_value}"
391  : $address_value;
392  break;
393 
394  case 'sel_country':
395  $this->lng->loadLanguageModule('meta');
396  $address[2] = $this->lng->txt('meta_c_' . $address_value);
397  break;
398 
399  case 'country':
400  $address[2] = $address_value;
401  break;
402  }
403  }
404  }
405  }
406  if (count($address)) {
407  $tpl->setCurrentBlock('address_line');
408  foreach ($address as $line) {
409  if (trim($line)) {
410  $tpl->setVariable('TXT_ADDRESS_LINE', trim($line));
412  }
413  }
414  $tpl->setCurrentBlock('address');
415  $tpl->setVariable('TXT_ADDRESS', $this->lng->txt('address'));
417  }
418  }
419 
420  // if value 'y' show information
421  if ($this->getPublicPref($user, 'public_org_units') == 'y') {
422  $tpl->setCurrentBlock('org_units');
423  $tpl->setVariable('TXT_ORG_UNITS', $this->lng->txt('objs_orgu'));
424  $tpl->setVariable('ORG_UNITS', $user->getOrgUnitsRepresentation());
426  }
427 
428  if ($this->getPublicPref($user, 'public_institution') == 'y' ||
429  $this->getPublicPref($user, 'public_department') == 'y') {
430  $tpl->setCurrentBlock('inst_dep');
431  $sep = '';
432  if ($this->getPublicPref($user, 'public_institution') == 'y') {
433  $h = $this->lng->txt('institution');
434  $v = $user->getInstitution();
435  $sep = ' / ';
436  }
437  if ($this->getPublicPref($user, 'public_department') == 'y') {
438  $h .= $sep . $this->lng->txt('department');
439  $v .= $sep . $user->getDepartment();
440  }
441  $tpl->setVariable('TXT_INST_DEP', $h);
442  $tpl->setVariable('INST_DEP', $v);
444  }
445 
446  // contact
447  $val_arr = [
448  'getPhoneOffice' => 'phone_office', 'getPhoneHome' => 'phone_home',
449  'getPhoneMobile' => 'phone_mobile', 'getFax' => 'fax', 'getEmail' => 'email', 'getSecondEmail' => 'second_email'
450  ];
451  $v = $sep = '';
452  foreach ($val_arr as $key => $value) {
453  // if value 'y' show information
454  if ($this->getPublicPref($user, 'public_' . $value) == 'y') {
455  $v .= $sep . $this->lng->txt($value) . ': ' . $user->$key();
456  $sep = '<br />';
457  }
458  }
459  if ($v != '') {
460  $tpl->parseCurrentBlock('contact');
461  $tpl->setVariable('TXT_CONTACT', $this->lng->txt('contact'));
462  $tpl->setVariable('CONTACT', $v);
464  }
465 
466 
467  $val_arr = [
468  'getHobby' => 'hobby',
469  'getGeneralInterestsAsText' => 'interests_general',
470  'getOfferingHelpAsText' => 'interests_help_offered',
471  'getLookingForHelpAsText' => 'interests_help_looking',
472  'getMatriculation' => 'matriculation',
473  'getClientIP' => 'client_ip'
474  ];
475 
476  foreach ($val_arr as $key => $value) {
477  // if value 'y' show information
478  if ($this->getPublicPref($user, 'public_' . $value) == 'y') {
479  $tpl->setCurrentBlock('profile_data');
480  $tpl->setVariable('TXT_DATA', $this->lng->txt($value));
481  $tpl->setVariable('DATA', $user->$key());
483  }
484  }
485 
486  // portfolios
487  $back = ($this->getBackUrl() != '')
488  ? $this->getBackUrl()
489  : ilLink::_getStaticLink($this->getUserId(), 'usr', true);
491  [$this->getUserId()],
492  $back
493  );
494  $cnt = 0;
495  if (count($port) > 0) {
496  foreach ($port as $u) {
497  $tpl->setCurrentBlock('portfolio');
498  foreach ($u as $link => $title) {
499  $cnt++;
500  $tpl->setVariable('HREF_PORTFOLIO', $link);
501  $tpl->setVariable('TITLE_PORTFOLIO', $title);
503  }
504  }
505  $tpl->setCurrentBlock('portfolios');
506  if ($cnt > 1) {
507  $this->lng->loadLanguageModule('prtf');
508  $tpl->setVariable('TXT_PORTFOLIO', $this->lng->txt('prtf_portfolios'));
509  } else {
510  $tpl->setVariable('TXT_PORTFOLIO', $this->lng->txt('portfolio'));
511  }
513  }
514 
515  // map
516  if (ilMapUtil::isActivated() &&
517  $this->getPublicPref($user, 'public_location') == 'y' &&
518  $user->getLatitude() != '') {
519  $tpl->setVariable('TXT_LOCATION', $this->lng->txt('location'));
520 
521  $map_gui = ilMapUtil::getMapGUI();
522  $map_gui->setMapId('user_map')
523  ->setWidth('350px')
524  ->setHeight('230px')
525  ->setLatitude($user->getLatitude())
526  ->setLongitude($user->getLongitude())
527  ->setZoom($user->getLocationZoom())
528  ->setEnableNavigationControl(true)
529  ->addUserMarker($user->getId());
530 
531  $tpl->setVariable('MAP_CONTENT', $map_gui->getHtml());
532  }
533 
534  // additional defined user data fields
535  $this->user_defined_fields = ilUserDefinedFields::_getInstance();
536  $user_defined_data = $user->getUserDefinedData();
537  foreach ($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition) {
538  // public setting
539  if ($this->getPublicPref($user, 'public_udf_' . $definition['field_id']) == 'y') {
540  if ($user_defined_data['f_' . $definition['field_id']] != '') {
541  $tpl->setCurrentBlock('udf_data');
542  $tpl->setVariable('TXT_UDF_DATA', $definition['field_name']);
543  $tpl->setVariable('UDF_DATA', $user_defined_data['f_' . $definition['field_id']]);
545  }
546  }
547  }
548 
549  // additional information
550  $additional = $this->getAdditional();
551  if (is_array($additional)) {
552  foreach ($additional as $key => $val) {
553  $tpl->setCurrentBlock('profile_data');
554  $tpl->setVariable('TXT_DATA', $key);
555  $tpl->setVariable('DATA', $val);
557  }
558  }
559 
560  if (
561  $this->getUserId() != $this->current_user->getId() &&
562  !$this->current_user->isAnonymous() &&
564  ) {
565  $button = ilBuddySystemLinkButton::getInstanceByUserId($user->getId());
566  $tpl->setVariable('BUDDY_HTML', $button->getHtml());
567  }
568 
569  // badges
570  $this->tpl->addJavaScript('assets/js/PublicProfileBadges.js');
571  $this->tpl->addOnLoadCode('new BadgeToggle("ilbdgprcont", "ilbdgprfhdm", "ilbdgprfhdl", "ilNoDisplay");');
572  $user_badges = ilBadgeAssignment::getInstancesByUserId($user->getId());
573  if ($user_badges) {
574  $has_public_badge = false;
575  $cnt = 0;
576 
577  $cut = 20;
578 
579  foreach ($user_badges as $ass) {
580  // only active
581  if ($ass->getPosition()) {
582  $cnt++;
583 
584  $renderer = new ilBadgeRenderer($ass);
585 
586  // limit to 20, [MORE] link
587  if ($cnt > $cut) {
588  $tpl->setCurrentBlock('hidden_badge');
589  $tpl->touchBlock('hidden_badge');
591  }
592 
593  $tpl->setCurrentBlock('badge_bl');
594  $tpl->setVariable('BADGE', $renderer->getHTML());
596 
597  $has_public_badge = true;
598  }
599  }
600 
601  if ($cnt > $cut) {
602  $this->lng->loadLanguageModule('badge');
603  $tpl->setVariable('BADGE_HIDDEN_TXT_MORE', $this->lng->txt('badge_profile_more'));
604  $tpl->setVariable('BADGE_HIDDEN_TXT_LESS', $this->lng->txt('badge_profile_less'));
605  }
606 
607  if ($has_public_badge) {
608  $tpl->setVariable('TXT_BADGES', $this->lng->txt('obj_bdga'));
609  }
610  }
611 
612  $goto = '';
613  if ($a_add_goto) {
614  $mtpl = $this->tpl;
615 
616  $mtpl->setPermanentLink(
617  'usr',
618  $user->getId(),
619  '',
620  '_top'
621  );
622  }
623  return $tpl->get() . $goto;
624  }
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
$renderer
const ANONYMOUS_USER_ID
Definition: constants.php:27
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
touchBlock(string $block)
overwrites ITX::touchBlock.
static getInstancesByUserId(int $a_user_id)
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 211 of file class.ilPublicUserProfileGUI.php.

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

Referenced by view().

211  : string
212  {
213  if ($this->embedded) {
214  return $this->getEmbeddable();
215  }
216 
217  // #15438 - (currently) inactive user?
218  $is_active = true;
219  $user = new ilObjUser($this->getUserId());
220  if (!$user->getActive() ||
221  !$user->checkTimeLimit()) {
222  $is_active = false;
223  }
224 
225  if ($is_active && $this->getProfilePortfolio()) {
226  $this->ctrl->redirectByClass('ilobjportfoliogui', 'preview');
227  } else {
228  if (!$is_active) {
229  ilUtil::redirect('ilias.php?baseClass=ilDashboardGUI');
230  }
231 
232  // Check from Database if value
233  // of public_profile = 'y' show user infomation
234  $user = new ilObjUser($this->getUserId());
235  $current = $user->getPref('public_profile');
236  if ($user->getPref('public_profile') == 'g' && !$this->setting->get('enable_global_profiles')) {
237  $current = 'y';
238  }
239 
240  if ($current != 'y' &&
241  ($current != 'g' || !$this->setting->get('enable_global_profiles')) &&
242  !$this->custom_prefs) {
243  ilUtil::redirect('ilias.php?baseClass=ilDashboardGUI');
244  }
245 
246  $this->renderTitle();
247  return $this->getEmbeddable(true);
248  }
249  return '';
250  }
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 774 of file class.ilPublicUserProfileGUI.php.

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

Referenced by executeCommand(), and getHTML().

774  : ?int
775  {
776  $portfolio_id = ilObjPortfolio::getDefaultPortfolio($this->getUserId());
777  if ($portfolio_id) {
778  $access_handler = new ilPortfolioAccessHandler();
779  if ($access_handler->checkAccess('read', '', $portfolio_id)) {
780  return $portfolio_id;
781  }
782  }
783  return null;
784  }
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 136 of file class.ilPublicUserProfileGUI.php.

References ilObjUser\getPref().

Referenced by getEmbeddable().

136  : string
137  {
138  if (!$this->custom_prefs) {
139  return (string) $a_user->getPref($a_id);
140  } else {
141  return (string) ($this->custom_prefs[$a_id] ?? '');
142  }
143  }
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 87 of file class.ilPublicUserProfileGUI.php.

References $userid.

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

87  : int
88  {
89  return $this->userid;
90  }
+ Here is the caller graph for this function:

◆ ignoreContactRequest()

ilPublicUserProfileGUI::ignoreContactRequest ( )
protected

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

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

843  : void
844  {
845  $osd_id = $this->profile_request->getOsdId();
846  if ($osd_id > 0) {
847  $this->ctrl->setParameterByClass('ilBuddySystemGUI', 'osd_id', $osd_id);
848  }
849 
850  $this->ctrl->setParameterByClass('ilBuddySystemGUI', 'user_id', $this->getUserId());
851  $this->ctrl->redirectByClass(['ilPublicUserProfileGUI', 'ilBuddySystemGUI'], 'ignore');
852  }
+ Here is the call graph for this function:

◆ isProfilePublic()

ilPublicUserProfileGUI::isProfilePublic ( )
protected

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

References getUserId().

Referenced by getEmbeddable().

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

◆ renderTitle()

ilPublicUserProfileGUI::renderTitle ( )

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

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

Referenced by getHTML().

764  : void
765  {
766  $this->tpl->resetHeaderBlock();
767  $this->tpl->setTitle(ilUserUtil::getNamePresentation($this->getUserId()));
768  $this->tpl->setTitleIcon(ilObjUser::_getPersonalPicturePath($this->getUserId(), 'xsmall'));
769  }
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 95 of file class.ilPublicUserProfileGUI.php.

95  : void
96  {
97  $this->additional = $a_additional;
98  }

◆ setBackUrl()

ilPublicUserProfileGUI::setBackUrl ( string  $backurl)

Set Back Link URL.

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

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

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

108  : void
109  {
110  // we only allow relative links
111  $parts = parse_url($backurl);
112  $host = $parts['host'] ?? '';
113  if ($host !== '') {
114  $backurl = '#';
115  }
116  $this->backurl = $backurl;
117  $this->ctrl->setParameter($this, 'back_url', rawurlencode($backurl));
118  }
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 128 of file class.ilPublicUserProfileGUI.php.

128  : void // Missing array type.
129  {
130  $this->custom_prefs = $a_prefs;
131  }

◆ setEmbedded()

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

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

145  : void
146  {
147  $this->embedded = $a_value;
148  $this->offline = $a_offline;
149  }

◆ setUserId()

ilPublicUserProfileGUI::setUserId ( int  $a_userid)

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

82  : void
83  {
84  $this->userid = $a_userid;
85  }

◆ validateUser()

ilPublicUserProfileGUI::validateUser ( int  $usrId)
protected

Check if given user id is valid.

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

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

Referenced by executeCommand().

736  : bool
737  {
738  if (ilObject::_lookupType($usrId) != 'usr') {
739  return false;
740  }
741 
742  $user = new ilObjUser($usrId);
743 
744  if ($this->current_user->isAnonymous()) {
745  if (strtolower($this->ctrl->getCmd()) == strtolower('approveContactRequest')) {
746  $this->ctrl->redirectToURL('login.php?cmd=force_login&target=usr_' . $usrId . '_contact_approved');
747  } elseif (strtolower($this->ctrl->getCmd()) == strtolower('ignoreContactRequest')) {
748  $this->ctrl->redirectToURL('login.php?cmd=force_login&target=usr_' . $usrId . '_contact_ignored');
749  }
750 
751  if ($user->getPref('public_profile') != 'g') {
752  // #12151
753  if ($user->getPref('public_profile') == 'y') {
754  $this->ctrl->redirectToURL('login.php?cmd=force_login&target=usr_' . $usrId);
755  }
756 
757  return false;
758  }
759  }
760 
761  return true;
762  }
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 195 of file class.ilPublicUserProfileGUI.php.

References getHTML().

195  : string
196  {
197  return $this->getHTML();
198  }
+ Here is the call graph for this function:

Field Documentation

◆ $additional

array ilPublicUserProfileGUI::$additional = []
private

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

Referenced by getAdditional().

◆ $backurl

string ilPublicUserProfileGUI::$backurl = ''
private

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

Referenced by getBackUrl(), and setBackUrl().

◆ $ctrl

ilCtrl ilPublicUserProfileGUI::$ctrl
private

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

◆ $current_user

ilObjUser ilPublicUserProfileGUI::$current_user
private

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

◆ $custom_prefs

array ilPublicUserProfileGUI::$custom_prefs = []
private

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

◆ $embedded

bool ilPublicUserProfileGUI::$embedded = false
private

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

◆ $lng

Language ilPublicUserProfileGUI::$lng
private

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

◆ $offline

bool ilPublicUserProfileGUI::$offline = false
private

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

◆ $profile_request

GUIRequest ilPublicUserProfileGUI::$profile_request
private

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

◆ $rbac_system

ilRbacSystem ilPublicUserProfileGUI::$rbac_system
private

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

◆ $setting

ilSetting ilPublicUserProfileGUI::$setting
private

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

◆ $tabs

ilTabsGUI ilPublicUserProfileGUI::$tabs
private

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

◆ $tpl

ilGlobalTemplateInterface ilPublicUserProfileGUI::$tpl
private

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

Referenced by getEmbeddable().

◆ $user_defined_fields

ilUserDefinedFields ilPublicUserProfileGUI::$user_defined_fields
private

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

◆ $userid

int ilPublicUserProfileGUI::$userid = 0
private

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

Referenced by getUserId().


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