ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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...
 
 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
 

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$

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

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

34  {
35  global $DIC;
36 
37  $ilCtrl = $DIC['ilCtrl'];
38  $lng = $DIC['lng'];
39 
40  $this->current_user = $DIC->user();
41 
42  if ($a_user_id) {
43  $this->setUserId($a_user_id);
44  } else {
45  $this->setUserId((int) $_GET["user_id"]);
46  }
47 
48  $ilCtrl->saveParameter($this, array("user_id","back_url", "user"));
49  if ($_GET["back_url"] != "") {
50  $this->setBackUrl($_GET["back_url"]);
51  }
52 
53  $lng->loadLanguageModule("user");
54  }
global $DIC
Definition: saml.php:7
$_GET["client_id"]
setUserId($a_userid)
Set User ID.
global $ilCtrl
Definition: ilias.php:18
setBackUrl($a_backurl)
Set Back Link URL.
$lng
+ Here is the call graph for this function:

Member Function Documentation

◆ deliverVCard()

ilPublicUserProfileGUI::deliverVCard ( )

Deliver vcard information.

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

References $_GET, $key, $type, $user, ilObject\_exists(), ilUtil\deliverData(), ilObjMediaObject\getMimeType(), getUserId(), ilUtil\getWebspaceDir(), TEL_TYPE_CELL, TEL_TYPE_FAX, TEL_TYPE_HOME, and TEL_TYPE_WORK.

681  {
682  // get user object
683  if (!ilObject::_exists($this->getUserId())) {
684  return "";
685  }
686  $user = new ilObjUser($this->getUserId());
687 
688  require_once "./Services/User/classes/class.ilvCard.php";
689  $vcard = new ilvCard();
690 
691  // ilsharedresourceGUI: embedded in shared portfolio
692  if ($user->getPref("public_profile") != "y" &&
693  $user->getPref("public_profile") != "g" &&
694  $_GET["baseClass"] != "ilsharedresourceGUI" &&
695  $this->current_user->getId() != $this->getUserId()
696  ) {
697  return;
698  }
699 
700  $vcard->setName($user->getLastName(), $user->getFirstName(), "", $user->getUTitle());
701  $vcard->setNickname($user->getLogin());
702 
703  $webspace_dir = ilUtil::getWebspaceDir("output");
704  $imagefile = $webspace_dir . "/usr_images/" . $user->getPref("profile_image");
705  if ($user->getPref("public_upload") == "y" && @is_file($imagefile)) {
706  $fh = fopen($imagefile, "r");
707  if ($fh) {
708  $image = fread($fh, filesize($imagefile));
709  fclose($fh);
710  require_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
711  $mimetype = ilObjMediaObject::getMimeType($imagefile);
712  if (preg_match("/^image/", $mimetype)) {
713  $type = $mimetype;
714  }
715  $vcard->setPhoto($image, $type);
716  }
717  }
718 
719  $val_arr = array("getOrgUnitsRepresentation" => "org_units", "getInstitution" => "institution",
720  "getDepartment" => "department", "getStreet" => "street",
721  "getZipcode" => "zipcode", "getCity" => "city", "getCountry" => "country",
722  "getPhoneOffice" => "phone_office", "getPhoneHome" => "phone_home",
723  "getPhoneMobile" => "phone_mobile", "getFax" => "fax", "getEmail" => "email",
724  "getHobby" => "hobby", "getMatriculation" => "matriculation",
725  "getClientIP" => "client_ip", "dummy" => "location");
726 
727  $org = array();
728  $adr = array();
729  foreach ($val_arr as $key => $value) {
730  // if value "y" show information
731  if ($user->getPref("public_" . $value) == "y") {
732  switch ($value) {
733  case "institution":
734  $org[0] = $user->$key();
735  break;
736  case "department":
737  $org[1] = $user->$key();
738  break;
739  case "street":
740  $adr[2] = $user->$key();
741  break;
742  case "zipcode":
743  $adr[5] = $user->$key();
744  break;
745  case "city":
746  $adr[3] = $user->$key();
747  break;
748  case "country":
749  $adr[6] = $user->$key();
750  break;
751  case "phone_office":
752  $vcard->setPhone($user->$key(), TEL_TYPE_WORK);
753  break;
754  case "phone_home":
755  $vcard->setPhone($user->$key(), TEL_TYPE_HOME);
756  break;
757  case "phone_mobile":
758  $vcard->setPhone($user->$key(), TEL_TYPE_CELL);
759  break;
760  case "fax":
761  $vcard->setPhone($user->$key(), TEL_TYPE_FAX);
762  break;
763  case "email":
764  $vcard->setEmail($user->$key());
765  break;
766  case "hobby":
767  $vcard->setNote($user->$key());
768  break;
769  case "location":
770  $vcard->setPosition($user->getLatitude(), $user->getLongitude());
771  break;
772  }
773  }
774  }
775 
776  if (count($org)) {
777  $vcard->setOrganization(join(";", $org));
778  }
779  if (count($adr)) {
780  $vcard->setAddress($adr[0], $adr[1], $adr[2], $adr[3], $adr[4], $adr[5], $adr[6]);
781  }
782 
783  ilUtil::deliverData($vcard->buildVCard(), $vcard->getFilename(), $vcard->getMimetype());
784  }
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
static getMimeType($a_file, $a_external=null)
get mime type for file
$type
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
$_GET["client_id"]
const TEL_TYPE_FAX
const TEL_TYPE_HOME
const TEL_TYPE_WORK
const TEL_TYPE_CELL
$user
Definition: migrateto20.php:57
static getWebspaceDir($mode="filesystem")
get webspace directory
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ doProfileAutoComplete()

