ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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
 
ProfileGUIRequest $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
 
ilLanguage $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 28 of file class.ilPublicUserProfileGUI.php.

Member Function Documentation

◆ approveContactRequest()

ilPublicUserProfileGUI::approveContactRequest ( )
protected

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

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

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

◆ deliverVCard()

ilPublicUserProfileGUI::deliverVCard ( )

Deliver vcard information.

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

References ILIAS\LTI\ToolProvider\$key, ilObject\_exists(), ilUtil\deliverData(), getUserId(), TEL_TYPE_CELL, TEL_TYPE_FAX, TEL_TYPE_HOME, and TEL_TYPE_WORK.

625  : void
626  {
627  // get user object
628  if (!ilObject::_exists($this->getUserId())) {
629  return;
630  }
631  $user = new ilObjUser($this->getUserId());
632 
633  $vcard = new ilvCard();
634 
635  // ilsharedresourceGUI: embedded in shared portfolio
636  if ($user->getPref('public_profile') != 'y' &&
637  $user->getPref('public_profile') != 'g' &&
638  strtolower($this->profile_request->getBaseClass()) != 'ilsharedresourcegui' &&
639  $this->current_user->getId() != $this->getUserId()
640  ) {
641  return;
642  }
643 
644  $vcard->setName($user->getLastname(), $user->getFirstname(), '', $user->getUTitle());
645  $vcard->setNickname($user->getLogin());
646 
647  list($image, $type) = (new ilUserAvatarResolver($this->getUserId()))->getUserPictureForVCard();
648  if ($image !== null) {
649  $vcard->setPhoto($image, $type);
650  }
651 
652  $val_arr = [
653  'getOrgUnitsRepresentation' => 'org_units', 'getInstitution' => 'institution',
654  'getDepartment' => 'department', 'getStreet' => 'street',
655  'getZipcode' => 'zipcode', 'getCity' => 'city', 'getCountry' => 'country',
656  'getPhoneOffice' => 'phone_office', 'getPhoneHome' => 'phone_home',
657  'getPhoneMobile' => 'phone_mobile', 'getFax' => 'fax', 'getEmail' => 'email',
658  'getHobby' => 'hobby', 'getMatriculation' => 'matriculation',
659  'getClientIP' => 'client_ip', 'dummy' => 'location'
660  ];
661 
662  $org = [];
663  $adr = [];
664  foreach ($val_arr as $key => $value) {
665  // if value 'y' show information
666  if ($user->getPref('public_' . $value) == 'y') {
667  switch ($value) {
668  case 'institution':
669  $org[0] = $user->$key();
670  break;
671  case 'department':
672  $org[1] = $user->$key();
673  break;
674  case 'street':
675  $adr[2] = $user->$key();
676  break;
677  case 'zipcode':
678  $adr[5] = $user->$key();
679  break;
680  case 'city':
681  $adr[3] = $user->$key();
682  break;
683  case 'country':
684  $adr[6] = $user->$key();
685  break;
686  case 'phone_office':
687  $vcard->setPhone($user->$key(), TEL_TYPE_WORK);
688  break;
689  case 'phone_home':
690  $vcard->setPhone($user->$key(), TEL_TYPE_HOME);
691  break;
692  case 'phone_mobile':
693  $vcard->setPhone($user->$key(), TEL_TYPE_CELL);
694  break;
695  case 'fax':
696  $vcard->setPhone($user->$key(), TEL_TYPE_FAX);
697  break;
698  case 'email':
699  $vcard->setEmail($user->$key());
700  break;
701  case 'hobby':
702  $vcard->setNote($user->$key());
703  break;
704  case 'location':
705  $vcard->setPosition($user->getLatitude(), $user->getLongitude());
706  break;
707  }
708  }
709  }
710 
711  if (count($org)) {
712  $vcard->setOrganization(implode(';', $org));
713  }
714  if (count($adr)) {
715  $vcard->setAddress(
716  $adr[0] ?? '',
717  $adr[1] ?? '',
718  $adr[2] ?? '',
719  $adr[3] ?? '',
720  $adr[4] ?? '',
721  $adr[5] ?? '',
722  $adr[6] ?? ''
723  );
724  }
725 
726  ilUtil::deliverData($vcard->buildVCard(), $vcard->getFilename(), $vcard->getMimetype());
727  }
static deliverData(string $a_data, string $a_filename, string $mime="application/octet-stream")
const TEL_TYPE_FAX
RFC 2426 vCard MIME Directory Profile 3.0 class.
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
const TEL_TYPE_HOME
const TEL_TYPE_WORK
string $key
Consumer key/client ID value.
Definition: System.php:193
const TEL_TYPE_CELL
Class ilUserAvatarResolver.
+ Here is the call graph for this function:

