ILIAS  release_8 Revision v8.24
ilPublicUserProfileGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

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

Public Member Functions

 __construct (int $a_user_id=0)
 
 setUserId (int $a_userid)
 
 getUserId ()
 
 setAdditional (array $a_additional)
 Set Additonal Information. More...
 
 getAdditional ()
 
 setBackUrl (string $a_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 ()
 
 getProfilePortfolio ()
 Check if current profile portfolio is accessible. More...
 
 doProfileAutoComplete ()
 
 approveContactRequest ()
 
 ignoreContactRequest ()
 

Static Protected Member Functions

static validateUser (int $usrId)
 Check if given user id is valid. More...
 

Protected Attributes

ilUserDefinedFields $user_defined_fields
 
ILIAS User ProfileGUIRequest $profile_request
 
int $userid = 0
 
int $portfolioid = 0
 
string $backurl = ""
 
array $additional = []
 
bool $embedded = false
 
array $custom_prefs = []
 
ilObjUser $current_user
 
ilSetting $setting
 

Private Attributes

bool $offline = false
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning GUI class for public user profile presentation.

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

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

Constructor & Destructor Documentation

◆ __construct()

ilPublicUserProfileGUI::__construct ( int  $a_user_id = 0)

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

39 {
40 global $DIC;
41
42 $ilCtrl = $DIC['ilCtrl'];
43 $lng = $DIC['lng'];
44 $this->current_user = $DIC->user();
45
46 $this->setting = $DIC["ilSetting"];
47
48 $this->profile_request = new \ILIAS\User\ProfileGUIRequest(
49 $DIC->http(),
50 $DIC->refinery()
51 );
52
53 if ($a_user_id) {
54 $this->setUserId($a_user_id);
55 } else {
56 $this->setUserId($this->profile_request->getUserId());
57 }
58
59 $ilCtrl->saveParameter($this, array("user_id","back_url", "user"));
60 $back_url = $this->profile_request->getBackUrl();
61 if ($back_url != "") {
62 $this->setBackUrl($back_url);
63 }
64
65 $lng->loadLanguageModule("user");
66 }
setBackUrl(string $a_backurl)
Set Back Link URL.
global $DIC
Definition: feed.php:28
$lng

References $DIC, $lng, setBackUrl(), and setUserId().

+ Here is the call graph for this function:

Member Function Documentation

◆ approveContactRequest()

ilPublicUserProfileGUI::approveContactRequest ( )
protected

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

873 : void
874 {
875 global $DIC;
876
877 $ilCtrl = $DIC->ctrl();
878 $osd_id = $this->profile_request->getOsdId();
879 if ($osd_id) {
880 $ilCtrl->setParameterByClass('ilBuddySystemGUI', 'osd_id', $osd_id);
881 }
882 $ilCtrl->setParameterByClass('ilBuddySystemGUI', 'user_id', $this->getUserId());
883 $ilCtrl->redirectByClass(array('ilPublicUserProfileGUI', 'ilBuddySystemGUI'), 'link');
884 }

References $DIC.

◆ deliverVCard()

ilPublicUserProfileGUI::deliverVCard ( )

Deliver vcard information.

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

647 : void
648 {
649 $type = "";
650 // get user object
651 if (!ilObject::_exists($this->getUserId())) {
652 return;
653 }
654 $user = new ilObjUser($this->getUserId());
655
656 $vcard = new ilvCard();
657
658 // ilsharedresourceGUI: embedded in shared portfolio
659 if ($user->getPref("public_profile") != "y" &&
660 $user->getPref("public_profile") != "g" &&
661 strtolower($this->profile_request->getBaseClass()) != "ilsharedresourcegui" &&
662 $this->current_user->getId() != $this->getUserId()
663 ) {
664 return;
665 }
666
667 $vcard->setName($user->getLastname(), $user->getFirstname(), "", $user->getUTitle());
668 $vcard->setNickname($user->getLogin());
669
670 $webspace_dir = ilFileUtils::getWebspaceDir("output");
671 $imagefile = $webspace_dir . "/usr_images/" . $user->getPref("profile_image");
672 if ($user->getPref("public_upload") == "y" && is_file($imagefile)) {
673 $fh = fopen($imagefile, 'rb');
674 if ($fh) {
675 $image = fread($fh, filesize($imagefile));
676 fclose($fh);
677 $mimetype = ilObjMediaObject::getMimeType($imagefile);
678 if (0 === strpos($mimetype, "image")) {
679 $type = $mimetype;
680 }
681 $vcard->setPhoto($image, $type);
682 }
683 }
684
685 $val_arr = array("getOrgUnitsRepresentation" => "org_units", "getInstitution" => "institution",
686 "getDepartment" => "department", "getStreet" => "street",
687 "getZipcode" => "zipcode", "getCity" => "city", "getCountry" => "country",
688 "getPhoneOffice" => "phone_office", "getPhoneHome" => "phone_home",
689 "getPhoneMobile" => "phone_mobile", "getFax" => "fax", "getEmail" => "email",
690 "getHobby" => "hobby", "getMatriculation" => "matriculation",
691 "getClientIP" => "client_ip", "dummy" => "location");
692
693 $org = array();
694 $adr = array();
695 foreach ($val_arr as $key => $value) {
696 // if value "y" show information
697 if ($user->getPref("public_" . $value) == "y") {
698 switch ($value) {
699 case "institution":
700 $org[0] = $user->$key();
701 break;
702 case "department":
703 $org[1] = $user->$key();
704 break;
705 case "street":
706 $adr[2] = $user->$key();
707 break;
708 case "zipcode":
709 $adr[5] = $user->$key();
710 break;
711 case "city":
712 $adr[3] = $user->$key();
713 break;
714 case "country":
715 $adr[6] = $user->$key();
716 break;
717 case "phone_office":
718 $vcard->setPhone($user->$key(), TEL_TYPE_WORK);
719 break;
720 case "phone_home":
721 $vcard->setPhone($user->$key(), TEL_TYPE_HOME);
722 break;
723 case "phone_mobile":
724 $vcard->setPhone($user->$key(), TEL_TYPE_CELL);
725 break;
726 case "fax":
727 $vcard->setPhone($user->$key(), TEL_TYPE_FAX);
728 break;
729 case "email":
730 $vcard->setEmail($user->$key());
731 break;
732 case "hobby":
733 $vcard->setNote($user->$key());
734 break;
735 case "location":
736 $vcard->setPosition($user->getLatitude(), $user->getLongitude());
737 break;
738 }
739 }
740 }
741
742 if (count($org)) {
743 $vcard->setOrganization(implode(";", $org));
744 }
745 if (count($adr)) {
746 $vcard->setAddress(
747 $adr[0] ?? "",
748 $adr[1] ?? "",
749 $adr[2] ?? "",
750 $adr[3] ?? "",
751 $adr[4] ?? "",
752 $adr[5] ?? "",
753 $adr[6] ?? ""
754 );
755 }
756
757 ilUtil::deliverData($vcard->buildVCard(), $vcard->getFilename(), $vcard->getMimetype());
758 }
const TEL_TYPE_HOME
const TEL_TYPE_FAX
const TEL_TYPE_CELL
const TEL_TYPE_WORK
static getWebspaceDir(string $mode="filesystem")
get webspace directory
static getMimeType(string $a_file, bool $a_external=false)
get mime type for file
User class.
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static deliverData(string $a_data, string $a_filename, string $mime="application/octet-stream")
RFC 2426 vCard MIME Directory Profile 3.0 class.
string $key
Consumer key/client ID value.
Definition: System.php:193
$type

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

+ Here is the call graph for this function:

◆ doProfileAutoComplete()

ilPublicUserProfileGUI::doProfileAutoComplete ( )
protected

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

862 : void
863 {
864 $field_id = $this->profile_request->getFieldId();
865 $term = $this->profile_request->getTerm();
866
867 $result = self::getAutocompleteResult($field_id, $term);
868
869 echo json_encode($result, JSON_THROW_ON_ERROR);
870 exit();
871 }
static getAutocompleteResult(string $a_field_id, string $a_term)
exit
Definition: login.php:28

References exit.

◆ executeCommand()

ilPublicUserProfileGUI::executeCommand ( )

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

141 : string
142 {
143 global $DIC;
144 $ilCtrl = $DIC['ilCtrl'];
145 $tpl = $DIC['tpl'];
146 $ret = "";
147 if (!self::validateUser($this->getUserId())) {
148 return "";
149 }
150 $next_class = $ilCtrl->getNextClass($this);
151 $cmd = $ilCtrl->getCmd();
152
153 $tpl->loadStandardTemplate();
154
155 switch ($next_class) {
156 case 'ilbuddysystemgui':
157 $gui = new ilBuddySystemGUI();
158 $ilCtrl->setReturn($this, 'view');
159 $ilCtrl->forwardCommand($gui);
160 break;
161 case "ilobjportfoliogui":
162 $portfolio_id = $this->getProfilePortfolio();
163 if ($portfolio_id
164 && $cmd !== 'deliverVCard') {
165 $gui = new ilObjPortfolioGUI($portfolio_id); // #11876
166 $gui->setAdditional($this->getAdditional());
167 $gui->setPermaLink($this->getUserId(), "usr");
168 $ilCtrl->forwardCommand($gui);
169 break;
170 }
171 // no break
172 default:
173 $ret = $this->$cmd();
174 $tpl->setContent($ret);
175 break;
176 }
177
178 // only for direct links
179 if (strtolower($this->profile_request->getBaseClass()) == "ilpublicuserprofilegui") {
180 $tpl->printToStdout();
181 }
182 return (string) $ret;
183 }
Class ilBuddySystemGUI.
Portfolio view gui class.
getProfilePortfolio()
Check if current profile portfolio is accessible.
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41

References $DIC, $tpl, getAdditional(), getProfilePortfolio(), and getUserId().

+ Here is the call graph for this function:

◆ getAdditional()

ilPublicUserProfileGUI::getAdditional ( )

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

86 : array // Missing array type.
87 {
88 return $this->additional;
89 }

References $additional.

Referenced by executeCommand(), and getEmbeddable().

+ Here is the caller graph for this function:

◆ getAutocompleteResult()

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

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

824 : array {
825 global $DIC;
826
827 $ilUser = $DIC['ilUser'];
828 $result = [];
829
830 $multi_fields = array("interests_general", "interests_help_offered", "interests_help_looking");
831 if (in_array($a_field_id, $multi_fields) && $a_term) {
832 // registration has no current user
833 $user_id = null;
834 if ($ilUser && $ilUser->getId() && $ilUser->getId() != ANONYMOUS_USER_ID) {
835 $user_id = $ilUser->getId();
836 }
837
838 $result = array();
839 $cnt = 0;
840
841 // term is searched in ALL interest fields, no distinction
842 foreach (ilObjUser::findInterests($a_term, $ilUser->getId()) as $item) {
843 $result[$cnt] = new stdClass();
844 $result[$cnt]->value = $item;
845 $result[$cnt]->label = $item;
846 $cnt++;
847 }
848
849 // :TODO: search in skill data
850 /*
851 foreach (ilSkillTreeNode::findSkills($a_term) as $skill) {
852 $result[$cnt] = new stdClass();
853 $result[$cnt]->value = $skill;
854 $result[$cnt]->label = $skill;
855 $cnt++;
856 }*/
857 }
858
859 return $result;
860 }
static findInterests(string $a_term, ?int $a_user_id=null, string $a_field_id=null)
const ANONYMOUS_USER_ID
Definition: constants.php:27
$ilUser
Definition: imgupload.php:34

Referenced by ilAccountRegistrationGUI\doProfileAutoComplete().

+ Here is the caller graph for this function:

◆ getBackUrl()

ilPublicUserProfileGUI::getBackUrl ( )

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

110 : string
111 {
112 return $this->backurl;
113 }

References $backurl.

Referenced by getEmbeddable().

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

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

References $_SERVER, $additional, $DIC, $ilSetting, $ilUser, ILIAS\LTI\ToolProvider\$key, $lng, $tpl, ilObject\_exists(), ilUserDefinedFields\_getInstance(), ilObjUser\_getPersonalPicturePath(), ilLink\_getStaticLink(), ilObjUser\_isAnonymous(), ANONYMOUS_USER_ID, ilDatePresentation\formatDate(), getAdditional(), ilObjPortfolio\getAvailablePortfolioLinksForUserIds(), getBackUrl(), ilBuddySystemLinkButton\getInstanceByUserId(), ilBadgeAssignment\getInstancesByUserId(), ilMailFormCall\getLinkTarget(), ilMailGlobalServices\getMailObjectRefId(), ilMapUtil\getMapGUI(), ilUserUtil\getNamePresentation(), getPublicPref(), getUserId(), ilFileUtils\getWebspaceDir(), IL_CAL_DATE, ilMapUtil\isActivated(), isProfilePublic(), and ilWACSignedPath\signFile().

Referenced by getHTML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHTML()

ilPublicUserProfileGUI::getHTML ( )

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

205 : string
206 {
207 global $DIC;
208 $ilCtrl = $DIC['ilCtrl'];
209 $ilSetting = $DIC['ilSetting'];
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 $ilCtrl->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 // #17462 - see ilPersonalProfileGUI::initPublicProfileForm()
235 if ($user->getPref("public_profile") == "g" && !$ilSetting->get('enable_global_profiles')) {
236 $current = "y";
237 }
238
239 if ($current != "y" &&
240 ($current != "g" || !$ilSetting->get('enable_global_profiles')) &&
241 !$this->custom_prefs) {
242 ilUtil::redirect('ilias.php?baseClass=ilDashboardGUI');
243 }
244
245 $this->renderTitle();
246 return $this->getEmbeddable(true);
247 }
248 return "";
249 }
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)