ilPublicUserProfileGUI::doProfileAutoComplete ( )
protected

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

References $DIC, $ilCtrl, $result, ilJsonUtil\encode(), exit, and getUserId().

896  {
897  $field_id = (string) $_REQUEST["f"];
898  $term = (string) $_REQUEST["term"];
899 
900  $result = self::getAutocompleteResult($field_id, $term);
901 
902  include_once 'Services/JSON/classes/class.ilJsonUtil.php';
904 
905  exit();
906  }
$result
static encode($mixed, $suppress_native=false)
exit
Definition: backend.php:16
+ Here is the call graph for this function:

◆ executeCommand()

ilPublicUserProfileGUI::executeCommand ( )

Execute Command.

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

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

194  {
195  global $DIC;
196 
197  $ilCtrl = $DIC['ilCtrl'];
198  $tpl = $DIC['tpl'];
199 
200  if (!self::validateUser($this->getUserId())) {
201  return;
202  }
203 
204  $next_class = $ilCtrl->getNextClass($this);
205  $cmd = $ilCtrl->getCmd();
206 
207  $tpl->getStandardTemplate();
208 
209  switch ($next_class) {
210  case "ilobjportfoliogui":
211  $portfolio_id = $this->getProfilePortfolio();
212  if ($portfolio_id) {
213  $this->handleBackUrl(true);
214 
215  include_once "Modules/Portfolio/classes/class.ilObjPortfolioGUI.php";
216  $gui = new ilObjPortfolioGUI($portfolio_id); // #11876
217  $gui->setAdditional($this->getAdditional());
218  $gui->setPermaLink($this->getUserId(), "usr");
219  $ilCtrl->forwardCommand($gui);
220  break;
221  }
222  // no break
223  case 'ilbuddysystemgui':
224  if (isset($_REQUEST['osd_id'])) {
225  require_once 'Services/Notifications/classes/class.ilNotificationOSDHandler.php';
227  }
228 
229  require_once 'Services/Contact/BuddySystem/classes/class.ilBuddySystemGUI.php';
230  $gui = new ilBuddySystemGUI();
231  $ilCtrl->setReturn($this, 'view');
232  $ilCtrl->forwardCommand($gui);
233  break;
234  default:
235  $ret = $this->$cmd();
236  $tpl->setContent($ret);
237  break;
238  }
239 
240  // only for direct links
241  if (strtolower($_GET["baseClass"]) == "ilpublicuserprofilegui") {
242  $tpl->show();
243  }
244  }
static removeNotification($notification_osd_id)
Removes a notifcation and triggers a follow up notification to remove the notification from the brows...
Class ilBuddySystemGUI.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
$tpl
Definition: ilias.php:10
getAdditional()
Get Additonal Information.
global $ilCtrl
Definition: ilias.php:18
getProfilePortfolio()
Check if current profile portfolio is accessible.
Portfolio view gui class.
$ret
Definition: parser.php:6
handleBackUrl($a_is_portfolio=false)
+ Here is the call graph for this function:

◆ getAdditional()

ilPublicUserProfileGUI::getAdditional ( )

Get Additonal Information.

Returns
array Additonal Information

Definition at line 91 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 857 of file class.ilPublicUserProfileGUI.php.

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

Referenced by ilAccountRegistrationGUI\doProfileAutoComplete().

858  {
859  global $DIC;
860 
861  $ilUser = $DIC['ilUser'];
862 
863  $multi_fields = array("interests_general", "interests_help_offered", "interests_help_looking");
864  if (in_array($a_field_id, $multi_fields) && $a_term) {
865  // registration has no current user
866  $user_id = null;
867  if ($ilUser && $ilUser->getId() && $ilUser->getId() != ANONYMOUS_USER_ID) {
868  $user_id = $ilUser->getId();
869  }
870 
871  $result = array();
872  $cnt = 0;
873 
874  // term is searched in ALL interest fields, no distinction
875  foreach (ilObjUser::findInterests($a_term, $ilUser->getId()) as $item) {
876  $result[$cnt] = new stdClass();
877  $result[$cnt]->value = $item;
878  $result[$cnt]->label = $item;
879  $cnt++;
880  }
881 
882  // :TODO: search in skill data
883  include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
884  foreach (ilSkillTreeNode::findSkills($a_term) as $skill) {
885  $result[$cnt] = new stdClass();
886  $result[$cnt]->value = $skill;
887  $result[$cnt]->label = $skill;
888  $cnt++;
889  }
890  }
891 
892  return $result;
893  }
$result
global $DIC
Definition: saml.php:7
static findSkills($a_term)
Find skills.
$ilUser
Definition: imgupload.php:18
static findInterests($a_term, $a_user_id=null, $a_field_id=null)
+ 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 122 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 310 of file class.ilPublicUserProfileGUI.php.

References $_SERVER, $additional, $DIC, $h, $ilCtrl, $ilSetting, $ilUser, $key, $lng, $title, $tpl, $user, ilObject\_exists(), ilUserDefinedFields\_getInstance(), ilLink\_getStaticLink(), ilObjUser\_isAnonymous(), ilDatePresentation\formatDate(), getAdditional(), ilObjPortfolio\getAvailablePortfolioLinksForUserIds(), getBackUrl(), ilPermanentLinkGUI\getHTML(), ilBuddySystemLinkButton\getInstanceByUserId(), ilBadgeAssignment\getInstancesByUserId(), ilMailFormCall\getLinkTarget(), ilMapUtil\getMapGUI(), getPublicPref(), getUserId(), ilUtil\getWebspaceDir(), IL_CAL_DATE, ilMapUtil\isActivated(), and ilWACSignedPath\signFile().

Referenced by getHTML().

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

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

Referenced by view().