◆ doProfileAutoComplete()

ilPublicUserProfileGUI::doProfileAutoComplete ( )
protected

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

References exit.

818  : void
819  {
820  $field_id = $this->profile_request->getFieldId();
821  $term = $this->profile_request->getTerm();
822 
823  $result = self::getAutocompleteResult($field_id, $term);
824 
825  echo json_encode($result, JSON_THROW_ON_ERROR);
826  exit();
827  }
exit
Definition: login.php:29

◆ executeCommand()

ilPublicUserProfileGUI::executeCommand ( )

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

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

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

◆ getAdditional()

ilPublicUserProfileGUI::getAdditional ( )

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

References $additional.

Referenced by executeCommand(), and getEmbeddable().

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

◆ getAutocompleteResult()

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

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

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

Referenced by ilAccountRegistrationGUI\doProfileAutoComplete().

785  : array {
786  global $DIC;
787 
788  $ilUser = $DIC['ilUser'];
789  $result = [];
790 
791  $multi_fields = [
792  'interests_general',
793  'interests_help_offered',
794  'interests_help_looking'
795  ];
796  if (in_array($a_field_id, $multi_fields) && $a_term) {
797  // registration has no current user
798  $user_id = null;
799  if ($ilUser && $ilUser->getId() && $ilUser->getId() != ANONYMOUS_USER_ID) {
800  $user_id = $ilUser->getId();
801  }
802 
803  $result = [];
804  $cnt = 0;
805 
806  // term is searched in ALL interest fields, no distinction
807  foreach (ilObjUser::findInterests($a_term, $ilUser->getId()) as $item) {
808  $result[$cnt] = new stdClass();
809  $result[$cnt]->value = $item;
810  $result[$cnt]->label = $item;
811  $cnt++;
812  }
813  }
814 
815  return $result;
816  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
static findInterests(string $a_term, ?int $a_user_id=null, string $a_field_id=null)
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBackUrl()

ilPublicUserProfileGUI::getBackUrl ( )

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

References $backurl.

Referenced by getEmbeddable().

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

References $_SERVER, ILIAS\LTI\ToolProvider\$key, $tpl, ilObject\_exists(), ilUserDefinedFields\_getInstance(), ilObjUser\_getPersonalPicturePath(), ilLink\_getStaticLink(), ilObjUser\_isAnonymous(), ANONYMOUS_USER_ID, ILIAS\Repository\ctrl(), ilDatePresentation\formatDate(), ilGlobalTemplateInterface\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(), ilGlobalTemplateInterface\parseCurrentBlock(), ilGlobalTemplateInterface\setCurrentBlock(), ilGlobalTemplateInterface\setPermanentLink(), ilGlobalTemplateInterface\setVariable(), and ilGlobalTemplateInterface\touchBlock().

Referenced by getHTML().

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

◆ getHTML()

ilPublicUserProfileGUI::getHTML ( )

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

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

Referenced by view().

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

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

Referenced by executeCommand(), and getHTML().

770  : ?int
771  {
772  $portfolio_id = ilObjPortfolio::getDefaultPortfolio($this->getUserId());
773  if ($portfolio_id) {
774  $access_handler = new ilPortfolioAccessHandler();
775  if ($access_handler->checkAccess('read', '', $portfolio_id)) {
776  return $portfolio_id;
777  }
778  }
779  return null;
780  }
static getDefaultPortfolio(int $a_user_id)
Get default portfolio of user.
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 134 of file class.ilPublicUserProfileGUI.php.

References ilObjUser\getPref().

Referenced by getEmbeddable().

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

References $userid.

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

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

◆ ignoreContactRequest()

ilPublicUserProfileGUI::ignoreContactRequest ( )
protected

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

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

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

◆ isProfilePublic()

ilPublicUserProfileGUI::isProfilePublic ( )
protected

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

References getUserId().

Referenced by getEmbeddable().

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

◆ renderTitle()

ilPublicUserProfileGUI::renderTitle ( )

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

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

Referenced by getHTML().

760  : void
761  {
762  $this->tpl->resetHeaderBlock();
763  $this->tpl->setTitle(ilUserUtil::getNamePresentation($this->getUserId()));
764  $this->tpl->setTitleIcon(ilObjUser::_getPersonalPicturePath($this->getUserId(), 'xsmall'));
765  }
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 93 of file class.ilPublicUserProfileGUI.php.

93  : void
94  {
95  $this->additional = $a_additional;
96  }

◆ setBackUrl()

ilPublicUserProfileGUI::setBackUrl ( string  $backurl)

Set Back Link URL.

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

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

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

106  : void
107  {
108  // we only allow relative links
109  $parts = parse_url($backurl);
110  $host = $parts['host'] ?? '';
111  if ($host !== '') {
112  $backurl = '#';
113  }
114  $this->backurl = $backurl;
115  $this->ctrl->setParameter($this, 'back_url', rawurlencode($backurl));
116  }
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:64
+ 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 126 of file class.ilPublicUserProfileGUI.php.

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

◆ setEmbedded()

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

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

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

◆ setUserId()

ilPublicUserProfileGUI::setUserId ( int  $a_userid)

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

80  : void
81  {
82  $this->userid = $a_userid;
83  }

◆ validateUser()

ilPublicUserProfileGUI::validateUser ( int  $usrId)
protected

Check if given user id is valid.

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

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

Referenced by executeCommand().

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

References getHTML().

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

Field Documentation

◆ $additional

array ilPublicUserProfileGUI::$additional = []
private

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

Referenced by getAdditional().

◆ $backurl

string ilPublicUserProfileGUI::$backurl = ''
private

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

Referenced by getBackUrl(), and setBackUrl().

◆ $ctrl

ilCtrl ilPublicUserProfileGUI::$ctrl
private

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

◆ $current_user

ilObjUser ilPublicUserProfileGUI::$current_user
private

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

◆ $custom_prefs

array ilPublicUserProfileGUI::$custom_prefs = []
private

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

◆ $embedded

bool ilPublicUserProfileGUI::$embedded = false
private

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

◆ $lng

ilLanguage ilPublicUserProfileGUI::$lng
private

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

◆ $offline

bool ilPublicUserProfileGUI::$offline = false
private

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

◆ $profile_request

ProfileGUIRequest ilPublicUserProfileGUI::$profile_request
private

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

◆ $rbac_system

ilRbacSystem ilPublicUserProfileGUI::$rbac_system
private

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

◆ $setting

ilSetting ilPublicUserProfileGUI::$setting
private

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

◆ $tabs

ilTabsGUI ilPublicUserProfileGUI::$tabs
private

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

◆ $tpl

ilGlobalTemplateInterface ilPublicUserProfileGUI::$tpl
private

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

Referenced by getEmbeddable().

◆ $user_defined_fields

ilUserDefinedFields ilPublicUserProfileGUI::$user_defined_fields
private

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

◆ $userid

int ilPublicUserProfileGUI::$userid = 0
private

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

Referenced by getUserId().


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