References $DIC, $ilSetting, getEmbeddable(), getProfilePortfolio(), getUserId(), ilUtil\redirect(), and renderTitle().

Referenced by view().

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

809 : ?int
810 {
811 $portfolio_id = ilObjPortfolio::getDefaultPortfolio($this->getUserId());
812 if ($portfolio_id) {
813 $access_handler = new ilPortfolioAccessHandler();
814 if ($access_handler->checkAccess("read", "", $portfolio_id)) {
815 return $portfolio_id;
816 }
817 }
818 return null;
819 }
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,...

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

Referenced by executeCommand(), and getHTML().

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

126 : string
127 {
128 if (!$this->custom_prefs) {
129 return (string) $a_user->getPref($a_id);
130 } else {
131 return (string) ($this->custom_prefs[$a_id] ?? "");
132 }
133 }
getPref(string $a_keyword)

References ilObjUser\getPref().

Referenced by getEmbeddable().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUserId()

ilPublicUserProfileGUI::getUserId ( )

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

73 : int
74 {
75 return $this->userid;
76 }

References $userid.

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

+ Here is the caller graph for this function:

◆ ignoreContactRequest()

ilPublicUserProfileGUI::ignoreContactRequest ( )
protected

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

886 : void
887 {
888 global $DIC;
889
890 $ilCtrl = $DIC->ctrl();
891
892 $osd_id = $this->profile_request->getOsdId();
893 if ($osd_id > 0) {
894 $ilCtrl->setParameterByClass('ilBuddySystemGUI', 'osd_id', $osd_id);
895 }
896
897 $ilCtrl->setParameterByClass('ilBuddySystemGUI', 'user_id', $this->getUserId());
898 $ilCtrl->redirectByClass(array('ilPublicUserProfileGUI', 'ilBuddySystemGUI'), 'ignore');
899 }

