ILIAS  release_7 Revision v7.30-3-g800a261c036
ilPublicUserProfileGUI Class Reference

GUI class for public user profile presentation. More...

+ Collaboration diagram for ilPublicUserProfileGUI:

Public Member Functions

 __construct ($a_user_id=0)
 Constructor. More...
 
 setUserId ($a_userid)
 Set User ID. More...
 
 getUserId ()
 Get User ID. More...
 
 setAdditional ($a_additional)
 Set Additonal Information. More...
 
 getAdditional ()
 Get Additonal Information. More...
 
 setBackUrl ($a_backurl)
 Set Back Link URL. More...
 
 getBackUrl ()
 Get Back Link URL. More...
 
 setCustomPrefs (array $a_prefs)
 Set custom preferences for public profile fields. More...
 
 setEmbedded ($a_value, $a_offline=false)
 
 executeCommand ()
 Execute Command. More...
 
 view ()
 View. More...
 
 getHTML ()
 Show user page. More...
 
 getEmbeddable ($a_add_goto=false)
 get public profile html code More...
 
 deliverVCard ()
 Deliver vcard information. More...
 
 renderTitle ()
 

Static Public Member Functions

static getAutocompleteResult ($a_field_id, $a_term)
 

Protected Member Functions

 handleBackUrl ($a_is_portfolio=false)
 
 getPublicPref (ilObjUser $a_user, $a_id)
 Get user preference for public profile. More...
 
 isProfilePublic ()
 
 getProfilePortfolio ()
 Check if current profile portfolio is accessible. More...
 
 doProfileAutoComplete ()
 

Static Protected Member Functions

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

Protected Attributes

 $userid
 
 $portfolioid
 
 $backurl
 
 $additional
 
 $embedded
 
 $custom_prefs
 
 $current_user
 
 $setting
 

Detailed Description

GUI class for public user profile presentation.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

@ilCtrl_Calls ilPublicUserProfileGUI: ilObjPortfolioGUI

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

Constructor & Destructor Documentation

◆ __construct()

ilPublicUserProfileGUI::__construct (   $a_user_id = 0)

Constructor.

Parameters
intUser ID.

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 if ($a_user_id) {
49 $this->setUserId($a_user_id);
50 } else {
51 $this->setUserId((int) $_GET["user_id"]);
52 }
53
54 $ilCtrl->saveParameter($this, array("user_id","back_url", "user"));
55 if ($_GET["back_url"] != "") {
56 $this->setBackUrl($_GET["back_url"]);
57 }
58
59 $lng->loadLanguageModule("user");
60 }
$_GET["client_id"]
setBackUrl($a_backurl)
Set Back Link URL.
global $DIC
Definition: goto.php:24
$lng

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

+ Here is the call graph for this function:

Member Function Documentation

◆ deliverVCard()

ilPublicUserProfileGUI::deliverVCard ( )

Deliver vcard information.

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

729 {
730 // get user object
731 if (!ilObject::_exists($this->getUserId())) {
732 return "";
733 }
734 $user = new ilObjUser($this->getUserId());
735
736 require_once "./Services/User/classes/class.ilvCard.php";
737 $vcard = new ilvCard();
738
739 // ilsharedresourceGUI: embedded in shared portfolio
740 if ($user->getPref("public_profile") != "y" &&
741 $user->getPref("public_profile") != "g" &&
742 $_GET["baseClass"] != "ilsharedresourceGUI" &&
743 $this->current_user->getId() != $this->getUserId()
744 ) {
745 return;
746 }
747
748 $vcard->setName($user->getLastName(), $user->getFirstName(), "", $user->getUTitle());
749 $vcard->setNickname($user->getLogin());
750
751 $webspace_dir = ilUtil::getWebspaceDir("output");
752 $imagefile = $webspace_dir . "/usr_images/" . $user->getPref("profile_image");
753 if ($user->getPref("public_upload") == "y" && @is_file($imagefile)) {
754 $fh = fopen($imagefile, "r");
755 if ($fh) {
756 $image = fread($fh, filesize($imagefile));
757 fclose($fh);
758 require_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
759 $mimetype = ilObjMediaObject::getMimeType($imagefile);
760 if (preg_match("/^image/", $mimetype)) {
761 $type = $mimetype;
762 }
763 $vcard->setPhoto($image, $type);
764 }
765 }
766
767 $val_arr = array("getOrgUnitsRepresentation" => "org_units", "getInstitution" => "institution",
768 "getDepartment" => "department", "getStreet" => "street",
769 "getZipcode" => "zipcode", "getCity" => "city", "getCountry" => "country",
770 "getPhoneOffice" => "phone_office", "getPhoneHome" => "phone_home",
771 "getPhoneMobile" => "phone_mobile", "getFax" => "fax", "getEmail" => "email",
772 "getHobby" => "hobby", "getMatriculation" => "matriculation",
773 "getClientIP" => "client_ip", "dummy" => "location");
774
775 $org = array();
776 $adr = array();
777 foreach ($val_arr as $key => $value) {
778 // if value "y" show information
779 if ($user->getPref("public_" . $value) == "y") {
780 switch ($value) {
781 case "institution":
782 $org[0] = $user->$key();
783 break;
784 case "department":
785 $org[1] = $user->$key();
786 break;
787 case "street":
788 $adr[2] = $user->$key();
789 break;
790 case "zipcode":
791 $adr[5] = $user->$key();
792 break;
793 case "city":
794 $adr[3] = $user->$key();
795 break;
796 case "country":
797 $adr[6] = $user->$key();
798 break;
799 case "phone_office":
800 $vcard->setPhone($user->$key(), TEL_TYPE_WORK);
801 break;
802 case "phone_home":
803 $vcard->setPhone($user->$key(), TEL_TYPE_HOME);
804 break;
805 case "phone_mobile":
806 $vcard->setPhone($user->$key(), TEL_TYPE_CELL);
807 break;
808 case "fax":
809 $vcard->setPhone($user->$key(), TEL_TYPE_FAX);
810 break;
811 case "email":
812 $vcard->setEmail($user->$key());
813 break;
814 case "hobby":
815 $vcard->setNote($user->$key());
816 break;
817 case "location":
818 $vcard->setPosition($user->getLatitude(), $user->getLongitude());
819 break;
820 }
821 }
822 }
823
824 if (count($org)) {
825 $vcard->setOrganization(join(";", $org));
826 }
827 if (count($adr)) {
828 $vcard->setAddress($adr[0], $adr[1], $adr[2], $adr[3], $adr[4], $adr[5], $adr[6]);
829 }
830
831 ilUtil::deliverData($vcard->buildVCard(), $vcard->getFilename(), $vcard->getMimetype());
832 }
const TEL_TYPE_HOME
const TEL_TYPE_FAX
const TEL_TYPE_CELL
const TEL_TYPE_WORK
static getMimeType($a_file, $a_external=null)
get mime type for file
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public
static getWebspaceDir($mode="filesystem")
get webspace directory
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
$type

References $_GET, $type, ilObject\_exists(), ilUtil\deliverData(), ilObjMediaObject\getMimeType(), getUserId(), ilUtil\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 941 of file class.ilPublicUserProfileGUI.php.

942 {
943 $field_id = (string) $_REQUEST["f"];
944 $term = (string) $_REQUEST["term"];
945
946 $result = self::getAutocompleteResult($field_id, $term);
947
948 include_once 'Services/JSON/classes/class.ilJsonUtil.php';
950
951 exit();
952 }
$result
static encode($mixed, $suppress_native=false)
static getAutocompleteResult($a_field_id, $a_term)
exit
Definition: login.php:29

References $result, ilJsonUtil\encode(), exit, and getAutocompleteResult().

+ Here is the call graph for this function:

◆ executeCommand()

ilPublicUserProfileGUI::executeCommand ( )

Execute Command.

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

200 {
201 global $DIC;
202 $ilCtrl = $DIC['ilCtrl'];
203 $tpl = $DIC['tpl'];
204
205 if (!self::validateUser($this->getUserId())) {
206 return;
207 }
208 $next_class = $ilCtrl->getNextClass($this);
209 $cmd = $ilCtrl->getCmd();
210
211 $tpl->loadStandardTemplate();
212
213 switch ($next_class) {
214 case "ilobjportfoliogui":
215 $portfolio_id = $this->getProfilePortfolio();
216 if ($portfolio_id) {
217 $this->handleBackUrl(true);
218
219 include_once "Modules/Portfolio/classes/class.ilObjPortfolioGUI.php";
220 $gui = new ilObjPortfolioGUI($portfolio_id); // #11876
221 $gui->setAdditional($this->getAdditional());
222 $gui->setPermaLink($this->getUserId(), "usr");
223 $ilCtrl->forwardCommand($gui);
224 break;
225 }
226 // no break
227 case 'ilbuddysystemgui':
228 if (isset($_REQUEST['osd_id'])) {
229 require_once 'Services/Notifications/classes/class.ilNotificationOSDHandler.php';
231 }
232
233 require_once 'Services/Contact/BuddySystem/classes/class.ilBuddySystemGUI.php';
234 $gui = new ilBuddySystemGUI();
235 $ilCtrl->setReturn($this, 'view');
236 $ilCtrl->forwardCommand($gui);
237 break;
238 default:
239 $ret = $this->$cmd();
240 $tpl->setContent($ret);
241 break;
242 }
243
244 // only for direct links
245 if (strtolower($_GET["baseClass"]) == "ilpublicuserprofilegui") {
246 $tpl->printToStdout();
247 }
248 return $ret;
249 }
Class ilBuddySystemGUI.
static removeNotification($notification_osd_id)
Removes a notifcation and triggers a follow up notification to remove the notification from the brows...
Portfolio view gui class.
getAdditional()
Get Additonal Information.
handleBackUrl($a_is_portfolio=false)
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
$ret
Definition: parser.php:6

