ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilPublicUserProfileGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
15{
16 protected $userid; // [int]
17 protected $portfolioid; // [int]
18 protected $backurl; // [string]
19 protected $additional; // [string] used in forum
20 protected $embedded; // [bool] used in portfolio
21 protected $custom_prefs; // [array] used in portfolio
22
26 protected $current_user;
27
31 protected $setting;
32
38 public function __construct($a_user_id = 0)
39 {
40 global $DIC;
41
42 $ilCtrl = $DIC['ilCtrl'];
43 $lng = $DIC['lng'];
44
45 $this->current_user = $DIC->user();
46
47 $this->setting = $DIC["ilSetting"];
48
49 if ($a_user_id) {
50 $this->setUserId($a_user_id);
51 } else {
52 $this->setUserId((int) $_GET["user_id"]);
53 }
54
55 $ilCtrl->saveParameter($this, array("user_id","back_url", "user"));
56 if ($_GET["back_url"] != "") {
57 $this->setBackUrl($_GET["back_url"]);
58 }
59
60 $lng->loadLanguageModule("user");
61 }
62
68 public function setUserId($a_userid)
69 {
70 $this->userid = $a_userid;
71 }
72
78 public function getUserId()
79 {
80 return $this->userid;
81 }
82
88 public function setAdditional($a_additional)
89 {
90 $this->additional = $a_additional;
91 }
92
98 public function getAdditional()
99 {
100 return $this->additional;
101 }
102
108 public function setBackUrl($a_backurl)
109 {
110 global $DIC;
111
112 $ilCtrl = $DIC['ilCtrl'];
113
114 // we only allow relative links
115 $parts = parse_url($a_backurl);
116 if ($parts["host"]) {
117 $a_backurl = "#";
118 }
119
120 $this->backurl = $a_backurl;
121 $ilCtrl->setParameter($this, "back_url", rawurlencode($a_backurl));
122 }
123
129 public function getBackUrl()
130 {
131 return $this->backurl;
132 }
133
134 protected function handleBackUrl($a_is_portfolio = false)
135 {
136 global $DIC;
137
138 $ilMainMenu = $DIC['ilMainMenu'];
139 $ilTabs = $DIC['ilTabs'];
140 $lng = $DIC['lng'];
141
142 $back = ($this->getBackUrl() != "")
143 ? $this->getBackUrl()
144 : $_GET["back_url"];
145
146 if (!$back) {
147 // #15984
148 $back = 'ilias.php?baseClass=ilDashboardGUI';
149 }
150
151 if ((bool) $a_is_portfolio) {
152 $ilMainMenu->setTopBarBack($back);
153 } else {
154 // #17838
155 $ilTabs->clearTargets();
156 $ilTabs->setBackTarget(
157 $lng->txt("back"),
158 $back
159 );
160 }
161 }
162
168 public function setCustomPrefs(array $a_prefs)
169 {
170 $this->custom_prefs = $a_prefs;
171 }
172
182 protected function getPublicPref(ilObjUser $a_user, $a_id)
183 {
184 if (!$this->custom_prefs) {
185 return $a_user->getPref($a_id);
186 } else {
187 return $this->custom_prefs[$a_id];
188 }
189 }
190
191 public function setEmbedded($a_value, $a_offline = false)
192 {
193 $this->embedded = (bool) $a_value;
194 $this->offline = (bool) $a_offline;
195 }
196
200 public function executeCommand()
201 {
202 global $DIC;
203
204 $ilCtrl = $DIC['ilCtrl'];
205 $tpl = $DIC['tpl'];
206
207 if (!self::validateUser($this->getUserId())) {
208 return;
209 }
210
211 $next_class = $ilCtrl->getNextClass($this);
212 $cmd = $ilCtrl->getCmd();
213
214 $tpl->loadStandardTemplate();
215
216 switch ($next_class) {
217 case "ilobjportfoliogui":
218 $portfolio_id = $this->getProfilePortfolio();
219 if ($portfolio_id) {
220 $this->handleBackUrl(true);
221
222 include_once "Modules/Portfolio/classes/class.ilObjPortfolioGUI.php";
223 $gui = new ilObjPortfolioGUI($portfolio_id); // #11876
224 $gui->setAdditional($this->getAdditional());
225 $gui->setPermaLink($this->getUserId(), "usr");
226 $ilCtrl->forwardCommand($gui);
227 break;
228 }
229 // no break
230 case 'ilbuddysystemgui':
231 if (isset($_REQUEST['osd_id'])) {
232 require_once 'Services/Notifications/classes/class.ilNotificationOSDHandler.php';
234 }
235
236 require_once 'Services/Contact/BuddySystem/classes/class.ilBuddySystemGUI.php';
237 $gui = new ilBuddySystemGUI();
238 $ilCtrl->setReturn($this, 'view');
239 $ilCtrl->forwardCommand($gui);
240 break;
241 default:
242 $ret = $this->$cmd();
243 $tpl->setContent($ret);
244 break;
245 }
246
247 // only for direct links
248 if (strtolower($_GET["baseClass"]) == "ilpublicuserprofilegui") {
249 $tpl->printToStdout();
250 }
251 return $ret;
252 }
253
257 public function view()
258 {
259 return $this->getHTML();
260 }
261
265 protected function isProfilePublic()
266 {
268 $user = new ilObjUser($this->getUserId());
269 $current = $user->getPref("public_profile");
270 // #17462 - see ilPersonalProfileGUI::initPublicProfileForm()
271 if ($user->getPref("public_profile") == "g" && !$setting->get('enable_global_profiles')) {
272 $current = "y";
273 }
274 return in_array($current, ["g", "y"]);
275 }
276
280 public function getHTML()
281 {
282 global $DIC;
283 $ilCtrl = $DIC['ilCtrl'];
284 $ilSetting = $DIC['ilSetting'];
285
286 if ($this->embedded) {
287 return $this->getEmbeddable();
288 }
289
290 // #15438 - (currently) inactive user?
291 $is_active = true;
292 $user = new ilObjUser($this->getUserId());
293 if (!$user->getActive() ||
294 !$user->checkTimeLimit()) {
295 $is_active = false;
296 }
297
298 if ($is_active && $this->getProfilePortfolio()) {
299 $ilCtrl->redirectByClass("ilobjportfoliogui", "preview");
300 } else {
301 if (!$is_active) {
302 ilUtil::redirect('ilias.php?baseClass=ilDashboardGUI');
303 }
304
305 // Check from Database if value
306 // of public_profile = "y" show user infomation
307 $user = new ilObjUser($this->getUserId());
308 $current = $user->getPref("public_profile");
309 // #17462 - see ilPersonalProfileGUI::initPublicProfileForm()
310 if ($user->getPref("public_profile") == "g" && !$ilSetting->get('enable_global_profiles')) {
311 $current = "y";
312 }
313
314 if ($current != "y" &&
315 ($current != "g" || !$ilSetting->get('enable_global_profiles')) &&
316 !$this->custom_prefs) {
317 ilUtil::redirect('ilias.php?baseClass=ilDashboardGUI');
318 }
319
320 $this->renderTitle();
321 return $this->getEmbeddable(true);
322 }
323 }
324
325
331 public function getEmbeddable($a_add_goto = false)
332 {
333 global $DIC;
334
335 $ilSetting = $DIC['ilSetting'];
336 $lng = $DIC['lng'];
337 $ilCtrl = $DIC['ilCtrl'];
338 $lng = $DIC['lng'];
339 $ilSetting = $DIC['ilSetting'];
340 $ilUser = $DIC['ilUser'];
341
342 // get user object
343 if (!ilObject::_exists($this->getUserId())) {
344 return "";
345 }
346 $user = new ilObjUser($this->getUserId());
347
348 $tpl = new ilTemplate(
349 "tpl.usr_public_profile.html",
350 true,
351 true,
352 "Services/User"
353 );
354
355
356 $tpl->setVariable("ROWCOL1", "tblrow1");
357 $tpl->setVariable("ROWCOL2", "tblrow2");
358
359 if (!$this->offline && $ilUser->getId() != ANONYMOUS_USER_ID) {
360 $ref_url = str_replace("&amp;", "&", $this->getBackUrl());
361 if (!$ref_url) {
362 $ref_url = basename($_SERVER['REQUEST_URI']);
363 }
364
365 $tpl->setCurrentBlock("mail");
366 $tpl->setVariable("TXT_MAIL", $lng->txt("send_mail"));
367 require_once 'Services/Mail/classes/class.ilMailFormCall.php';
368 $tpl->setVariable(
369 'HREF_MAIL',
371 $ref_url,
372 '',
373 array(),
374 array('type' => 'new', 'rcp_to' => $user->getLogin())
375 )
376 );
377 $tpl->parseCurrentBlock();
378 }
379
380
381 // short version, fixes e.g. #27242
382 if (!$this->isProfilePublic()) {
383 $tpl->setVariable("TXT_NAME", $lng->txt("name"));
384 $tpl->setVariable("FIRSTNAME", ilUserUtil::getNamePresentation($user->getId()));
385 return $tpl->get();
386 }
387
388 $first_name = "";
389 if ($this->getPublicPref($user, "public_title") == "y") {
390 $first_name .= $user->getUTitle() . " ";
391 }
392 $first_name .= $user->getFirstName();
393
394 if ($this->getPublicPref($user, "public_gender") == "y" && in_array($user->getGender(), ['m', 'f'])) {
395 $sal = $lng->txt("salutation_" . $user->getGender()) . " ";
396 $tpl->setVariable("SALUTATION", $sal);
397 }
398
399 $tpl->setVariable("TXT_NAME", $lng->txt("name"));
400 $tpl->setVariable("FIRSTNAME", $first_name);
401 $tpl->setVariable("LASTNAME", $user->getLastName());
402
403 if ($user->getBirthday() &&
404 $this->getPublicPref($user, "public_birthday") == "y") {
405 // #17574
406 $tpl->setCurrentBlock("bday_bl");
407 $tpl->setVariable("TXT_BIRTHDAY", $lng->txt("birthday"));
408 $tpl->setVariable("VAL_BIRTHDAY", ilDatePresentation::formatDate(new ilDate($user->getBirthday(), IL_CAL_DATE)));
409 $tpl->parseCurrentBlock();
410 }
411
412 if (!$this->offline) {
413 // vcard
414 $tpl->setCurrentBlock("vcard");
415 $tpl->setVariable("TXT_VCARD", $lng->txt("vcard"));
416 $tpl->setVariable("TXT_DOWNLOAD_VCARD", $lng->txt("vcard_download"));
417 $ilCtrl->setParameter($this, "user", $this->getUserId());
418 $tpl->setVariable("HREF_VCARD", $ilCtrl->getLinkTarget($this, "deliverVCard"));
419 }
420
421 $webspace_dir = ilUtil::getWebspaceDir("user");
422 $check_dir = ilUtil::getWebspaceDir();
423 $random = new \ilRandom();
424 $imagefile = $webspace_dir . "/usr_images/" . $user->getPref("profile_image") . "?dummy=" . $random->int(1, 999999);
425 $check_file = $check_dir . "/usr_images/" . $user->getPref("profile_image");
426
427 if (!@is_file($check_file)) {
428 $imagefile = $check_file =
429 ilObjUser::_getPersonalPicturePath($user->getId(), "small", false, true);
430 } else {
431 if ($this->offline) {
432 $imagefile = basename($imagefile);
433 } else {
434 $imagefile = ilWACSignedPath::signFile($imagefile . "?t=1");
435 }
436 }
437
438 if ($this->getPublicPref($user, "public_upload") == "y" && $imagefile != "" &&
439 ($ilUser->getId() != ANONYMOUS_USER_ID || $user->getPref("public_profile") == "g")) {
440 //Getting the flexible path of image form ini file
441 //$webspace_dir = ilUtil::getWebspaceDir("output");
442 $tpl->setCurrentBlock("image");
443 $tpl->setVariable("TXT_IMAGE", $lng->txt("image"));
444 $tpl->setVariable("IMAGE_PATH", $imagefile);
445 $tpl->setVariable("IMAGE_ALT", $lng->txt("personal_picture"));
446 $tpl->parseCurrentBlock();
447 }
448
449 // address
450 if ($this->getPublicPref($user, "public_street") == "y" ||
451 $this->getPublicPref($user, "public_zipcode") == "y" ||
452 $this->getPublicPref($user, "public_city") == "y" ||
453 $this->getPublicPref($user, "public_country") == "y") {
454 $address = array();
455 $val_arr = array("getStreet" => "street",
456 "getZipcode" => "zipcode",
457 "getCity" => "city",
458 "getCountry" => "country",
459 "getSelectedCountry" => "sel_country");
460 foreach ($val_arr as $key => $value) {
461 // if value "y" show information
462 if ($this->getPublicPref($user, "public_" . $value) == "y") {
463 $address_value = $user->$key();
464
465 // only if set
466 if (trim($address_value) != "") {
467 switch ($value) {
468 case "street":
469 $address[0] = $address_value;
470 break;
471
472 case "zipcode":
473 case "city":
474 $address[1] .= " " . $address_value;
475 break;
476
477 case "sel_country":
478 $lng->loadLanguageModule("meta");
479 $address[2] = $lng->txt("meta_c_" . $address_value);
480 break;
481
482 case "country":
483 $address[2] = $address_value;
484 break;
485 }
486 }
487 }
488 }
489 if (sizeof($address)) {
490 $tpl->setCurrentBlock("address_line");
491 foreach ($address as $line) {
492 if (trim($line)) {
493 $tpl->setVariable("TXT_ADDRESS_LINE", trim($line));
494 $tpl->parseCurrentBlock();
495 }
496 }
497 $tpl->setCurrentBlock("address");
498 $tpl->setVariable("TXT_ADDRESS", $lng->txt("address"));
499 $tpl->parseCurrentBlock();
500 }
501 }
502
503 // if value "y" show information
504 if ($this->getPublicPref($user, "public_org_units") == "y") {
505 $tpl->setCurrentBlock("org_units");
506 $tpl->setVariable("TXT_ORG_UNITS", $lng->txt("objs_orgu"));
507 $tpl->setVariable("ORG_UNITS", $user->getOrgUnitsRepresentation());
508 $tpl->parseCurrentBlock();
509 }
510
511 // institution / department
512 if ($this->getPublicPref($user, "public_institution") == "y" ||
513 $this->getPublicPref($user, "public_department") == "y") {
514 $tpl->setCurrentBlock("inst_dep");
515 $sep = "";
516 if ($this->getPublicPref($user, "public_institution") == "y") {
517 $h = $lng->txt("institution");
518 $v = $user->getInstitution();
519 $sep = " / ";
520 }
521 if ($this->getPublicPref($user, "public_department") == "y") {
522 $h .= $sep . $lng->txt("department");
523 $v .= $sep . $user->getDepartment();
524 }
525 $tpl->setVariable("TXT_INST_DEP", $h);
526 $tpl->setVariable("INST_DEP", $v);
527 $tpl->parseCurrentBlock();
528 }
529
530 // contact
531 $val_arr = array(
532 "getPhoneOffice" => "phone_office", "getPhoneHome" => "phone_home",
533 "getPhoneMobile" => "phone_mobile", "getFax" => "fax", "getEmail" => "email", "getSecondEmail" => "second_email");
534 $v = $sep = "";
535 foreach ($val_arr as $key => $value) {
536 // if value "y" show information
537 if ($this->getPublicPref($user, "public_" . $value) == "y") {
538 $v .= $sep . $lng->txt($value) . ": " . $user->$key();
539 $sep = "<br />";
540 }
541 }
542 if ($v != "") {
543 $tpl->parseCurrentBlock("contact");
544 $tpl->setVariable("TXT_CONTACT", $lng->txt("contact"));
545 $tpl->setVariable("CONTACT", $v);
546 $tpl->parseCurrentBlock();
547 }
548
549
550 $val_arr = array(
551 "getHobby" => "hobby",
552 "getGeneralInterestsAsText" => "interests_general",
553 "getOfferingHelpAsText" => "interests_help_offered",
554 "getLookingForHelpAsText" => "interests_help_looking",
555 "getMatriculation" => "matriculation",
556 "getClientIP" => "client_ip");
557
558 foreach ($val_arr as $key => $value) {
559 // if value "y" show information
560 if ($this->getPublicPref($user, "public_" . $value) == "y") {
561 $tpl->setCurrentBlock("profile_data");
562 $tpl->setVariable("TXT_DATA", $lng->txt($value));
563 $tpl->setVariable("DATA", $user->$key());
564 $tpl->parseCurrentBlock();
565 }
566 }
567
568 // portfolios
569 include_once("./Services/Link/classes/class.ilLink.php");
570 include_once("./Modules/Portfolio/classes/class.ilObjPortfolio.php");
571 $back = ($this->getBackUrl() != "")
572 ? $this->getBackUrl()
573 : ilLink::_getStaticLink($this->getUserId(), "usr", true);
575 $cnt = 0;
576 if (count($port) > 0) {
577 foreach ($port as $u) {
578 $tpl->setCurrentBlock("portfolio");
579 foreach ($u as $link => $title) {
580 $cnt++;
581 $tpl->setVariable("HREF_PORTFOLIO", $link);
582 $tpl->setVariable("TITLE_PORTFOLIO", $title);
583 $tpl->parseCurrentBlock();
584 }
585 }
586 $tpl->setCurrentBlock("portfolios");
587 if ($cnt > 1) {
588 $lng->loadLanguageModule("prtf");
589 $tpl->setVariable("TXT_PORTFOLIO", $lng->txt("prtf_portfolios"));
590 } else {
591 $tpl->setVariable("TXT_PORTFOLIO", $lng->txt("portfolio"));
592 }
593 $tpl->parseCurrentBlock();
594 }
595
596 // map
597 include_once("./Services/Maps/classes/class.ilMapUtil.php");
599 $this->getPublicPref($user, "public_location") == "y" &&
600 $user->getLatitude() != "") {
601 $tpl->setVariable("TXT_LOCATION", $lng->txt("location"));
602
603 $map_gui = ilMapUtil::getMapGUI();
604 $map_gui->setMapId("user_map")
605 ->setWidth("350px")
606 ->setHeight("230px")
607 ->setLatitude($user->getLatitude())
608 ->setLongitude($user->getLongitude())
609 ->setZoom($user->getLocationZoom())
610 ->setEnableNavigationControl(true)
611 ->addUserMarker($user->getId());
612
613 $tpl->setVariable("MAP_CONTENT", $map_gui->getHTML());
614 }
615
616 // additional defined user data fields
617 include_once './Services/User/classes/class.ilUserDefinedFields.php';
618 $this->user_defined_fields = &ilUserDefinedFields::_getInstance();
619 $user_defined_data = $user->getUserDefinedData();
620 foreach ($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition) {
621 // public setting
622 if ($this->getPublicPref($user, "public_udf_" . $definition["field_id"]) == "y") {
623 if ($user_defined_data["f_" . $definition["field_id"]] != "") {
624 $tpl->setCurrentBlock("udf_data");
625 $tpl->setVariable("TXT_UDF_DATA", $definition["field_name"]);
626 $tpl->setVariable("UDF_DATA", $user_defined_data["f_" . $definition["field_id"]]);
627 $tpl->parseCurrentBlock();
628 }
629 }
630 }
631
632 // additional information
633 $additional = $this->getAdditional();
634 if (is_array($additional)) {
635 foreach ($additional as $key => $val) {
636 $tpl->setCurrentBlock("profile_data");
637 $tpl->setVariable("TXT_DATA", $key);
638 $tpl->setVariable("DATA", $val);
639 $tpl->parseCurrentBlock();
640 }
641 }
642
643 if (
644 $this->getUserId() != $ilUser->getId() &&
645 !$ilUser->isAnonymous() &&
646 !ilObjUser::_isAnonymous($this->getUserId())
647 ) {
648 require_once 'Services/Contact/BuddySystem/classes/class.ilBuddySystemLinkButton.php';
649 $button = ilBuddySystemLinkButton::getInstanceByUserId((int) $user->getId());
650 $tpl->setVariable('BUDDY_HTML', $button->getHtml());
651 }
652
653 // badges
654 include_once "Services/Badge/classes/class.ilBadgeAssignment.php";
655 $user_badges = ilBadgeAssignment::getInstancesByUserId($user->getId());
656 if ($user_badges) {
657 $has_public_badge = false;
658 $cnt = 0;
659
660 $cut = 20;
661
662 include_once "Services/Badge/classes/class.ilBadgeRenderer.php";
663 foreach ($user_badges as $ass) {
664 // only active
665 if ($ass->getPosition()) {
666 $cnt++;
667
668 $renderer = new ilBadgeRenderer($ass);
669
670 // limit to 20, [MORE] link
671 if ($cnt <= $cut) {
672 $tpl->setCurrentBlock("badge_bl");
673 $tpl->setVariable("BADGE", $renderer->getHTML());
674 $tpl->parseCurrentBlock();
675 } else {
676 $tpl->setCurrentBlock("badge_hidden_item_bl");
677 $tpl->setVariable("BADGE_HIDDEN", $renderer->getHTML());
678 $tpl->parseCurrentBlock();
679 }
680
681 $has_public_badge = true;
682 }
683 }
684
685 if ($cnt > $cut) {
686 $lng->loadLanguageModule("badge");
687 $tpl->setVariable("BADGE_HIDDEN_TXT_MORE", $lng->txt("badge_profile_more"));
688 $tpl->setVariable("BADGE_HIDDEN_TXT_LESS", $lng->txt("badge_profile_less"));
689 $tpl->touchBlock("badge_js_bl");
690 }
691
692 if ($has_public_badge) {
693 $tpl->setVariable("TXT_BADGES", $lng->txt("obj_bdga"));
694 }
695 }
696
697 $goto = "";
698 if ($a_add_goto) {
699 global $DIC;
700
701 $mtpl = $DIC->ui()->mainTemplate();
702
703 $mtpl->setPermanentLink(
704 "usr",
705 $user->getId(),
706 "",
707 "_top"
708 );
709
710 /*include_once('Services/PermanentLink/classes/class.ilPermanentLinkGUI.php');
711 $goto = new ilPermanentLinkGUI("usr", $user->getId());
712 $goto = $goto->getHTML();*/
713 }
714 return $tpl->get() . $goto;
715 }
716
720 public function deliverVCard()
721 {
722 // get user object
723 if (!ilObject::_exists($this->getUserId())) {
724 return "";
725 }
726 $user = new ilObjUser($this->getUserId());
727
728 require_once "./Services/User/classes/class.ilvCard.php";
729 $vcard = new ilvCard();
730
731 // ilsharedresourceGUI: embedded in shared portfolio
732 if ($user->getPref("public_profile") != "y" &&
733 $user->getPref("public_profile") != "g" &&
734 $_GET["baseClass"] != "ilsharedresourceGUI" &&
735 $this->current_user->getId() != $this->getUserId()
736 ) {
737 return;
738 }
739
740 $vcard->setName($user->getLastName(), $user->getFirstName(), "", $user->getUTitle());
741 $vcard->setNickname($user->getLogin());
742
743 $webspace_dir = ilUtil::getWebspaceDir("output");
744 $imagefile = $webspace_dir . "/usr_images/" . $user->getPref("profile_image");
745 if ($user->getPref("public_upload") == "y" && @is_file($imagefile)) {
746 $fh = fopen($imagefile, "r");
747 if ($fh) {
748 $image = fread($fh, filesize($imagefile));
749 fclose($fh);
750 require_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
751 $mimetype = ilObjMediaObject::getMimeType($imagefile);
752 if (preg_match("/^image/", $mimetype)) {
753 $type = $mimetype;
754 }
755 $vcard->setPhoto($image, $type);
756 }
757 }
758
759 $val_arr = array("getOrgUnitsRepresentation" => "org_units", "getInstitution" => "institution",
760 "getDepartment" => "department", "getStreet" => "street",
761 "getZipcode" => "zipcode", "getCity" => "city", "getCountry" => "country",
762 "getPhoneOffice" => "phone_office", "getPhoneHome" => "phone_home",
763 "getPhoneMobile" => "phone_mobile", "getFax" => "fax", "getEmail" => "email",
764 "getHobby" => "hobby", "getMatriculation" => "matriculation",
765 "getClientIP" => "client_ip", "dummy" => "location");
766
767 $org = array();
768 $adr = array();
769 foreach ($val_arr as $key => $value) {
770 // if value "y" show information
771 if ($user->getPref("public_" . $value) == "y") {
772 switch ($value) {
773 case "institution":
774 $org[0] = $user->$key();
775 break;
776 case "department":
777 $org[1] = $user->$key();
778 break;
779 case "street":
780 $adr[2] = $user->$key();
781 break;
782 case "zipcode":
783 $adr[5] = $user->$key();
784 break;
785 case "city":
786 $adr[3] = $user->$key();
787 break;
788 case "country":
789 $adr[6] = $user->$key();
790 break;
791 case "phone_office":
792 $vcard->setPhone($user->$key(), TEL_TYPE_WORK);
793 break;
794 case "phone_home":
795 $vcard->setPhone($user->$key(), TEL_TYPE_HOME);
796 break;
797 case "phone_mobile":
798 $vcard->setPhone($user->$key(), TEL_TYPE_CELL);
799 break;
800 case "fax":
801 $vcard->setPhone($user->$key(), TEL_TYPE_FAX);
802 break;
803 case "email":
804 $vcard->setEmail($user->$key());
805 break;
806 case "hobby":
807 $vcard->setNote($user->$key());
808 break;
809 case "location":
810 $vcard->setPosition($user->getLatitude(), $user->getLongitude());
811 break;
812 }
813 }
814 }
815
816 if (count($org)) {
817 $vcard->setOrganization(join(";", $org));
818 }
819 if (count($adr)) {
820 $vcard->setAddress($adr[0], $adr[1], $adr[2], $adr[3], $adr[4], $adr[5], $adr[6]);
821 }
822
823 ilUtil::deliverData($vcard->buildVCard(), $vcard->getFilename(), $vcard->getMimetype());
824 }
825
831 protected static function validateUser($usrId)
832 {
833 global $DIC;
834
835 $ilUser = $DIC->user();
836 $ilCtrl = $DIC->ctrl();
837
838 if (ilObject::_lookupType($usrId) != "usr") {
839 return false;
840 }
841
842 $user = new ilObjUser($usrId);
843
844 if ($ilUser->isAnonymous()) {
845 if (strtolower($ilCtrl->getCmd()) == strtolower('approveContactRequest')) {
846 $ilCtrl->redirectToURL('login.php?cmd=force_login&target=usr_' . $usrId . '_contact_approved');
847 } elseif (strtolower($ilCtrl->getCmd()) == strtolower('ignoreContactRequest')) {
848 $ilCtrl->redirectToURL('login.php?cmd=force_login&target=usr_' . $usrId . '_contact_ignored');
849 }
850
851 if ($user->getPref("public_profile") != "g") {
852 // #12151
853 if ($user->getPref("public_profile") == "y") {
854 $ilCtrl->redirectToURL("login.php?cmd=force_login&target=usr_" . $usrId);
855 }
856
857 return false;
858 }
859 }
860
861 return true;
862 }
863
864 public function renderTitle()
865 {
866 global $DIC;
867
868 $tpl = $DIC['tpl'];
869
870 $tpl->resetHeaderBlock();
871
872 include_once("./Services/User/classes/class.ilUserUtil.php");
874 $tpl->setTitleIcon(ilObjUser::_getPersonalPicturePath($this->getUserId(), "xsmall"));
875
876 $this->handleBackUrl();
877 }
878
884 protected function getProfilePortfolio()
885 {
886 include_once "Modules/Portfolio/classes/class.ilObjPortfolio.php";
887 $portfolio_id = ilObjPortfolio::getDefaultPortfolio($this->getUserId());
888 if ($portfolio_id) {
889 include_once('./Modules/Portfolio/classes/class.ilPortfolioAccessHandler.php');
890 $access_handler = new ilPortfolioAccessHandler();
891 if ($access_handler->checkAccess("read", "", $portfolio_id)) {
892 return $portfolio_id;
893 }
894 }
895 }
896
897 public static function getAutocompleteResult($a_field_id, $a_term)
898 {
899 global $DIC;
900
901 $ilUser = $DIC['ilUser'];
902
903 $multi_fields = array("interests_general", "interests_help_offered", "interests_help_looking");
904 if (in_array($a_field_id, $multi_fields) && $a_term) {
905 // registration has no current user
906 $user_id = null;
907 if ($ilUser && $ilUser->getId() && $ilUser->getId() != ANONYMOUS_USER_ID) {
908 $user_id = $ilUser->getId();
909 }
910
911 $result = array();
912 $cnt = 0;
913
914 // term is searched in ALL interest fields, no distinction
915 foreach (ilObjUser::findInterests($a_term, $ilUser->getId()) as $item) {
916 $result[$cnt] = new stdClass();
917 $result[$cnt]->value = $item;
918 $result[$cnt]->label = $item;
919 $cnt++;
920 }
921
922 // :TODO: search in skill data
923 include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
924 foreach (ilSkillTreeNode::findSkills($a_term) as $skill) {
925 $result[$cnt] = new stdClass();
926 $result[$cnt]->value = $skill;
927 $result[$cnt]->label = $skill;
928 $cnt++;
929 }
930 }
931
932 return $result;
933 }
934
935 protected function doProfileAutoComplete()
936 {
937 $field_id = (string) $_REQUEST["f"];
938 $term = (string) $_REQUEST["term"];
939
940 $result = self::getAutocompleteResult($field_id, $term);
941
942 include_once 'Services/JSON/classes/class.ilJsonUtil.php';
944
945 exit();
946 }
947
951 protected function approveContactRequest()
952 {
956 global $DIC;
957
958 $ilCtrl = $DIC['ilCtrl'];
959
960 if (isset($_REQUEST['osd_id'])) {
961 $ilCtrl->setParameterByClass('ilBuddySystemGUI', 'osd_id', $_REQUEST['osd_id']);
962 }
963
964 $ilCtrl->setParameterByClass('ilBuddySystemGUI', 'user_id', $this->getUserId());
965 $ilCtrl->redirectByClass(array('ilPublicUserProfileGUI', 'ilBuddySystemGUI'), 'link');
966 }
967
971 protected function ignoreContactRequest()
972 {
976 global $DIC;
977
978 $ilCtrl = $DIC['ilCtrl'];
979
980 if (isset($_REQUEST['osd_id'])) {
981 $ilCtrl->setParameterByClass('ilBuddySystemGUI', 'osd_id', $_REQUEST['osd_id']);
982 }
983
984 $ilCtrl->setParameterByClass('ilBuddySystemGUI', 'user_id', $this->getUserId());
985 $ilCtrl->redirectByClass(array('ilPublicUserProfileGUI', 'ilBuddySystemGUI'), 'ignore');
986 }
987}
$result
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATE
const TEL_TYPE_HOME
const TEL_TYPE_FAX
const TEL_TYPE_CELL
const TEL_TYPE_WORK
static getInstancesByUserId($a_user_id)
Class ilBadgeRenderer.
Class ilBuddySystemGUI.
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 encode($mixed, $suppress_native=false)
static getLinkTarget($gui, $cmd, array $gui_params=array(), array $mail_params=array(), $context_params=array())
static isActivated()
Checks whether Map feature is activated.
static getMapGUI()
Get an instance of the GUI class.
static removeNotification($notification_osd_id)
Removes a notifcation and triggers a follow up notification to remove the notification from the brows...
static getMimeType($a_file, $a_external=null)
get mime type for file
Portfolio view gui class.
static getDefaultPortfolio($a_user_id)
Get default portfolio of user.
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)
Get path to personal picture.
static findInterests($a_term, $a_user_id=null, $a_field_id=null)
getPref($a_keyword)
get a user preference
static _isAnonymous($usr_id)
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public
static _lookupType($a_id, $a_reference=false)
lookup object type
Access handler for portfolio.
GUI class for public user profile presentation.
setEmbedded($a_value, $a_offline=false)
deliverVCard()
Deliver vcard information.
setBackUrl($a_backurl)
Set Back Link URL.
setAdditional($a_additional)
Set Additonal Information.
getAdditional()
Get Additonal Information.
static validateUser($usrId)
Check if given user id is valid.
handleBackUrl($a_is_portfolio=false)
static getAutocompleteResult($a_field_id, $a_term)
getProfilePortfolio()
Check if current profile portfolio is accessible.
setCustomPrefs(array $a_prefs)
Set custom preferences for public profile fields.
getEmbeddable($a_add_goto=false)
get public profile html code
__construct($a_user_id=0)
Constructor.
getPublicPref(ilObjUser $a_user, $a_id)
Get user preference for public profile.
static findSkills($a_term)
Find skills.
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 getWebspaceDir($mode="filesystem")
get webspace directory
static redirect($a_script)
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
static signFile($path_to_file)
global $ilCtrl
Definition: ilias.php:18
exit
Definition: login.php:29
$ret
Definition: parser.php:6
global $ilSetting
Definition: privfeed.php:17
$type
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
$lng
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46