References $DIC.

◆ isProfilePublic()

ilPublicUserProfileGUI::isProfilePublic ( )
protected

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

193 : bool
194 {
196 $user = new ilObjUser($this->getUserId());
197 $current = $user->getPref("public_profile");
198 // #17462 - see ilPersonalProfileGUI::initPublicProfileForm()
199 if ($user->getPref("public_profile") == "g" && !$setting->get('enable_global_profiles')) {
200 $current = "y";
201 }
202 return in_array($current, ["g", "y"]);
203 }
get(string $a_keyword, ?string $a_default_value=null)
get setting

References $setting, ilSetting\get(), and getUserId().

Referenced by getEmbeddable().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderTitle()

ilPublicUserProfileGUI::renderTitle ( )

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

795 : void
796 {
797 global $DIC;
798
799 $tpl = $DIC['tpl'];
800
801 $tpl->resetHeaderBlock();
803 $tpl->setTitleIcon(ilObjUser::_getPersonalPicturePath($this->getUserId(), "xsmall"));
804 }

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

Referenced by getHTML().

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

81 : void // Missing array type.
82 {
83 $this->additional = $a_additional;
84 }

◆ setBackUrl()

ilPublicUserProfileGUI::setBackUrl ( string  $a_backurl)

Set Back Link URL.

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