258  {
259  global $DIC;
260 
261  $ilCtrl = $DIC['ilCtrl'];
262  $ilSetting = $DIC['ilSetting'];
263 
264  if ($this->embedded) {
265  return $this->getEmbeddable();
266  }
267 
268  // #15438 - (currently) inactive user?
269  $is_active = true;
270  $user = new ilObjUser($this->getUserId());
271  if (!$user->getActive() ||
272  !$user->checkTimeLimit()) {
273  $is_active = false;
274  }
275 
276  if ($is_active && $this->getProfilePortfolio()) {
277  $ilCtrl->redirectByClass("ilobjportfoliogui", "preview");
278  } else {
279  if (!$is_active) {
280  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
281  }
282 
283  // Check from Database if value
284  // of public_profile = "y" show user infomation
285  $user = new ilObjUser($this->getUserId());
286  $current = $user->getPref("public_profile");
287 
288  // #17462 - see ilPersonalProfileGUI::initPublicProfileForm()
289  if ($user->getPref("public_profile") == "g" && !$ilSetting->get('enable_global_profiles')) {
290  $current = "y";
291  }
292 
293  if ($current != "y" &&
294  ($current != "g" || !$ilSetting->get('enable_global_profiles')) &&
295  !$this->custom_prefs) {
296  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
297  }
298 
299  $this->renderTitle();
300 
301  return $this->getEmbeddable(true);
302  }
303  }
global $DIC
Definition: saml.php:7
global $ilCtrl
Definition: ilias.php:18
getProfilePortfolio()
Check if current profile portfolio is accessible.
$user
Definition: migrateto20.php:57
getEmbeddable($a_add_goto=false)
get public profile html code
global $ilSetting
Definition: privfeed.php:17
static redirect($a_script)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getProfilePortfolio()

ilPublicUserProfileGUI::getProfilePortfolio ( )
protected

Check if current profile portfolio is accessible.

Returns
int

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

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

Referenced by executeCommand(), and getHTML().

845  {
846  include_once "Modules/Portfolio/classes/class.ilObjPortfolio.php";
847  $portfolio_id = ilObjPortfolio::getDefaultPortfolio($this->getUserId());
848  if ($portfolio_id) {
849  include_once('./Modules/Portfolio/classes/class.ilPortfolioAccessHandler.php');
850  $access_handler = new ilPortfolioAccessHandler();
851  if ($access_handler->checkAccess("read", "", $portfolio_id)) {
852  return $portfolio_id;
853  }
854  }
855  }
Access handler for portfolio.
static getDefaultPortfolio($a_user_id)
Get default portfolio of user.
+ 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 175 of file class.ilPublicUserProfileGUI.php.

References ilObjUser\getPref().

Referenced by getEmbeddable().

176  {
177  if (!$this->custom_prefs) {
178  return $a_user->getPref($a_id);
179  } else {
180  return $this->custom_prefs[$a_id];
181  }
182  }
getPref($a_keyword)
get a user preference
+ 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 71 of file class.ilPublicUserProfileGUI.php.

References $userid.

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

+ Here is the caller graph for this function:

◆ handleBackUrl()

ilPublicUserProfileGUI::handleBackUrl (   $a_is_portfolio = false)
protected

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

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

Referenced by executeCommand(), and renderTitle().

128  {
129  global $DIC;
130 
131  $ilMainMenu = $DIC['ilMainMenu'];
132  $ilTabs = $DIC['ilTabs'];
133  $lng = $DIC['lng'];
134 
135  $back = ($this->getBackUrl() != "")
136  ? $this->getBackUrl()
137  : $_GET["back_url"];
138 
139  if (!$back) {
140  // #15984
141  $back = 'ilias.php?baseClass=ilPersonalDesktopGUI';
142  }
143 
144  if ((bool) $a_is_portfolio) {
145  $ilMainMenu->setTopBarBack($back);
146  } else {
147  // #17838
148  $ilTabs->clearTargets();
149  $ilTabs->setBackTarget(
150  $lng->txt("back"),
151  $back
152  );
153  }
154  }
global $DIC
Definition: saml.php:7
$_GET["client_id"]
$lng
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderTitle()