References $_GET, $DIC, $ret, $tpl, getAdditional(), getProfilePortfolio(), getUserId(), handleBackUrl(), and ilNotificationOSDHandler\removeNotification().

+ Here is the call graph for this function:

◆ getAdditional()

ilPublicUserProfileGUI::getAdditional ( )

Get Additonal Information.

Returns
array Additonal Information

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

References $additional.

Referenced by executeCommand(), and getEmbeddable().

+ Here is the caller graph for this function:

◆ getAutocompleteResult()

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

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

905 {
906 global $DIC;
907
908 $ilUser = $DIC['ilUser'];
909
910 $multi_fields = array("interests_general", "interests_help_offered", "interests_help_looking");
911 if (in_array($a_field_id, $multi_fields) && $a_term) {
912 // registration has no current user
913 $user_id = null;
914 if ($ilUser && $ilUser->getId() && $ilUser->getId() != ANONYMOUS_USER_ID) {
915 $user_id = $ilUser->getId();
916 }
917
918 $result = array();
919 $cnt = 0;
920
921 // term is searched in ALL interest fields, no distinction
922 foreach (ilObjUser::findInterests($a_term, $ilUser->getId()) as $item) {
923 $result[$cnt] = new stdClass();
924 $result[$cnt]->value = $item;
925 $result[$cnt]->label = $item;
926 $cnt++;
927 }
928
929 // :TODO: search in skill data
930 foreach (ilSkillTreeNode::findSkills($a_term) as $skill) {
931 $result[$cnt] = new stdClass();
932 $result[$cnt]->value = $skill;
933 $result[$cnt]->label = $skill;
934 $cnt++;
935 }
936 }
937
938 return $result;
939 }
static findInterests($a_term, $a_user_id=null, $a_field_id=null)
static findSkills($a_term)
Find skills.
const ANONYMOUS_USER_ID
Definition: constants.php:25
$ilUser
Definition: imgupload.php:18

References $DIC, $ilUser, $result, ANONYMOUS_USER_ID, ilObjUser\findInterests(), and ilSkillTreeNode\findSkills().

Referenced by ilAccountRegistrationGUI\doProfileAutoComplete(), and doProfileAutoComplete().

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

◆ getBackUrl()

ilPublicUserProfileGUI::getBackUrl ( )

Get Back Link URL.

Returns
string Back Link URL

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

References $backurl.

Referenced by getEmbeddable(), and handleBackUrl().

+ Here is the caller graph for this function:

◆ getEmbeddable()

ilPublicUserProfileGUI::getEmbeddable (   $a_add_goto = false)

get public profile html code

Used in Personal Profile (as preview) and Portfolio (as page block)

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