94 : void
95 {
96 global $DIC;
97
98 $ilCtrl = $DIC['ilCtrl'];
99
100 // we only allow relative links
101 $parts = parse_url($a_backurl);
102 $host = $parts['host'] ?? '';
103 if ($host !== '') {
104 $a_backurl = "#";
105 }
106 $this->backurl = $a_backurl;
107 $ilCtrl->setParameter($this, "back_url", rawurlencode($a_backurl));
108 }
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:64

References $DIC, and $parts.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setCustomPrefs()

ilPublicUserProfileGUI::setCustomPrefs ( array  $a_prefs)

Set custom preferences for public profile fields.

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

118 : void // Missing array type.
119 {
120 $this->custom_prefs = $a_prefs;
121 }

◆ setEmbedded()

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

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

135 : void
136 {
137 $this->embedded = $a_value;
138 $this->offline = $a_offline;
139 }

◆ setUserId()

ilPublicUserProfileGUI::setUserId ( int  $a_userid)

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

68 : void
69 {
70 $this->userid = $a_userid;
71 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ validateUser()

static ilPublicUserProfileGUI::validateUser ( int  $usrId)
staticprotected

Check if given user id is valid.

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

763 : bool
764 {
765 global $DIC;
766
767 $ilUser = $DIC->user();
768 $ilCtrl = $DIC->ctrl();
769 if (ilObject::_lookupType($usrId) != "usr") {
770 return false;
771 }
772
773 $user = new ilObjUser($usrId);
774
775 if ($ilUser->isAnonymous()) {
776 if (strtolower($ilCtrl->getCmd()) == strtolower('approveContactRequest')) {
777 $ilCtrl->redirectToURL('login.php?cmd=force_login&target=usr_' . $usrId . '_contact_approved');
778 } elseif (strtolower($ilCtrl->getCmd()) == strtolower('ignoreContactRequest')) {
779 $ilCtrl->redirectToURL('login.php?cmd=force_login&target=usr_' . $usrId . '_contact_ignored');
780 }
781
782 if ($user->getPref("public_profile") != "g") {
783 // #12151
784 if ($user->getPref("public_profile") == "y") {
785 $ilCtrl->redirectToURL("login.php?cmd=force_login&target=usr_" . $usrId);
786 }
787
788 return false;
789 }
790 }
791
792 return true;
793 }
static _lookupType(int $id, bool $reference=false)

References $DIC, $ilUser, and ilObject\_lookupType().

+ Here is the call graph for this function:

◆ view()

ilPublicUserProfileGUI::view ( )

View.

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

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

188 : string
189 {
190 return $this->getHTML();
191 }

References getHTML().

+ Here is the call graph for this function:

Field Documentation

◆ $additional

array ilPublicUserProfileGUI::$additional = []
protected

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

Referenced by getAdditional(), and getEmbeddable().

◆ $backurl

string ilPublicUserProfileGUI::$backurl = ""
protected

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

Referenced by getBackUrl().

◆ $current_user

ilObjUser ilPublicUserProfileGUI::$current_user
protected

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

◆ $custom_prefs

array ilPublicUserProfileGUI::$custom_prefs = []
protected

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

◆ $embedded

bool ilPublicUserProfileGUI::$embedded = false
protected

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

◆ $offline

bool ilPublicUserProfileGUI::$offline = false
private

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

◆ $portfolioid

int ilPublicUserProfileGUI::$portfolioid = 0
protected

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

◆ $profile_request

ILIAS User ProfileGUIRequest ilPublicUserProfileGUI::$profile_request
protected

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

◆ $setting

ilSetting ilPublicUserProfileGUI::$setting
protected

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

Referenced by isProfilePublic().

◆ $user_defined_fields

ilUserDefinedFields ilPublicUserProfileGUI::$user_defined_fields
protected

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

◆ $userid

int ilPublicUserProfileGUI::$userid = 0
protected

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

Referenced by getUserId().


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