ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilPublicUserProfileGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
29 {
30  private bool $offline = false;
33  private int $userid = 0;
34  private string $backurl = '';
35  private array $additional = []; // Missing array type.
36  private bool $embedded = false;
37  private array $custom_prefs = []; // Missing array type.
40  private ilCtrl $ctrl;
41  private ilTabsGUI $tabs;
44  private ilLanguage $lng;
45 
46  public function __construct(int $a_user_id = 0)
47  {
49  global $DIC;
50 
51  $this->ctrl = $DIC['ilCtrl'];
52  $this->lng = $DIC['lng'];
53  $this->current_user = $DIC['ilUser'];
54  $this->setting = $DIC['ilSetting'];
55  $this->tabs = $DIC['ilTabs'];
56  $this->tpl = $DIC['tpl'];
57  $this->rbac_system = $DIC['rbacsystem'];
58  $this->lng = $DIC['lng'];
59 
60  $this->profile_request = new ProfileGUIRequest(
61  $DIC->http(),
62  $DIC->refinery()
63  );
64 
65  if ($a_user_id) {
66  $this->setUserId($a_user_id);
67  } else {
68  $this->setUserId($this->profile_request->getUserId());
69  }
70 
71  $this->ctrl->saveParameter($this, ['user_id','back_url', 'user']);
72  $back_url = $this->profile_request->getBackUrl();
73  if ($back_url !== '') {
74  $this->setBackUrl($back_url);
75  }
76 
77  $this->lng->loadLanguageModule('user');
78  }
79 
80  public function setUserId(int $a_userid): void
81  {
82  $this->userid = $a_userid;
83  }
84 
85  public function getUserId(): int
86  {
87  return $this->userid;
88  }
89 
93  public function setAdditional(array $a_additional): void
94  {
95  $this->additional = $a_additional;
96  }
97 
98  public function getAdditional(): array
99  {
100  return $this->additional;
101  }
102 
106  public function setBackUrl(string $backurl): 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  }
117 
118  public function getBackUrl(): string
119  {
120  return $this->backurl;
121  }
122 
126  public function setCustomPrefs(array $a_prefs): void // Missing array type.
127  {
128  $this->custom_prefs = $a_prefs;
129  }
130 
134  protected function getPublicPref(ilObjUser $a_user, string $a_id): 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  }
142 
143  public function setEmbedded(bool $a_value, bool $a_offline = false): void
144  {
145  $this->embedded = $a_value;
146  $this->offline = $a_offline;
147  }
148 
149  public function executeCommand(): 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  }
189 
193  public function view(): string
194  {
195  return $this->getHTML();
196  }
197 
198  protected function isProfilePublic(): 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  }
208 
209  public function getHTML(): 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  }
249 
250 
255  public function getEmbeddable(bool $a_add_goto = false): 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('&amp;', '&', $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);
304  $tpl->parseCurrentBlock();
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)));
337  $tpl->parseCurrentBlock();
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'));
357  $tpl->parseCurrentBlock();
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));
409  $tpl->parseCurrentBlock();
410  }
411  }
412  $tpl->setCurrentBlock('address');
413  $tpl->setVariable('TXT_ADDRESS', $this->lng->txt('address'));
414  $tpl->parseCurrentBlock();
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());
423  $tpl->parseCurrentBlock();
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);
441  $tpl->parseCurrentBlock();
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);
461  $tpl->parseCurrentBlock();
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());
480  $tpl->parseCurrentBlock();
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);
500  $tpl->parseCurrentBlock();
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  }
510  $tpl->parseCurrentBlock();
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']]);
542  $tpl->parseCurrentBlock();
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);
554  $tpl->parseCurrentBlock();
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  }
590  $tpl->parseCurrentBlock();
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  }
621 
625  public function deliverVCard(): 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  }
728 
732  protected function validateUser(int $usrId): 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  }
759 
760  public function renderTitle(): void
761  {
762  $this->tpl->resetHeaderBlock();
763  $this->tpl->setTitle(ilUserUtil::getNamePresentation($this->getUserId()));
764  $this->tpl->setTitleIcon(ilObjUser::_getPersonalPicturePath($this->getUserId(), 'xsmall'));
765  }
766 
770  protected function getProfilePortfolio(): ?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  }
781 
782  public static function getAutocompleteResult(
783  string $a_field_id,
784  string $a_term
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  }
817 
818  protected function doProfileAutoComplete(): 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  }
828 
829  protected function approveContactRequest(): 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  }
838 
839  protected function ignoreContactRequest(): 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  }
849 }
setEmbedded(bool $a_value, bool $a_offline=false)
exit
Definition: login.php:29
Class ilBuddySystemGUI.
const ANONYMOUS_USER_ID
Definition: constants.php:27
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:64
touchBlock(string $block)
overwrites ITX::touchBlock.
static getInstancesByUserId(int $a_user_id)
Additional user data fields definition.
deliverVCard()
Deliver vcard information.
static getAutocompleteResult(string $a_field_id, string $a_term)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
static getDefaultPortfolio(int $a_user_id)
Get default portfolio of user.
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
setAdditional(array $a_additional)
Set Additonal Information.
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.
static deliverData(string $a_data, string $a_filename, string $mime="application/octet-stream")
const TEL_TYPE_FAX
setBackUrl(string $backurl)
Set Back Link URL.
getPublicPref(ilObjUser $a_user, string $a_id)
Get user preference for public profile.
static findInterests(string $a_term, ?int $a_user_id=null, string $a_field_id=null)
Interface ilCtrlBaseClassInterface describes ilCtrl base classes.
global $DIC
Definition: feed.php:28
getProfilePortfolio()
Check if current profile portfolio is accessible.
RFC 2426 vCard MIME Directory Profile 3.0 class.
GUI class for public user profile presentation.
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.
Portfolio view gui class.
__construct(VocabulariesInterface $vocabularies)
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:
ilUserDefinedFields $user_defined_fields
const TEL_TYPE_HOME
validateUser(int $usrId)
Check if given user id is valid.
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
getPref(string $a_keyword)
const TEL_TYPE_WORK
string $key
Consumer key/client ID value.
Definition: System.php:193
const TEL_TYPE_CELL
setCustomPrefs(array $a_prefs)
Set custom preferences for public profile fields.
getEmbeddable(bool $a_add_goto=false)
get public profile html code Used in Personal Profile (as preview) and Portfolio (as page block) ...
Class ilUserAvatarResolver.
static _isAnonymous(int $usr_id)
static redirect(string $a_script)
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
Access handler for portfolio NOTE: This file needs to stay in the classes directory, WAC will be confused otherwise.
static getAvailablePortfolioLinksForUserIds(array $a_owner_ids, ?string $a_back_url=null)
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
static _lookupType(int $id, bool $reference=false)
ilGlobalTemplateInterface $tpl