ilPublicUserProfileGUI::renderTitle ( )

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

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

Referenced by getHTML().

825  {
826  global $DIC;
827 
828  $tpl = $DIC['tpl'];
829 
830  $tpl->resetHeaderBlock();
831 
832  include_once("./Services/User/classes/class.ilUserUtil.php");
833  $tpl->setTitle(ilUserUtil::getNamePresentation($this->getUserId()));
834  $tpl->setTitleIcon(ilObjUser::_getPersonalPicturePath($this->getUserId(), "xsmall"));
835 
836  $this->handleBackUrl();
837  }
global $DIC
Definition: saml.php:7
$tpl
Definition: ilias.php:10
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:
handleBackUrl($a_is_portfolio=false)
+ 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 81 of file class.ilPublicUserProfileGUI.php.

82  {
83  $this->additional = $a_additional;
84  }

◆ setBackUrl()

ilPublicUserProfileGUI::setBackUrl (   $a_backurl)

Set Back Link URL.

Parameters
string$a_backurlBack Link URL

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

References $DIC, and $ilCtrl.

Referenced by __construct().

102  {
103  global $DIC;
104 
105  $ilCtrl = $DIC['ilCtrl'];
106 
107  // we only allow relative links
108  $parts = parse_url($a_backurl);
109  if ($parts["host"]) {
110  $a_backurl = "#";
111  }
112 
113  $this->backurl = $a_backurl;
114  $ilCtrl->setParameter($this, "back_url", rawurlencode($a_backurl));
115  }
global $DIC
Definition: saml.php:7
global $ilCtrl
Definition: ilias.php:18
+ 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 161 of file class.ilPublicUserProfileGUI.php.

162  {
163  $this->custom_prefs = $a_prefs;
164  }

◆ setEmbedded()

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

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

185  {
186  $this->embedded = (bool) $a_value;
187  $this->offline = (bool) $a_offline;
188  }

◆ setUserId()

ilPublicUserProfileGUI::setUserId (   $a_userid)

Set User ID.

Parameters
int$a_useridUser ID

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

Referenced by __construct().

62  {
63  $this->userid = $a_userid;
64  }
+ 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 791 of file class.ilPublicUserProfileGUI.php.

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

792  {
793  global $DIC;
794 
795  $ilUser = $DIC->user();
796  $ilCtrl = $DIC->ctrl();
797 
798  if (ilObject::_lookupType($usrId) != "usr") {
799  return false;
800  }
801 
802  $user = new ilObjUser($usrId);
803 
804  if ($ilUser->isAnonymous()) {
805  if (strtolower($ilCtrl->getCmd()) == strtolower('approveContactRequest')) {
806  $ilCtrl->redirectToURL('login.php?cmd=force_login&target=usr_' . $usrId . '_contact_approved');
807  } elseif (strtolower($ilCtrl->getCmd()) == strtolower('ignoreContactRequest')) {
808  $ilCtrl->redirectToURL('login.php?cmd=force_login&target=usr_' . $usrId . '_contact_ignored');
809  }
810 
811  if ($user->getPref("public_profile") != "g") {
812  // #12151
813  if ($user->getPref("public_profile") == "y") {
814  $ilCtrl->redirectToURL("login.php?cmd=force_login&target=usr_" . $usrId);
815  }
816 
817  return false;
818  }
819  }
820 
821  return true;
822  }
global $DIC
Definition: saml.php:7
global $ilCtrl
Definition: ilias.php:18
$ilUser
Definition: imgupload.php:18
$user
Definition: migrateto20.php:57
static _lookupType($a_id, $a_reference=false)
lookup object type
+ 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 249 of file class.ilPublicUserProfileGUI.php.

References getHTML().

250  {
251  return $this->getHTML();
252  }
+ 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.

◆ $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: