ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilPublicUserProfileGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
25 
32 {
33  private bool $offline = false;
36  private int $userid = 0;
37  private string $backurl = '';
38  private array $additional = []; // Missing array type.
39  private bool $embedded = false;
40  private array $custom_prefs = []; // Missing array type.
43  private ilCtrl $ctrl;
44  private ilTabsGUI $tabs;
47  private Language $lng;
49 
50  public function __construct(int $a_user_id = 0)
51  {
53  global $DIC;
54 
55  $this->ctrl = $DIC['ilCtrl'];
56  $this->lng = $DIC['lng'];
57  $this->current_user = $DIC['ilUser'];
58  $this->setting = $DIC['ilSetting'];
59  $this->tabs = $DIC['ilTabs'];
60  $this->tpl = $DIC['tpl'];
61  $this->rbac_system = $DIC['rbacsystem'];
62  $this->lng = $DIC['lng'];
63 
64  $this->profile_request = new GUIRequest(
65  $DIC->http(),
66  $DIC->refinery()
67  );
68 
69  $this->badges_renderer = new PublicUserProfileBadgesRenderer();
70 
71  if ($a_user_id) {
72  $this->setUserId($a_user_id);
73  } else {
74  $this->setUserId($this->profile_request->getUserId());
75  }
76 
77  $this->ctrl->saveParameter($this, ['user_id','back_url', 'user']);
78  $back_url = $this->profile_request->getBackUrl();
79  if ($back_url !== '') {
80  $this->setBackUrl($back_url);
81  }
82 
83  $this->lng->loadLanguageModule('user');
84  }
85 
86  public function setUserId(int $a_userid): void
87  {
88  $this->userid = $a_userid;
89  }
90 
91  public function getUserId(): int
92  {
93  return $this->userid;
94  }
95 
99  public function setAdditional(array $a_additional): void
100  {
101  $this->additional = $a_additional;
102  }
103 
104  public function getAdditional(): array
105  {
106  return $this->additional;
107  }
108 
112  public function setBackUrl(string $backurl): void
113  {
114  // we only allow relative links
115  $parts = parse_url($backurl);
116  $host = $parts['host'] ?? '';
117  if ($host !== '') {
118  $backurl = '#';
119  }
120  $this->backurl = $backurl;
121  $this->ctrl->setParameter($this, 'back_url', rawurlencode($backurl));
122  }
123 
124  public function getBackUrl(): string
125  {
126  return $this->backurl;
127  }
128 
132  public function setCustomPrefs(array $a_prefs): void // Missing array type.
133  {
134  $this->custom_prefs = $a_prefs;
135  }
136 
140  protected function getPublicPref(ilObjUser $a_user, string $a_id): string
141  {
142  if (!$this->custom_prefs) {
143  return (string) $a_user->getPref($a_id);
144  } else {
145  return (string) ($this->custom_prefs[$a_id] ?? '');
146  }
147  }
148 
149  public function setEmbedded(bool $a_value, bool $a_offline = false): void
150  {
151  $this->embedded = $a_value;
152  $this->offline = $a_offline;
153  }
154 
155  public function executeCommand(): string
156  {
157  $ret = '';
158  if (!$this->validateUser($this->getUserId())) {
159  return '';
160  }
161  $next_class = $this->ctrl->getNextClass($this);
162  $cmd = $this->ctrl->getCmd();
163 
164  $this->tpl->loadStandardTemplate();
165 
166  switch ($next_class) {
167  case 'ilbuddysystemgui':
168  $gui = new ilBuddySystemGUI();
169  $this->ctrl->setReturn($this, 'view');
170  $this->ctrl->forwardCommand($gui);
171  break;
172  case 'ilobjportfoliogui':
173  $portfolio_id = $this->getProfilePortfolio();
174  if ($portfolio_id
175  && $cmd !== 'deliverVCard') {
176  $gui = new ilObjPortfolioGUI($portfolio_id); // #11876
177  $gui->setAdditional($this->getAdditional());
178  $gui->setPermaLink($this->getUserId(), 'usr');
179  $this->ctrl->forwardCommand($gui);
180  break;
181  }
182  // no break
183  default:
184  $ret = $this->$cmd();
185  $this->tpl->setContent($ret);
186  break;
187  }
188 
189  // only for direct links
190  if (strtolower($this->profile_request->getBaseClass()) == 'ilpublicuserprofilegui') {
191  $this->tpl->printToStdout();
192  }
193  return (string) $ret;
194  }
195 
199  public function view(): string
200  {
201  return $this->getHTML();
202  }
203 
204  protected function isProfilePublic(): bool
205  {
206  $user = new ilObjUser($this->getUserId());
207  $current = $user->getPref('public_profile');
208  // #17462 - see ilPersonalProfileGUI::initPublicProfileForm()
209  if ($user->getPref('public_profile') === 'g' && !$this->setting->get('enable_global_profiles')) {
210  $current = 'y';
211  }
212  return in_array($current, ['g', 'y']);
213  }
214 
215  public function getHTML(): string
216  {
217  if ($this->embedded) {
218  return $this->getEmbeddable();
219  }
220 
221  // #15438 - (currently) inactive user?
222  $is_active = true;
223  $user = new ilObjUser($this->getUserId());
224  if (!$user->getActive() ||
225  !$user->checkTimeLimit()) {
226  $is_active = false;
227  }
228 
229  if ($is_active && $this->getProfilePortfolio()) {
230  $this->ctrl->redirectByClass('ilobjportfoliogui', 'preview');
231  } else {
232  if (!$is_active) {
233  ilUtil::redirect('ilias.php?baseClass=ilDashboardGUI');
234  }
235 
236  // Check from Database if value
237  // of public_profile = 'y' show user infomation
238  $user = new ilObjUser($this->getUserId());
239  $current = $user->getPref('public_profile');
240  if ($user->getPref('public_profile') == 'g' && !$this->setting->get('enable_global_profiles')) {
241  $current = 'y';
242  }
243 
244  if ($current != 'y' &&
245  ($current != 'g' || !$this->setting->get('enable_global_profiles')) &&
246  !$this->custom_prefs) {
247  ilUtil::redirect('ilias.php?baseClass=ilDashboardGUI');
248  }
249 
250  $this->renderTitle();
251  return $this->getEmbeddable(true);
252  }
253  return '';
254  }
255 
256 
261  public function getEmbeddable(bool $a_add_goto = false): string
262  {
263  $h = $v = '';
264 
265  // get user object
266  if (!ilObject::_exists($this->getUserId())) {
267  return '';
268  }
269  $user = new ilObjUser($this->getUserId());
270 
271  $tpl = new ilTemplate(
272  'tpl.usr_public_profile.html',
273  true,
274  true,
275  'components/ILIAS/User'
276  );
277 
278 
279  $tpl->setVariable('ROWCOL1', 'tblrow1');
280  $tpl->setVariable('ROWCOL2', 'tblrow2');
281 
282  if (!$this->offline && $this->current_user->getId() != ANONYMOUS_USER_ID) {
283  $ref_url = str_replace('&amp;', '&', $this->getBackUrl());
284  if (!$ref_url) {
285  $ref_url = basename($_SERVER['REQUEST_URI']);
286  }
287 
288  $mail_url = '';
289  if ($this->rbac_system->checkAccess('internal_mail', ilMailGlobalServices::getMailObjectRefId())) {
290  $mail_url = ilMailFormCall::getLinkTarget(
291  $ref_url,
292  '',
293  [],
294  [
295  'type' => 'new',
296  'rcp_to' => $user->getLogin()
297  ]
298  );
299  } elseif ($user->getPref('public_profile') === 'g' ||
300  (!$this->current_user->isAnonymous() && $user->getPref('public_profile') === 'y') &&
301  $user->getPref('public_email') &&
302  $user->getEmail() !== '') {
303  $mail_url = 'mailto:' . $user->getEmail();
304  }
305 
306  if ($mail_url !== '') {
307  $tpl->setCurrentBlock('mail');
308  $tpl->setVariable('TXT_MAIL', $this->lng->txt('send_mail'));
309  $tpl->setVariable('HREF_MAIL', $mail_url);
310  $tpl->parseCurrentBlock();
311  }
312  }
313 
314 
315  // short version, fixes e.g. #27242
316  if (!$this->isProfilePublic()) {
317  $tpl->setVariable('TXT_NAME', $this->lng->txt('name'));
318  $tpl->setVariable('FIRSTNAME', ilUserUtil::getNamePresentation($user->getId()));
319  return $tpl->get();
320  }
321 
322  $first_name = '';
323  if ($this->getPublicPref($user, 'public_title') == 'y') {
324  $first_name .= $user->getUTitle() . ' ';
325  }
326  $first_name .= $user->getFirstname();
327 
328  if ($this->getPublicPref($user, 'public_gender') == 'y' && in_array($user->getGender(), ['m', 'f'])) {
329  $sal = $this->lng->txt('salutation_' . $user->getGender()) . ' ';
330  $tpl->setVariable('SALUTATION', $sal);
331  }
332 
333  $tpl->setVariable('TXT_NAME', $this->lng->txt('name'));
334  $tpl->setVariable('FIRSTNAME', $first_name);
335  $tpl->setVariable('LASTNAME', $user->getLastname());
336 
337  if ($user->getBirthday() &&
338  $this->getPublicPref($user, 'public_birthday') == 'y') {
339  // #17574
340  $tpl->setCurrentBlock('bday_bl');
341  $tpl->setVariable('TXT_BIRTHDAY', $this->lng->txt('birthday'));
342  $tpl->setVariable('VAL_BIRTHDAY', ilDatePresentation::formatDate(new ilDate($user->getBirthday(), IL_CAL_DATE)));
343  $tpl->parseCurrentBlock();
344  }
345 
346  if (!$this->offline) {
347  // vcard
348  $tpl->setCurrentBlock('vcard');
349  $tpl->setVariable('TXT_VCARD', $this->lng->txt('vcard'));
350  $tpl->setVariable('TXT_DOWNLOAD_VCARD', $this->lng->txt('vcard_download'));
351  $this->ctrl->setParameter($this, 'user_id', $this->getUserId());
352  $tpl->setVariable('HREF_VCARD', $this->ctrl->getLinkTarget($this, 'deliverVCard'));
353  }
354 
355  $imagefile = ilObjUser::_getPersonalPicturePath($user->getId(), 'big', false, true);
356  if ($this->getPublicPref($user, 'public_upload') === 'y' && $imagefile !== ''
357  && ($this->current_user->getId() !== ANONYMOUS_USER_ID || $user->getPref('public_profile') === 'g')) {
358 
359  $tpl->setCurrentBlock('image');
360  $tpl->setVariable('TXT_IMAGE', $this->lng->txt('image'));
361  $tpl->setVariable('IMAGE_PATH', $imagefile);
362  $tpl->setVariable('IMAGE_ALT', $this->lng->txt('personal_picture'));
363  $tpl->parseCurrentBlock();
364  }
365 
366  // address
367  if ($this->getPublicPref($user, 'public_street') == 'y' ||
368  $this->getPublicPref($user, 'public_zipcode') == 'y' ||
369  $this->getPublicPref($user, 'public_city') == 'y' ||
370  $this->getPublicPref($user, 'public_country') == 'y') {
371  $address = [];
372  $val_arr = [
373  'getStreet' => 'street',
374  'getZipcode' => 'zipcode',
375  'getCity' => 'city',
376  'getCountry' => 'country',
377  'getSelectedCountry' => 'sel_country'
378  ];
379  foreach ($val_arr as $key => $value) {
380  // if value 'y' show information
381  if ($this->getPublicPref($user, 'public_' . $value) == 'y') {
382  $address_value = $user->$key();
383 
384  // only if set
385  if (trim($address_value) != '') {
386  switch ($value) {
387  case 'street':
388  $address[0] = $address_value;
389  break;
390 
391  case 'zipcode':
392  case 'city':
393  $address[1] = isset($address[1])
394  ? "{$address[1]} {$address_value}"
395  : $address_value;
396  break;
397 
398  case 'sel_country':
399  $this->lng->loadLanguageModule('meta');
400  $address[2] = $this->lng->txt('meta_c_' . $address_value);
401  break;
402 
403  case 'country':
404  $address[2] = $address_value;
405  break;
406  }
407  }
408  }
409  }
410  if (count($address)) {
411  $tpl->setCurrentBlock('address_line');
412  foreach ($address as $line) {
413  if (trim($line)) {
414  $tpl->setVariable('TXT_ADDRESS_LINE', trim($line));
415  $tpl->parseCurrentBlock();
416  }
417  }
418  $tpl->setCurrentBlock('address');
419  $tpl->setVariable('TXT_ADDRESS', $this->lng->txt('address'));
420  $tpl->parseCurrentBlock();
421  }
422  }
423 
424  // if value 'y' show information
425  if ($this->getPublicPref($user, 'public_org_units') == 'y') {
426  $tpl->setCurrentBlock('org_units');
427  $tpl->setVariable('TXT_ORG_UNITS', $this->lng->txt('objs_orgu'));
428  $tpl->setVariable('ORG_UNITS', $user->getOrgUnitsRepresentation());
429  $tpl->parseCurrentBlock();
430  }
431 
432  if ($this->getPublicPref($user, 'public_institution') == 'y' ||
433  $this->getPublicPref($user, 'public_department') == 'y') {
434  $tpl->setCurrentBlock('inst_dep');
435  $sep = '';
436  if ($this->getPublicPref($user, 'public_institution') == 'y') {
437  $h = $this->lng->txt('institution');
438  $v = $user->getInstitution();
439  $sep = ' / ';
440  }
441  if ($this->getPublicPref($user, 'public_department') == 'y') {
442  $h .= $sep . $this->lng->txt('department');
443  $v .= $sep . $user->getDepartment();
444  }
445  $tpl->setVariable('TXT_INST_DEP', $h);
446  $tpl->setVariable('INST_DEP', $v);
447  $tpl->parseCurrentBlock();
448  }
449 
450  // contact
451  $val_arr = [
452  'getPhoneOffice' => 'phone_office', 'getPhoneHome' => 'phone_home',
453  'getPhoneMobile' => 'phone_mobile', 'getFax' => 'fax', 'getEmail' => 'email', 'getSecondEmail' => 'second_email'
454  ];
455  $v = $sep = '';
456  foreach ($val_arr as $key => $value) {
457  // if value 'y' show information
458  if ($this->getPublicPref($user, 'public_' . $value) == 'y') {
459  $v .= $sep . $this->lng->txt($value) . ': ' . $user->$key();
460  $sep = '<br />';
461  }
462  }
463  if ($v != '') {
464  $tpl->parseCurrentBlock('contact');
465  $tpl->setVariable('TXT_CONTACT', $this->lng->txt('contact'));
466  $tpl->setVariable('CONTACT', $v);
467  $tpl->parseCurrentBlock();
468  }
469 
470 
471  $val_arr = [
472  'getHobby' => 'hobby',
473  'getGeneralInterestsAsText' => 'interests_general',
474  'getOfferingHelpAsText' => 'interests_help_offered',
475  'getLookingForHelpAsText' => 'interests_help_looking',
476  'getMatriculation' => 'matriculation',
477  'getClientIP' => 'client_ip'
478  ];
479 
480  foreach ($val_arr as $key => $value) {
481  // if value 'y' show information
482  if ($this->getPublicPref($user, 'public_' . $value) == 'y') {
483  $tpl->setCurrentBlock('profile_data');
484  $tpl->setVariable('TXT_DATA', $this->lng->txt($value));
485  $tpl->setVariable('DATA', $user->$key());
486  $tpl->parseCurrentBlock();
487  }
488  }
489 
490  // portfolios
491  $back = ($this->getBackUrl() != '')
492  ? $this->getBackUrl()
493  : ilLink::_getStaticLink($this->getUserId(), 'usr', true);
495  [$this->getUserId()],
496  $back
497  );
498  $cnt = 0;
499  if (count($port) > 0) {
500  foreach ($port as $u) {
501  $tpl->setCurrentBlock('portfolio');
502  foreach ($u as $link => $title) {
503  $cnt++;
504  $tpl->setVariable('HREF_PORTFOLIO', $link);
505  $tpl->setVariable('TITLE_PORTFOLIO', $title);
506  $tpl->parseCurrentBlock();
507  }
508  }
509  $tpl->setCurrentBlock('portfolios');
510  if ($cnt > 1) {
511  $this->lng->loadLanguageModule('prtf');
512  $tpl->setVariable('TXT_PORTFOLIO', $this->lng->txt('prtf_portfolios'));
513  } else {
514  $tpl->setVariable('TXT_PORTFOLIO', $this->lng->txt('portfolio'));
515  }
516  $tpl->parseCurrentBlock();
517  }
518 
519  // map
520  if (ilMapUtil::isActivated() &&
521  $this->getPublicPref($user, 'public_location') == 'y' &&
522  $user->getLatitude() != '') {
523  $tpl->setVariable('TXT_LOCATION', $this->lng->txt('location'));
524 
525  $map_gui = ilMapUtil::getMapGUI();
526  $map_gui->setMapId('user_map')
527  ->setWidth('350px')
528  ->setHeight('230px')
529  ->setLatitude($user->getLatitude())
530  ->setLongitude($user->getLongitude())
531  ->setZoom($user->getLocationZoom())
532  ->setEnableNavigationControl(true)
533  ->addUserMarker($user->getId());
534 
535  $tpl->setVariable('MAP_CONTENT', $map_gui->getHtml());
536  }
537 
538  // additional defined user data fields
539  $this->user_defined_fields = ilUserDefinedFields::_getInstance();
540  $user_defined_data = $user->getUserDefinedData();
541  foreach ($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition) {
542  // public setting
543  if ($this->getPublicPref($user, 'public_udf_' . $definition['field_id']) == 'y') {
544  if ($user_defined_data['f_' . $definition['field_id']] != '') {
545  $tpl->setCurrentBlock('udf_data');
546  $tpl->setVariable('TXT_UDF_DATA', $definition['field_name']);
547  $tpl->setVariable('UDF_DATA', $user_defined_data['f_' . $definition['field_id']]);
548  $tpl->parseCurrentBlock();
549  }
550  }
551  }
552 
553  // additional information
554  $additional = $this->getAdditional();
555  if (is_array($additional)) {
556  foreach ($additional as $key => $val) {
557  $tpl->setCurrentBlock('profile_data');
558  $tpl->setVariable('TXT_DATA', $key);
559  $tpl->setVariable('DATA', $val);
560  $tpl->parseCurrentBlock();
561  }
562  }
563 
564  if (
565  $this->getUserId() != $this->current_user->getId() &&
566  !$this->current_user->isAnonymous() &&
568  ) {
569  $button = ilBuddySystemLinkButton::getInstanceByUserId($user->getId());
570  $tpl->setVariable('BUDDY_HTML', $button->getHtml());
571  }
572 
573  //badge
574  $tpl->setVariable('USER_BADGES', $this->badges_renderer->render($user->getId()));
575 
576  $goto = '';
577  if ($a_add_goto) {
578  $mtpl = $this->tpl;
579 
580  $mtpl->setPermanentLink(
581  'usr',
582  $user->getId(),
583  '',
584  '_top'
585  );
586  }
587  return $tpl->get() . $goto;
588  }
589 
593  public function deliverVCard(): void
594  {
595  // get user object
596  if (!ilObject::_exists($this->getUserId())) {
597  return;
598  }
599  $user = new ilObjUser($this->getUserId());
600 
601  $vcard = new VCard();
602 
603  // ilsharedresourceGUI: embedded in shared portfolio
604  if ($user->getPref('public_profile') != 'y' &&
605  $user->getPref('public_profile') != 'g' &&
606  strtolower($this->profile_request->getBaseClass()) != 'ilsharedresourcegui' &&
607  $this->current_user->getId() != $this->getUserId()
608  ) {
609  return;
610  }
611 
612  $vcard->setName($user->getLastname(), $user->getFirstname(), '', $user->getUTitle());
613  $vcard->setNickname($user->getLogin());
614 
615  list($image, $type) = (new ilUserAvatarResolver($this->getUserId()))->getUserPictureForVCard();
616  if ($image !== null) {
617  $vcard->setPhoto($image, $type);
618  }
619 
620  $val_arr = [
621  'getOrgUnitsRepresentation' => 'org_units', 'getInstitution' => 'institution',
622  'getDepartment' => 'department', 'getStreet' => 'street',
623  'getZipcode' => 'zipcode', 'getCity' => 'city', 'getCountry' => 'country',
624  'getPhoneOffice' => 'phone_office', 'getPhoneHome' => 'phone_home',
625  'getPhoneMobile' => 'phone_mobile', 'getFax' => 'fax', 'getEmail' => 'email',
626  'getHobby' => 'hobby', 'getMatriculation' => 'matriculation',
627  'getClientIP' => 'client_ip', 'dummy' => 'location'
628  ];
629 
630  $org = [];
631  $adr = [];
632  foreach ($val_arr as $key => $value) {
633  // if value 'y' show information
634  if ($user->getPref('public_' . $value) == 'y') {
635  switch ($value) {
636  case 'institution':
637  $org[0] = $user->$key();
638  break;
639  case 'department':
640  $org[1] = $user->$key();
641  break;
642  case 'street':
643  $adr[2] = $user->$key();
644  break;
645  case 'zipcode':
646  $adr[5] = $user->$key();
647  break;
648  case 'city':
649  $adr[3] = $user->$key();
650  break;
651  case 'country':
652  $adr[6] = $user->$key();
653  break;
654  case 'phone_office':
655  $vcard->setPhone($user->$key(), VCard::TEL_TYPE_WORK);
656  break;
657  case 'phone_home':
658  $vcard->setPhone($user->$key(), VCard::TEL_TYPE_HOME);
659  break;
660  case 'phone_mobile':
661  $vcard->setPhone($user->$key(), VCard::TEL_TYPE_CELL);
662  break;
663  case 'fax':
664  $vcard->setPhone($user->$key(), VCard::TEL_TYPE_FAX);
665  break;
666  case 'email':
667  $vcard->setEmail($user->$key());
668  break;
669  case 'hobby':
670  $vcard->setNote($user->$key());
671  break;
672  case 'location':
673  $vcard->setPosition($user->getLatitude(), $user->getLongitude());
674  break;
675  }
676  }
677  }
678 
679  if (count($org)) {
680  $vcard->setOrganization(implode(';', $org));
681  }
682  if (count($adr)) {
683  $vcard->setAddress(
684  $adr[0] ?? '',
685  $adr[1] ?? '',
686  $adr[2] ?? '',
687  $adr[3] ?? '',
688  $adr[4] ?? '',
689  $adr[5] ?? '',
690  $adr[6] ?? ''
691  );
692  }
693 
694  ilUtil::deliverData($vcard->buildVCard(), $vcard->getFilename(), $vcard->getMimetype());
695  }
696 
700  protected function validateUser(int $usrId): bool
701  {
702  if (ilObject::_lookupType($usrId) != 'usr') {
703  return false;
704  }
705 
706  $user = new ilObjUser($usrId);
707 
708  if ($this->current_user->isAnonymous()) {
709  if (strtolower($this->ctrl->getCmd()) == strtolower('approveContactRequest')) {
710  $this->ctrl->redirectToURL('login.php?cmd=force_login&target=usr_' . $usrId . '_contact_approved');
711  } elseif (strtolower($this->ctrl->getCmd()) == strtolower('ignoreContactRequest')) {
712  $this->ctrl->redirectToURL('login.php?cmd=force_login&target=usr_' . $usrId . '_contact_ignored');
713  }
714 
715  if ($user->getPref('public_profile') != 'g') {
716  // #12151
717  if ($user->getPref('public_profile') == 'y') {
718  $this->ctrl->redirectToURL('login.php?cmd=force_login&target=usr_' . $usrId);
719  }
720 
721  return false;
722  }
723  }
724 
725  return true;
726  }
727 
728  public function renderTitle(): void
729  {
730  $this->tpl->resetHeaderBlock();
731  $this->tpl->setTitle(ilUserUtil::getNamePresentation($this->getUserId()));
732  $this->tpl->setTitleIcon(ilObjUser::_getPersonalPicturePath($this->getUserId(), 'xsmall'));
733  }
734 
738  protected function getProfilePortfolio(): ?int
739  {
740  $portfolio_id = ilObjPortfolio::getDefaultPortfolio($this->getUserId());
741  if ($portfolio_id) {
742  $access_handler = new ilPortfolioAccessHandler();
743  if ($access_handler->checkAccess('read', '', $portfolio_id)) {
744  return $portfolio_id;
745  }
746  }
747  return null;
748  }
749 
750  public static function getAutocompleteResult(
751  string $a_field_id,
752  string $a_term
753  ): array {
754  global $DIC;
755 
756  $ilUser = $DIC['ilUser'];
757  $result = [];
758 
759  $multi_fields = [
760  'interests_general',
761  'interests_help_offered',
762  'interests_help_looking'
763  ];
764  if (in_array($a_field_id, $multi_fields) && $a_term) {
765  // registration has no current user
766  $user_id = null;
767  if ($ilUser && $ilUser->getId() && $ilUser->getId() != ANONYMOUS_USER_ID) {
768  $user_id = $ilUser->getId();
769  }
770 
771  $result = [];
772  $cnt = 0;
773 
774  // term is searched in ALL interest fields, no distinction
775  foreach (ilObjUser::findInterests($a_term, $ilUser->getId()) as $item) {
776  $result[$cnt] = new stdClass();
777  $result[$cnt]->value = $item;
778  $result[$cnt]->label = $item;
779  $cnt++;
780  }
781  }
782 
783  return $result;
784  }
785 
786  protected function doProfileAutoComplete(): void
787  {
788  $field_id = $this->profile_request->getFieldId();
789  $term = $this->profile_request->getTerm();
790 
791  $result = self::getAutocompleteResult($field_id, $term);
792 
793  echo json_encode($result, JSON_THROW_ON_ERROR);
794  exit();
795  }
796 
797  protected function approveContactRequest(): void
798  {
799  $osd_id = $this->profile_request->getOsdId();
800  if ($osd_id) {
801  $this->ctrl->setParameterByClass('ilBuddySystemGUI', 'osd_id', $osd_id);
802  }
803  $this->ctrl->setParameterByClass('ilBuddySystemGUI', 'user_id', $this->getUserId());
804  $this->ctrl->redirectByClass(['ilPublicUserProfileGUI', 'ilBuddySystemGUI'], 'link');
805  }
806 
807  protected function ignoreContactRequest(): void
808  {
809  $osd_id = $this->profile_request->getOsdId();
810  if ($osd_id > 0) {
811  $this->ctrl->setParameterByClass('ilBuddySystemGUI', 'osd_id', $osd_id);
812  }
813 
814  $this->ctrl->setParameterByClass('ilBuddySystemGUI', 'user_id', $this->getUserId());
815  $this->ctrl->redirectByClass(['ilPublicUserProfileGUI', 'ilBuddySystemGUI'], 'ignore');
816  }
817 }
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
setEmbedded(bool $a_value, bool $a_offline=false)
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...
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61
Additional user data fields definition.
deliverVCard()
Deliver vcard information.
static getAutocompleteResult(string $a_field_id, string $a_term)
static getDefaultPortfolio(int $a_user_id)
setAdditional(array $a_additional)
Set Additonal Information.
static getLinkTarget( $gui, string $cmd, array $gui_params=[], array $mail_params=[], array $context_params=[])
static deliverData(string $a_data, string $a_filename, string $mime="application/octet-stream")
setVariable(string $variable, $value='')
Sets the given variable to the given value.
setBackUrl(string $backurl)
Set Back Link URL.
RFC 2426 vCard MIME Directory Profile 3.0 class.
Definition: VCard.php:27
getPublicPref(ilObjUser $a_user, string $a_id)
Get user preference for public profile.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getProfilePortfolio()
Check if current profile portfolio is accessible.
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.
ilObjPortfolioGUI: ilPortfolioPageGUI, ilPageObjectGUI ilObjPortfolioGUI: ilWorkspaceAccessGUI, ilCommentGUI, ilCommonActionDispatcherGUI ilObjPortfolioGUI: ilObjectContentStyleSettingsGUI, ilPortfolioExerciseGUI ilObjPortfolioGUI: ILIAS
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
validateUser(int $usrId)
Check if given user id is valid.
$_SERVER['HTTP_HOST']
Definition: raiseError.php:26
getPref(string $a_keyword)
global $DIC
Definition: shib_login.php:26
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) ...
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
Class ilUserAvatarResolver.
exit
static _isAnonymous(int $usr_id)
static redirect(string $a_script)
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)
static findInterests(string $a_term, ?int $a_user_id=null, ?string $a_field_id=null)
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.
__construct(Container $dic, ilPlugin $plugin)
Access handler for portfolio NOTE: This file needs to stay in the classes directory, WAC will be confused otherwise.
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)
static _lookupType(int $id, bool $reference=false)
PublicUserProfileBadgesRenderer $badges_renderer
ilGlobalTemplateInterface $tpl