329 {
330 global $DIC;
331
332 $ilSetting = $DIC['ilSetting'];
333 $lng = $DIC['lng'];
334 $ilCtrl = $DIC['ilCtrl'];
335 $lng = $DIC['lng'];
336 $ilSetting = $DIC['ilSetting'];
337 $ilUser = $DIC['ilUser'];
338
339 // get user object
340 if (!ilObject::_exists($this->getUserId())) {
341 return "";
342 }
343 $user = new ilObjUser($this->getUserId());
344
345 $tpl = new ilTemplate(
346 "tpl.usr_public_profile.html",
347 true,
348 true,
349 "Services/User"
350 );
351
352
353 $tpl->setVariable("ROWCOL1", "tblrow1");
354 $tpl->setVariable("ROWCOL2", "tblrow2");
355
356 if (!$this->offline && $ilUser->getId() != ANONYMOUS_USER_ID) {
357 $ref_url = str_replace("&", "&", $this->getBackUrl());
358 if (!$ref_url) {
359 $ref_url = basename($_SERVER['REQUEST_URI']);
360 }
361
362 $mail_url = '';
363 if ($DIC->rbac()->system()->checkAccess('internal_mail', ilMailGlobalServices::getMailObjectRefId())) {
365 $ref_url,
366 '',
367 [],
368 [
369 'type' => 'new',
370 'rcp_to' => $user->getLogin()
371 ]
372 );
373 } elseif ($user->getPref('public_profile') === 'g' ||
374 (!$ilUser->isAnonymous() && $user->getPref('public_profile') === 'y') &&
375 $user->getPref('public_email') &&
376 $user->getEmail() !== '') {
377 $mail_url = 'mailto:' . $user->getEmail();
378 }
379
380 if ($mail_url !== '') {
381 $tpl->setCurrentBlock("mail");
382 $tpl->setVariable("TXT_MAIL", $lng->txt("send_mail"));
383 $tpl->setVariable('HREF_MAIL', $mail_url);
384 $tpl->parseCurrentBlock();
385 }
386 }
387
388
389 // short version, fixes e.g. #27242
390 if (!$this->isProfilePublic()) {
391 $tpl->setVariable("TXT_NAME", $lng->txt("name"));
392 $tpl->setVariable("FIRSTNAME", ilUserUtil::getNamePresentation($user->getId()));
393 return $tpl->get();
394 }
395
396 $first_name = "";
397 if ($this->getPublicPref($user, "public_title") == "y") {
398 $first_name .= $user->getUTitle() . " ";
399 }
400 $first_name .= $user->getFirstName();
401
402 if ($this->getPublicPref($user, "public_gender") == "y" && in_array($user->getGender(), ['m', 'f'])) {
403 $sal = $lng->txt("salutation_" . $user->getGender()) . " ";
404 $tpl->setVariable("SALUTATION", $sal);
405 }
406
407 $tpl->setVariable("TXT_NAME", $lng->txt("name"));
408 $tpl->setVariable("FIRSTNAME", $first_name);
409 $tpl->setVariable("LASTNAME", $user->getLastName());
410
411 if ($user->getBirthday() &&
412 $this->getPublicPref($user, "public_birthday") == "y") {
413 // #17574
414 $tpl->setCurrentBlock("bday_bl");
415 $tpl->setVariable("TXT_BIRTHDAY", $lng->txt("birthday"));
416 $tpl->setVariable("VAL_BIRTHDAY", ilDatePresentation::formatDate(new ilDate($user->getBirthday(), IL_CAL_DATE)));
417 $tpl->parseCurrentBlock();
418 }
419
420 if (!$this->offline) {
421 // vcard
422 $tpl->setCurrentBlock("vcard");
423 $tpl->setVariable("TXT_VCARD", $lng->txt("vcard"));
424 $tpl->setVariable("TXT_DOWNLOAD_VCARD", $lng->txt("vcard_download"));
425 $ilCtrl->setParameter($this, "user_id", $this->getUserId());
426 $tpl->setVariable("HREF_VCARD", $ilCtrl->getLinkTarget($this, "deliverVCard"));
427 }
428
429 $webspace_dir = ilUtil::getWebspaceDir("user");
430 $check_dir = ilUtil::getWebspaceDir();
431 $random = new \ilRandom();
432 $imagefile = $webspace_dir . "/usr_images/" . $user->getPref("profile_image") . "?dummy=" . $random->int(1, 999999);
433 $check_file = $check_dir . "/usr_images/" . $user->getPref("profile_image");
434
435 if (!@is_file($check_file)) {
436 $imagefile = $check_file =
437 ilObjUser::_getPersonalPicturePath($user->getId(), "small", false, true);
438 } else {
439 if ($this->offline) {
440 $imagefile = basename($imagefile);
441 } else {
442 $imagefile = ilWACSignedPath::signFile($imagefile . "?t=1");
443 }
444 }
445
446 if ($this->getPublicPref($user, "public_upload") == "y" && $imagefile != "" &&
447 ($ilUser->getId() != ANONYMOUS_USER_ID || $user->getPref("public_profile") == "g")) {
448 //Getting the flexible path of image form ini file
449 //$webspace_dir = ilUtil::getWebspaceDir("output");
450 $tpl->setCurrentBlock("image");
451 $tpl->setVariable("TXT_IMAGE", $lng->txt("image"));
452 $tpl->setVariable("IMAGE_PATH", $imagefile);
453 $tpl->setVariable("IMAGE_ALT", $lng->txt("personal_picture"));
454 $tpl->parseCurrentBlock();
455 }
456
457 // address
458 if ($this->getPublicPref($user, "public_street") == "y" ||
459 $this->getPublicPref($user, "public_zipcode") == "y" ||
460 $this->getPublicPref($user, "public_city") == "y" ||
461 $this->getPublicPref($user, "public_country") == "y") {
462 $address = array();
463 $val_arr = array("getStreet" => "street",
464 "getZipcode" => "zipcode",
465 "getCity" => "city",
466 "getCountry" => "country",
467 "getSelectedCountry" => "sel_country");
468 foreach ($val_arr as $key => $value) {
469 // if value "y" show information
470 if ($this->getPublicPref($user, "public_" . $value) == "y") {
471 $address_value = $user->$key();
472
473 // only if set
474 if (trim($address_value) != "") {
475 switch ($value) {
476 case "street":
477 $address[0] = $address_value;
478 break;
479
480 case "zipcode":
481 case "city":
482 $address[1] .= " " . $address_value;
483 break;
484
485 case "sel_country":
486 $lng->loadLanguageModule("meta");
487 $address[2] = $lng->txt("meta_c_" . $address_value);
488 break;
489
490 case "country":
491 $address[2] = $address_value;
492 break;
493 }
494 }
495 }
496 }
497 if (sizeof($address)) {
498 $tpl->setCurrentBlock("address_line");
499 foreach ($address as $line) {
500 if (trim($line)) {
501 $tpl->setVariable("TXT_ADDRESS_LINE", trim($line));
502 $tpl->parseCurrentBlock();
503 }
504 }
505 $tpl->setCurrentBlock("address");
506 $tpl->setVariable("TXT_ADDRESS", $lng->txt("address"));
507 $tpl->parseCurrentBlock();
508 }
509 }
510
511 // if value "y" show information
512 if ($this->getPublicPref($user, "public_org_units") == "y") {
513 $tpl->setCurrentBlock("org_units");
514 $tpl->setVariable("TXT_ORG_UNITS", $lng->txt("objs_orgu"));
515 $tpl->setVariable("ORG_UNITS", $user->getOrgUnitsRepresentation());
516 $tpl->parseCurrentBlock();
517 }
518
519 // institution / department
520 if ($this->getPublicPref($user, "public_institution") == "y" ||
521 $this->getPublicPref($user, "public_department") == "y") {
522 $tpl->setCurrentBlock("inst_dep");
523 $sep = "";
524 if ($this->getPublicPref($user, "public_institution") == "y") {
525 $h = $lng->txt("institution");
526 $v = $user->getInstitution();
527 $sep = " / ";
528 }
529 if ($this->getPublicPref($user, "public_department") == "y") {
530 $h .= $sep . $lng->txt("department");
531 $v .= $sep . $user->getDepartment();
532 }
533 $tpl->setVariable("TXT_INST_DEP", $h);
534 $tpl->setVariable("INST_DEP", $v);
535 $tpl->parseCurrentBlock();
536 }
537
538 // contact
539 $val_arr = array(
540 "getPhoneOffice" => "phone_office", "getPhoneHome" => "phone_home",
541 "getPhoneMobile" => "phone_mobile", "getFax" => "fax", "getEmail" => "email", "getSecondEmail" => "second_email");
542 $v = $sep = "";
543 foreach ($val_arr as $key => $value) {
544 // if value "y" show information
545 if ($this->getPublicPref($user, "public_" . $value) == "y") {
546 $v .= $sep . $lng->txt($value) . ": " . $user->$key();
547 $sep = "<br />";
548 }
549 }
550 if ($v != "") {
551 $tpl->parseCurrentBlock("contact");
552 $tpl->setVariable("TXT_CONTACT", $lng->txt("contact"));
553 $tpl->setVariable("CONTACT", $v);
554 $tpl->parseCurrentBlock();
555 }
556
557
558 $val_arr = array(
559 "getHobby" => "hobby",
560 "getGeneralInterestsAsText" => "interests_general",
561 "getOfferingHelpAsText" => "interests_help_offered",
562 "getLookingForHelpAsText" => "interests_help_looking",
563 "getMatriculation" => "matriculation",
564 "getClientIP" => "client_ip");
565
566 foreach ($val_arr as $key => $value) {
567 // if value "y" show information
568 if ($this->getPublicPref($user, "public_" . $value) == "y") {
569 $tpl->setCurrentBlock("profile_data");
570 $tpl->setVariable("TXT_DATA", $lng->txt($value));
571 $tpl->setVariable("DATA", $user->$key());
572 $tpl->parseCurrentBlock();
573 }
574 }
575
576 // portfolios
577 include_once("./Services/Link/classes/class.ilLink.php");
578 include_once("./Modules/Portfolio/classes/class.ilObjPortfolio.php");
579 $back = ($this->getBackUrl() != "")
580 ? $this->getBackUrl()
581 : ilLink::_getStaticLink($this->getUserId(), "usr", true);
583 $cnt = 0;
584 if (count($port) > 0) {
585 foreach ($port as $u) {
586 $tpl->setCurrentBlock("portfolio");
587 foreach ($u as $link => $title) {
588 $cnt++;
589 $tpl->setVariable("HREF_PORTFOLIO", $link);
590 $tpl->setVariable("TITLE_PORTFOLIO", $title);
591 $tpl->parseCurrentBlock();
592 }
593 }
594 $tpl->setCurrentBlock("portfolios");
595 if ($cnt > 1) {
596 $lng->loadLanguageModule("prtf");
597 $tpl->setVariable("TXT_PORTFOLIO", $lng->txt("prtf_portfolios"));
598 } else {
599 $tpl->setVariable("TXT_PORTFOLIO", $lng->txt("portfolio"));
600 }
601 $tpl->parseCurrentBlock();
602 }
603
604 // map
605 include_once("./Services/Maps/classes/class.ilMapUtil.php");
607 $this->getPublicPref($user, "public_location") == "y" &&
608 $user->getLatitude() != "") {
609 $tpl->setVariable("TXT_LOCATION", $lng->txt("location"));
610
611 $map_gui = ilMapUtil::getMapGUI();
612 $map_gui->setMapId("user_map")
613 ->setWidth("350px")
614 ->setHeight("230px")
615 ->setLatitude($user->getLatitude())
616 ->setLongitude($user->getLongitude())
617 ->setZoom($user->getLocationZoom())
618 ->setEnableNavigationControl(true)
619 ->addUserMarker($user->getId());
620
621 $tpl->setVariable("MAP_CONTENT", $map_gui->getHTML());
622 }
623
624 // additional defined user data fields
625 include_once './Services/User/classes/class.ilUserDefinedFields.php';
626 $this->user_defined_fields = &ilUserDefinedFields::_getInstance();
627 $user_defined_data = $user->getUserDefinedData();
628 foreach ($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition) {
629 // public setting
630 if ($this->getPublicPref($user, "public_udf_" . $definition["field_id"]) == "y") {
631 if ($user_defined_data["f_" . $definition["field_id"]] != "") {
632 $tpl->setCurrentBlock("udf_data");
633 $tpl->setVariable("TXT_UDF_DATA", $definition["field_name"]);
634 $tpl->setVariable("UDF_DATA", $user_defined_data["f_" . $definition["field_id"]]);
635 $tpl->parseCurrentBlock();
636 }
637 }
638 }
639
640 // additional information
641 $additional = $this->getAdditional();
642 if (is_array($additional)) {
643 foreach ($additional as $key => $val) {
644 $tpl->setCurrentBlock("profile_data");
645 $tpl->setVariable("TXT_DATA", $key);
646 $tpl->setVariable("DATA", $val);
647 $tpl->parseCurrentBlock();
648 }
649 }
650
651 if (
652 $this->getUserId() != $ilUser->getId() &&
653 !$ilUser->isAnonymous() &&
654 !ilObjUser::_isAnonymous($this->getUserId())
655 ) {
656 require_once 'Services/Contact/BuddySystem/classes/class.ilBuddySystemLinkButton.php';
657 $button = ilBuddySystemLinkButton::getInstanceByUserId((int) $user->getId());
658 $tpl->setVariable('BUDDY_HTML', $button->getHtml());
659 }
660
661 // badges
662 include_once "Services/Badge/classes/class.ilBadgeAssignment.php";
663 $user_badges = ilBadgeAssignment::getInstancesByUserId($user->getId());
664 if ($user_badges) {
665 $has_public_badge = false;
666 $cnt = 0;
667
668 $cut = 20;
669
670 include_once "Services/Badge/classes/class.ilBadgeRenderer.php";
671 foreach ($user_badges as $ass) {
672 // only active
673 if ($ass->getPosition()) {
674 $cnt++;
675
676 $renderer = new ilBadgeRenderer($ass);
677
678 // limit to 20, [MORE] link
679 if ($cnt <= $cut) {
680 $tpl->setCurrentBlock("badge_bl");
681 $tpl->setVariable("BADGE", $renderer->getHTML());
682 $tpl->parseCurrentBlock();
683 } else {
684 $tpl->setCurrentBlock("badge_hidden_item_bl");
685 $tpl->setVariable("BADGE_HIDDEN", $renderer->getHTML());
686 $tpl->parseCurrentBlock();
687 }
688
689 $has_public_badge = true;
690 }
691 }
692
693 if ($cnt > $cut) {
694 $lng->loadLanguageModule("badge");
695 $tpl->setVariable("BADGE_HIDDEN_TXT_MORE", $lng->txt("badge_profile_more"));
696 $tpl->setVariable("BADGE_HIDDEN_TXT_LESS", $lng->txt("badge_profile_less"));
697 $tpl->touchBlock("badge_js_bl");
698 }
699
700 if ($has_public_badge) {
701 $tpl->setVariable("TXT_BADGES", $lng->txt("obj_bdga"));
702 }
703 }
704
705 $goto = "";
706 if ($a_add_goto) {
707 global $DIC;
708
709 $mtpl = $DIC->ui()->mainTemplate();
710
711 $mtpl->setPermanentLink(
712 "usr",
713 $user->getId(),
714 "",
715 "_top"
716 );
717
718 /*include_once('Services/PermanentLink/classes/class.ilPermanentLinkGUI.php');
719 $goto = new ilPermanentLinkGUI("usr", $user->getId());
720 $goto = $goto->getHTML();*/
721 }
722 return $tpl->get() . $goto;
723 }
const IL_CAL_DATE
static getInstancesByUserId($a_user_id)
Class ilBadgeRenderer.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
Class for single dates.
static getLinkTarget( $gui, string $cmd, array $gui_params=[], array $mail_params=[], $context_params=[])
static getMailObjectRefId()
Determines the reference id of the mail object and stores this information in a local cache variable.
static isActivated()
Checks whether Map feature is activated.
static getMapGUI()
Get an instance of the GUI class.
static getAvailablePortfolioLinksForUserIds(array $a_owner_ids, $a_back_url=null)
static _getPersonalPicturePath( $a_usr_id, $a_size="small", $a_force_pic=false, $a_prevent_no_photo_image=false, $html_export=false)
Get path to personal picture.
static _isAnonymous($usr_id)
getPublicPref(ilObjUser $a_user, $a_id)
Get user preference for public profile.
special template class to simplify handling of ITX/PEAR
static _getInstance()
Get instance.
static getNamePresentation( $a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
static signFile($path_to_file)
global $ilSetting
Definition: privfeed.php:17
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10

References $_SERVER, $additional, $DIC, $ilSetting, $ilUser, $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(), ilUtil\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 ( )

Show user page.

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

278 {
279 global $DIC;
280 $ilCtrl = $DIC['ilCtrl'];
281 $ilSetting = $DIC['ilSetting'];
282
283 if ($this->embedded) {
284 return $this->getEmbeddable();
285 }
286
287 // #15438 - (currently) inactive user?
288 $is_active = true;
289 $user = new ilObjUser($this->getUserId());
290 if (!$user->getActive() ||
291 !$user->checkTimeLimit()) {
292 $is_active = false;
293 }
294
295 if ($is_active && $this->getProfilePortfolio()) {
296 $ilCtrl->redirectByClass("ilobjportfoliogui", "preview");
297 } else {
298 if (!$is_active) {
299 ilUtil::redirect('ilias.php?baseClass=ilDashboardGUI');
300 }
301
302 // Check from Database if value
303 // of public_profile = "y" show user infomation
304 $user = new ilObjUser($this->getUserId());
305 $current = $user->getPref("public_profile");
306 // #17462 - see ilPersonalProfileGUI::initPublicProfileForm()
307 if ($user->getPref("public_profile") == "g" && !$ilSetting->get('enable_global_profiles')) {
308 $current = "y";
309 }
310
311 if ($current != "y" &&
312 ($current != "g" || !$ilSetting->get('enable_global_profiles')) &&
313 !$this->custom_prefs) {
314 ilUtil::redirect('ilias.php?baseClass=ilDashboardGUI');
315 }
316
317 $this->renderTitle();
318 return $this->getEmbeddable(true);
319 }
320 }
getEmbeddable($a_add_goto=false)
get public profile html code
static redirect($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.

Returns
int

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

892 {
893 include_once "Modules/Portfolio/classes/class.ilObjPortfolio.php";
894 $portfolio_id = ilObjPortfolio::getDefaultPortfolio($this->getUserId());
895 if ($portfolio_id) {
896 include_once('./Modules/Portfolio/classes/class.ilPortfolioAccessHandler.php');
897 $access_handler = new ilPortfolioAccessHandler();
898 if ($access_handler->checkAccess("read", "", $portfolio_id)) {
899 return $portfolio_id;
900 }
901 }
902 }
static getDefaultPortfolio($a_user_id)
Get default portfolio of user.
Access handler for portfolio.

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,
  $a_id 
)
protected

Get user preference for public profile.

Will use original or custom preferences

Parameters
ilObjUser$a_user
string$a_id
Returns
string

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

182 {
183 if (!$this->custom_prefs) {
184 return $a_user->getPref($a_id);
185 } else {
186 return $this->custom_prefs[$a_id];
187 }
188 }
getPref($a_keyword)
get a user preference

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 ( )

Get User ID.

Returns
int User ID

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

References $userid.

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

+ Here is the caller graph for this function:

◆ handleBackUrl()

ilPublicUserProfileGUI::handleBackUrl (   $a_is_portfolio = false)
protected

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

134 {
135 global $DIC;
136
137 $ilMainMenu = $DIC['ilMainMenu'];
138 $ilTabs = $DIC['ilTabs'];
139 $lng = $DIC['lng'];
140
141 $back = ($this->getBackUrl() != "")
142 ? $this->getBackUrl()
143 : $_GET["back_url"];
144
145 if (!$back) {
146 // #15984
147 $back = 'ilias.php?baseClass=ilDashboardGUI';
148 }
149
150 if ((bool) $a_is_portfolio) {
151 $ilMainMenu->setTopBarBack($back);
152 } else {
153 // #17838
154 $ilTabs->clearTargets();
155 $ilTabs->setBackTarget(
156 $lng->txt("back"),
157 $back
158 );
159 }
160 }

References $_GET, $DIC, $lng, and getBackUrl().

Referenced by executeCommand(), and renderTitle().

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

◆ isProfilePublic()

ilPublicUserProfileGUI::isProfilePublic ( )
protected
Returns
bool

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

263 {
265 $user = new ilObjUser($this->getUserId());
266 $current = $user->getPref("public_profile");
267 // #17462 - see ilPersonalProfileGUI::initPublicProfileForm()
268 if ($user->getPref("public_profile") == "g" && !$setting->get('enable_global_profiles')) {
269 $current = "y";
270 }
271 return in_array($current, ["g", "y"]);
272 }

References $setting, 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 871 of file class.ilPublicUserProfileGUI.php.

872 {
873 global $DIC;
874
875 $tpl = $DIC['tpl'];
876
877 $tpl->resetHeaderBlock();
878
879 include_once("./Services/User/classes/class.ilUserUtil.php");
881 $tpl->setTitleIcon(ilObjUser::_getPersonalPicturePath($this->getUserId(), "xsmall"));
882
883 $this->handleBackUrl();
884 }

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

Referenced by getHTML().

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

◆ setAdditional()

ilPublicUserProfileGUI::setAdditional (   $a_additional)

Set Additonal Information.

Parameters
array$a_additionalAdditonal Information

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

88 {
89 $this->additional = $a_additional;
90 }

◆ setBackUrl()

ilPublicUserProfileGUI::setBackUrl (   $a_backurl)

Set Back Link URL.

Parameters
string$a_backurlBack Link URL

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

108 {
109 global $DIC;
110
111 $ilCtrl = $DIC['ilCtrl'];
112
113 // we only allow relative links
114 $parts = parse_url($a_backurl);
115 if ($parts["host"]) {
116 $a_backurl = "#";
117 }
118
119 $this->backurl = $a_backurl;
120 $ilCtrl->setParameter($this, "back_url", rawurlencode($a_backurl));
121 }

References $DIC.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setCustomPrefs()

ilPublicUserProfileGUI::setCustomPrefs ( array  $a_prefs)

Set custom preferences for public profile fields.

Parameters
array$a_prefs

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

168 {
169 $this->custom_prefs = $a_prefs;
170 }

◆ setEmbedded()

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

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

191 {
192 $this->embedded = (bool) $a_value;
193 $this->offline = (bool) $a_offline;
194 }

◆ setUserId()

ilPublicUserProfileGUI::setUserId (   $a_userid)

Set User ID.

Parameters
int$a_useridUser ID

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

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

Referenced by __construct().

+ Here is the caller graph for this function:

◆ validateUser()

static ilPublicUserProfileGUI::validateUser (   $usrId)
staticprotected

Check if given user id is valid.

Parameters
int$usrIdThe user id of the subject user
Returns
bool

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

840 {
841 global $DIC;
842
843 $ilUser = $DIC->user();
844 $ilCtrl = $DIC->ctrl();
845 if (ilObject::_lookupType($usrId) != "usr") {
846 return false;
847 }
848
849 $user = new ilObjUser($usrId);
850
851 if ($ilUser->isAnonymous()) {
852 if (strtolower($ilCtrl->getCmd()) == strtolower('approveContactRequest')) {
853 $ilCtrl->redirectToURL('login.php?cmd=force_login&target=usr_' . $usrId . '_contact_approved');
854 } elseif (strtolower($ilCtrl->getCmd()) == strtolower('ignoreContactRequest')) {
855 $ilCtrl->redirectToURL('login.php?cmd=force_login&target=usr_' . $usrId . '_contact_ignored');
856 }
857
858 if ($user->getPref("public_profile") != "g") {
859 // #12151
860 if ($user->getPref("public_profile") == "y") {
861 $ilCtrl->redirectToURL("login.php?cmd=force_login&target=usr_" . $usrId);
862 }
863
864 return false;
865 }
866 }
867
868 return true;
869 }
static _lookupType($a_id, $a_reference=false)
lookup object type

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

255 {
256 return $this->getHTML();
257 }

References getHTML().

+ Here is the call graph for this function:

Field Documentation

◆ $additional

ilPublicUserProfileGUI::$additional
protected

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

Referenced by getAdditional(), and getEmbeddable().

◆ $backurl

ilPublicUserProfileGUI::$backurl
protected

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

Referenced by getBackUrl().

◆ $current_user

ilPublicUserProfileGUI::$current_user
protected

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

◆ $custom_prefs

ilPublicUserProfileGUI::$custom_prefs
protected

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

◆ $embedded

ilPublicUserProfileGUI::$embedded
protected

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

◆ $portfolioid

ilPublicUserProfileGUI::$portfolioid
protected

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

◆ $setting

ilPublicUserProfileGUI::$setting
protected

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

Referenced by isProfilePublic().

◆ $userid

ilPublicUserProfileGUI::$userid
protected

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

Referenced by getUserId().


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