ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
28 function __construct($a_user_id = 0)
29 {
30 global $ilCtrl, $lng;
31
32 if($a_user_id)
33 {
34 $this->setUserId($a_user_id);
35 }
36 else
37 {
38 $this->setUserId((int)$_GET["user_id"]);
39 }
40
41 $ilCtrl->saveParameter($this, array("user_id","back_url", "user"));
42 if ($_GET["back_url"] != "")
43 {
44 $this->setBackUrl($_GET["back_url"]);
45 }
46
47 $lng->loadLanguageModule("user");
48 }
49
55 function setUserId($a_userid)
56 {
57 $this->userid = $a_userid;
58 }
59
65 function getUserId()
66 {
67 return $this->userid;
68 }
69
75 function setAdditional($a_additional)
76 {
77 $this->additional = $a_additional;
78 }
79
85 function getAdditional()
86 {
87 return $this->additional;
88 }
89
95 function setBackUrl($a_backurl)
96 {
97 global $ilCtrl;
98
99 // we only allow relative links
100 $parts = parse_url($a_backurl);
101 if($parts["host"])
102 {
103 $a_backurl = "#";
104 }
105
106 $this->backurl = $a_backurl;
107 $ilCtrl->setParameter($this, "back_url", rawurlencode($a_backurl));
108 }
109
115 function getBackUrl()
116 {
117 return $this->backurl;
118 }
119
120 protected function handleBackUrl($a_is_portfolio = false)
121 {
122 global $ilMainMenu, $ilTabs, $lng;
123
124 $back = ($this->getBackUrl() != "")
125 ? $this->getBackUrl()
126 : $_GET["back_url"];
127
128 if(!$back)
129 {
130 // #15984
131 $back = 'ilias.php?baseClass=ilPersonalDesktopGUI';
132 }
133
134 if((bool)$a_is_portfolio)
135 {
136 $ilMainMenu->setTopBarBack($back);
137 }
138 else
139 {
140 // #17838
141 $ilTabs->clearTargets();
142 $ilTabs->setBackTarget($lng->txt("back"),
143 $back);
144 }
145 }
146
152 function setCustomPrefs(array $a_prefs)
153 {
154 $this->custom_prefs = $a_prefs;
155 }
156
166 protected function getPublicPref(ilObjUser $a_user, $a_id)
167 {
168 if(!$this->custom_prefs)
169 {
170 return $a_user->getPref($a_id);
171 }
172 else
173 {
174 return $this->custom_prefs[$a_id];
175 }
176 }
177
178 function setEmbedded($a_value, $a_offline = false)
179 {
180 $this->embedded = (bool)$a_value;
181 $this->offline = (bool)$a_offline;
182 }
183
187 function executeCommand()
188 {
189 global $ilCtrl, $tpl;
190
191 if(!self::validateUser($this->getUserId()))
192 {
193 return;
194 }
195
196 $next_class = $ilCtrl->getNextClass($this);
197 $cmd = $ilCtrl->getCmd();
198
199 $tpl->getStandardTemplate();
200
201 switch($next_class)
202 {
203 case "ilobjportfoliogui":
204 $portfolio_id = $this->getProfilePortfolio();
205 if($portfolio_id)
206 {
207 $this->handleBackUrl(true);
208
209 include_once "Modules/Portfolio/classes/class.ilObjPortfolioGUI.php";
210 $gui = new ilObjPortfolioGUI($portfolio_id); // #11876
211 $gui->setAdditional($this->getAdditional());
212 $gui->setPermaLink($this->getUserId(), "usr");
213 $ilCtrl->forwardCommand($gui);
214 break;
215 }
216 case 'ilbuddysystemgui':
217 if(isset($_REQUEST['osd_id']))
218 {
219 require_once 'Services/Notifications/classes/class.ilNotificationOSDHandler.php';
221 }
222
223 require_once 'Services/Contact/BuddySystem/classes/class.ilBuddySystemGUI.php';
224 $gui = new ilBuddySystemGUI();
225 $ilCtrl->setReturn($this, 'view');
226 $ilCtrl->forwardCommand($gui);
227 break;
228 default:
229 $ret = $this->$cmd();
230 $tpl->setContent($ret);
231 break;
232 }
233
234 // only for direct links
235 if (strtolower($_GET["baseClass"]) == "ilpublicuserprofilegui")
236 {
237 $tpl->show();
238 }
239 }
240
244 function view()
245 {
246 return $this->getHTML();
247 }
248
252 function getHTML()
253 {
254 global $ilCtrl, $ilSetting;
255
256 if($this->embedded)
257 {
258 return $this->getEmbeddable();
259 }
260
261 // #15438 - (currently) inactive user?
262 $is_active = true;
263 $user = new ilObjUser($this->getUserId());
264 if(!$user->getActive() ||
265 !$user->checkTimeLimit())
266 {
267 $is_active = false;
268 }
269
270 if($is_active && $this->getProfilePortfolio())
271 {
272 $ilCtrl->redirectByClass("ilobjportfoliogui", "preview");
273 }
274 else
275 {
276
277 if(!$is_active)
278 {
279 ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
280 }
281
282 // Check from Database if value
283 // of public_profile = "y" show user infomation
284 $user = new ilObjUser($this->getUserId());
285 $current = $user->getPref("public_profile");
286
287 // #17462 - see ilPersonalProfileGUI::initPublicProfileForm()
288 if($user->getPref("public_profile") == "g" && !$ilSetting->get('enable_global_profiles'))
289 {
290 $current = "y";
291 }
292
293 if ($current != "y" &&
294 ($current != "g" || !$ilSetting->get('enable_global_profiles')) &&
295 !$this->custom_prefs)
296 {
297 ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
298 }
299
300 $this->renderTitle();
301
302 return $this->getEmbeddable(true);
303 }
304 }
305
311 function getEmbeddable($a_add_goto = false)
312 {
314
315 // get user object
316 if (!ilObject::_exists($this->getUserId()))
317 {
318 return "";
319 }
320 $user = new ilObjUser($this->getUserId());
321
322 $tpl = new ilTemplate("tpl.usr_public_profile.html", true, true,
323 "Services/User");
324
325 $tpl->setVariable("ROWCOL1", "tblrow1");
326 $tpl->setVariable("ROWCOL2", "tblrow2");
327
328 if(!$this->offline && $ilUser->getId() != ANONYMOUS_USER_ID)
329 {
330 $ref_url = str_replace("&amp;", "&", $this->getBackUrl());
331 if(!$ref_url)
332 {
333 $ref_url = basename($_SERVER['REQUEST_URI']);
334 }
335
336 $tpl->setCurrentBlock("mail");
337 $tpl->setVariable("TXT_MAIL", $lng->txt("send_mail"));
338 require_once 'Services/Mail/classes/class.ilMailFormCall.php';
339 $tpl->setVariable(
340 'HREF_MAIL',
342 $ref_url, '', array(), array('type' => 'new', 'rcp_to' => $user->getLogin())
343 )
344 );
345 $tpl->parseCurrentBlock();
346 }
347
348 $first_name = "";
349 if($this->getPublicPref($user, "public_title") == "y")
350 {
351 $first_name .= $user->getUTitle()." ";
352 }
353 $first_name .= $user->getFirstName();
354
355 $tpl->setVariable("TXT_NAME", $lng->txt("name"));
356 $tpl->setVariable("FIRSTNAME", $first_name);
357 $tpl->setVariable("LASTNAME", $user->getLastName());
358
359 if($user->getBirthday() &&
360 $this->getPublicPref($user, "public_birthday") == "y")
361 {
362 // #17574
363 $tpl->setCurrentBlock("bday_bl");
364 $tpl->setVariable("TXT_BIRTHDAY", $lng->txt("birthday"));
365 $tpl->setVariable("VAL_BIRTHDAY", ilDatePresentation::formatDate(new ilDate($user->getBirthday(), IL_CAL_DATE)));
366 $tpl->parseCurrentBlock();
367 }
368
369 if(!$this->offline)
370 {
371 // vcard
372 $tpl->setCurrentBlock("vcard");
373 $tpl->setVariable("TXT_VCARD", $lng->txt("vcard"));
374 $tpl->setVariable("TXT_DOWNLOAD_VCARD", $lng->txt("vcard_download"));
375 $ilCtrl->setParameter($this, "user", $this->getUserId());
376 $tpl->setVariable("HREF_VCARD", $ilCtrl->getLinkTarget($this, "deliverVCard"));
377 }
378
379 $webspace_dir = ilUtil::getWebspaceDir("user");
380 $check_dir = ilUtil::getWebspaceDir();
381 $imagefile = $webspace_dir."/usr_images/".$user->getPref("profile_image")."?dummy=".rand(1,999999);
382 $check_file = $check_dir."/usr_images/".$user->getPref("profile_image");
383
384 if (!@is_file($check_file))
385 {
386 $imagefile = $check_file =
387 ilObjUser::_getPersonalPicturePath($user->getId(), "small", false, true);
388 }
389
390 if($this->offline)
391 {
392 $imagefile = basename($imagefile);
393 }
394
395 if ($this->getPublicPref($user, "public_upload")=="y" && $imagefile != "" &&
396 ($ilUser->getId() != ANONYMOUS_USER_ID || $user->getPref("public_profile") == "g"))
397 {
398 //Getting the flexible path of image form ini file
399 //$webspace_dir = ilUtil::getWebspaceDir("output");
400 $tpl->setCurrentBlock("image");
401 $tpl->setVariable("TXT_IMAGE",$lng->txt("image"));
402 $tpl->setVariable("IMAGE_PATH", $imagefile);
403 $tpl->setVariable("IMAGE_ALT", $lng->txt("personal_picture"));
404 $tpl->parseCurrentBlock();
405 }
406
407 // address
408 if ($this->getPublicPref($user, "public_street") == "y" ||
409 $this->getPublicPref($user, "public_zipcode") == "y" ||
410 $this->getPublicPref($user, "public_city") == "y" ||
411 $this->getPublicPref($user, "public_country") == "y")
412 {
413 $address = array();
414 $val_arr = array ("getStreet" => "street",
415 "getZipcode" => "zipcode",
416 "getCity" => "city",
417 "getCountry" => "country",
418 "getSelectedCountry" => "sel_country");
419 foreach ($val_arr as $key => $value)
420 {
421 // if value "y" show information
422 if ($this->getPublicPref($user, "public_".$value) == "y")
423 {
424 $address_value = $user->$key();
425
426 // only if set
427 if (trim($address_value) != "")
428 {
429 switch($value)
430 {
431 case "street":
432 $address[0] = $address_value;
433 break;
434
435 case "zipcode":
436 case "city":
437 $address[1] .= " ".$address_value;
438 break;
439
440 case "sel_country":
441 $lng->loadLanguageModule("meta");
442 $address[2] = $lng->txt("meta_c_".$address_value);
443 break;
444
445 case "country":
446 $address[2] = $address_value;
447 break;
448 }
449 }
450 }
451 }
452 if(sizeof($address))
453 {
454 $tpl->setCurrentBlock("address_line");
455 foreach($address as $line)
456 {
457 if(trim($line))
458 {
459 $tpl->setVariable("TXT_ADDRESS_LINE", trim($line));
460 $tpl->parseCurrentBlock();
461 }
462 }
463 $tpl->setCurrentBlock("address");
464 $tpl->setVariable("TXT_ADDRESS", $lng->txt("address"));
465 $tpl->parseCurrentBlock();
466 }
467 }
468
469 // institution / department
470 if ($this->getPublicPref($user, "public_institution") == "y" ||
471 $this->getPublicPref($user, "public_department") == "y")
472 {
473 $tpl->setCurrentBlock("inst_dep");
474 $sep = "";
475 if ($this->getPublicPref($user, "public_institution") == "y")
476 {
477 $h = $lng->txt("institution");
478 $v = $user->getInstitution();
479 $sep = " / ";
480 }
481 if ($this->getPublicPref($user, "public_department") == "y")
482 {
483 $h.= $sep.$lng->txt("department");
484 $v.= $sep.$user->getDepartment();
485 }
486 $tpl->setVariable("TXT_INST_DEP", $h);
487 $tpl->setVariable("INST_DEP", $v);
488 $tpl->parseCurrentBlock();
489 }
490
491 // contact
492 $val_arr = array(
493 "getPhoneOffice" => "phone_office", "getPhoneHome" => "phone_home",
494 "getPhoneMobile" => "phone_mobile", "getFax" => "fax", "getEmail" => "email");
495 $v = $sep = "";
496 foreach ($val_arr as $key => $value)
497 {
498 // if value "y" show information
499 if ($this->getPublicPref($user, "public_".$value) == "y")
500 {
501 $v.= $sep.$lng->txt($value).": ".$user->$key();
502 $sep = "<br />";
503 }
504 }
505 if ($ilSetting->get("usr_settings_hide_instant_messengers") != 1)
506 {
507 $im_arr = array("icq","yahoo","msn","aim","skype","jabber","voip");
508
509 foreach ($im_arr as $im_name)
510 {
511 if ($im_id = $user->getInstantMessengerId($im_name))
512 {
513 if ($this->getPublicPref($user, "public_im_".$im_name) != "n")
514 {
515 $v.= $sep.$lng->txt('im_'.$im_name).": ".$im_id;
516 $sep = "<br />";
517 }
518 }
519 }
520 }
521 if ($v != "")
522 {
523 $tpl->parseCurrentBlock("contact");
524 $tpl->setVariable("TXT_CONTACT", $lng->txt("contact"));
525 $tpl->setVariable("CONTACT", $v);
526 $tpl->parseCurrentBlock();
527 }
528
529
530 $val_arr = array(
531 "getHobby" => "hobby",
532 "getGeneralInterestsAsText" => "interests_general",
533 "getOfferingHelpAsText" => "interests_help_offered",
534 "getLookingForHelpAsText" => "interests_help_looking",
535 "getMatriculation" => "matriculation",
536 "getClientIP" => "client_ip");
537
538 foreach ($val_arr as $key => $value)
539 {
540 // if value "y" show information
541 if ($this->getPublicPref($user, "public_".$value) == "y")
542 {
543 $tpl->setCurrentBlock("profile_data");
544 $tpl->setVariable("TXT_DATA", $lng->txt($value));
545 $tpl->setVariable("DATA", $user->$key());
546 $tpl->parseCurrentBlock();
547 }
548 }
549
550 // portfolios
551 include_once("./Services/Link/classes/class.ilLink.php");
552 include_once("./Modules/Portfolio/classes/class.ilObjPortfolio.php");
553 $back = ($this->getBackUrl() != "")
554 ? $this->getBackUrl()
555 : ilLink::_getStaticLink($this->getUserId(), "usr", true);
557 $cnt=0;
558 if (count($port) > 0)
559 {
560 foreach ($port as $u)
561 {
562 $tpl->setCurrentBlock("portfolio");
563 foreach ($u as $link => $title)
564 {
565 $cnt++;
566 $tpl->setVariable("HREF_PORTFOLIO", $link);
567 $tpl->setVariable("TITLE_PORTFOLIO", $title);
568 $tpl->parseCurrentBlock();
569 }
570 }
571 $tpl->setCurrentBlock("portfolios");
572 if ($cnt > 1)
573 {
574 $lng->loadLanguageModule("prtf");
575 $tpl->setVariable("TXT_PORTFOLIO", $lng->txt("prtf_portfolios"));
576 }
577 else
578 {
579 $tpl->setVariable("TXT_PORTFOLIO", $lng->txt("portfolio"));
580 }
581 $tpl->parseCurrentBlock();
582 }
583
584 // delicious row
585 //$d_set = new ilSetting("delicious");
586 if ($this->getPublicPref($user, "public_delicious") == "y")
587 {
588 $tpl->setCurrentBlock("delicious_row");
589 $tpl->setVariable("TXT_DELICIOUS", $lng->txt("delicious"));
590 $tpl->setVariable("TXT_DEL_ICON", $lng->txt("delicious"));
591 $tpl->setVariable("SRC_DEL_ICON", ilUtil::getImagePath("icon_delicious.png"));
592 $tpl->setVariable("DEL_ACCOUNT", $user->getDelicious());
593 $tpl->parseCurrentBlock();
594 }
595
596 // map
597 include_once("./Services/Maps/classes/class.ilMapUtil.php");
598 if (ilMapUtil::isActivated() &&
599 $this->getPublicPref($user, "public_location") == "y" &&
600 $user->getLatitude() != "")
601 {
602 $tpl->setVariable("TXT_LOCATION", $lng->txt("location"));
603
604 $map_gui = ilMapUtil::getMapGUI();
605 $map_gui->setMapId("user_map")
606 ->setWidth("350px")
607 ->setHeight("230px")
608 ->setLatitude($user->getLatitude())
609 ->setLongitude($user->getLongitude())
610 ->setZoom($user->getLocationZoom())
611 ->setEnableNavigationControl(true)
612 ->addUserMarker($user->getId());
613
614 $tpl->setVariable("MAP_CONTENT", $map_gui->getHTML());
615 }
616
617 // additional defined user data fields
618 include_once './Services/User/classes/class.ilUserDefinedFields.php';
619 $this->user_defined_fields =& ilUserDefinedFields::_getInstance();
620 $user_defined_data = $user->getUserDefinedData();
621 foreach($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition)
622 {
623 // public setting
624 if ($this->getPublicPref($user, "public_udf_".$definition["field_id"]) == "y")
625 {
626 if ($user_defined_data["f_".$definition["field_id"]] != "")
627 {
628 $tpl->setCurrentBlock("udf_data");
629 $tpl->setVariable("TXT_UDF_DATA", $definition["field_name"]);
630 $tpl->setVariable("UDF_DATA", $user_defined_data["f_".$definition["field_id"]]);
631 $tpl->parseCurrentBlock();
632 }
633 }
634 }
635
636 // additional information
637 $additional = $this->getAdditional();
638 if (is_array($additional))
639 {
640 foreach($additional as $key => $val)
641 {
642 $tpl->setCurrentBlock("profile_data");
643 $tpl->setVariable("TXT_DATA", $key);
644 $tpl->setVariable("DATA", $val);
645 $tpl->parseCurrentBlock();
646 }
647 }
648
649 if(
650 $this->getUserId() != $ilUser->getId() &&
651 !$ilUser->isAnonymous() &&
652 !ilObjUser::_isAnonymous($this->getUserId())
653 )
654 {
655 require_once 'Services/Contact/BuddySystem/classes/class.ilBuddySystemLinkButton.php';
656 $button = ilBuddySystemLinkButton::getInstanceByUserId($user->getId());
657 $tpl->setVariable('BUDDY_HTML', $button->getHtml());
658 }
659
660 $goto = "";
661 if($a_add_goto)
662 {
663 include_once('Services/PermanentLink/classes/class.ilPermanentLinkGUI.php');
664 $goto = new ilPermanentLinkGUI("usr", $user->getId());
665 $goto = $goto->getHTML();
666 }
667
668 return $tpl->get().$goto;
669 }
670
674 function deliverVCard()
675 {
676 // get user object
677 if (!ilObject::_exists($this->getUserId()))
678 {
679 return "";
680 }
681 $user = new ilObjUser($this->getUserId());
682
683 require_once "./Services/User/classes/class.ilvCard.php";
684 $vcard = new ilvCard();
685
686 // ilsharedresourceGUI: embedded in shared portfolio
687 if ($user->getPref("public_profile") != "y" &&
688 $user->getPref("public_profile") != "g" &&
689 $_GET["baseClass"] != "ilsharedresourceGUI")
690 {
691 return;
692 }
693
694 $vcard->setName($user->getLastName(), $user->getFirstName(), "", $user->getUTitle());
695 $vcard->setNickname($user->getLogin());
696
697 $webspace_dir = ilUtil::getWebspaceDir("output");
698 $imagefile = $webspace_dir."/usr_images/".$user->getPref("profile_image");
699 if ($user->getPref("public_upload")=="y" && @is_file($imagefile))
700 {
701 $fh = fopen($imagefile, "r");
702 if ($fh)
703 {
704 $image = fread($fh, filesize($imagefile));
705 fclose($fh);
706 require_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
707 $mimetype = ilObjMediaObject::getMimeType($imagefile);
708 if (preg_match("/^image/", $mimetype))
709 {
710 $type = $mimetype;
711 }
712 $vcard->setPhoto($image, $type);
713 }
714 }
715
716 $val_arr = array("getInstitution" => "institution", "getDepartment" => "department",
717 "getStreet" => "street",
718 "getZipcode" => "zipcode", "getCity" => "city", "getCountry" => "country",
719 "getPhoneOffice" => "phone_office", "getPhoneHome" => "phone_home",
720 "getPhoneMobile" => "phone_mobile", "getFax" => "fax", "getEmail" => "email",
721 "getHobby" => "hobby", "getMatriculation" => "matriculation", "getClientIP" => "client_ip",
722 "dummy" => "location");
723
724 $org = array();
725 $adr = array();
726 foreach ($val_arr as $key => $value)
727 {
728 // if value "y" show information
729 if ($user->getPref("public_".$value) == "y")
730 {
731 switch ($value)
732 {
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 {
778 $vcard->setOrganization(join(";", $org));
779 }
780 if (count($adr))
781 {
782 $vcard->setAddress($adr[0], $adr[1], $adr[2], $adr[3], $adr[4], $adr[5], $adr[6]);
783 }
784
785 ilUtil::deliverData($vcard->buildVCard(), $vcard->getFilename(), $vcard->getMimetype());
786 }
787
793 protected static function validateUser($a_user_id)
794 {
795 global $ilUser, $ilCtrl;
796
797 if (ilObject::_lookupType($a_user_id) != "usr")
798 {
799 return false;
800 }
801 $user = new ilObjUser($a_user_id);
802 if ($ilUser->getId() == ANONYMOUS_USER_ID && $user->getPref("public_profile") != "g")
803 {
804 // #12151
805 if($user->getPref("public_profile") == "y")
806 {
807 ilUtil::redirect("login.php?cmd=force_login&target=usr_".$a_user_id);
808 }
809 return false;
810 }
811
812 if($ilUser->isAnonymous())
813 {
814 if(strtolower($ilCtrl->getCmd()) == strtolower('approveContactRequest'))
815 {
816 ilUtil::redirect('login.php?cmd=force_login&target=usr_' . $a_user_id . '_contact_approved');
817 }
818 else if(strtolower($ilCtrl->getCmd()) == strtolower('ignoreContactRequest'))
819 {
820 ilUtil::redirect('login.php?cmd=force_login&target=usr_' . $a_user_id . '_contact_ignored');
821 }
822 }
823
824 return true;
825 }
826
827 function renderTitle()
828 {
829 global $tpl;
830
831 $tpl->resetHeaderBlock();
832
833 include_once("./Services/User/classes/class.ilUserUtil.php");
835 $tpl->setTitleIcon(ilObjUser::_getPersonalPicturePath($this->getUserId(), "xxsmall"));
836
837 $this->handleBackUrl();
838 }
839
845 protected function getProfilePortfolio()
846 {
847 include_once "Modules/Portfolio/classes/class.ilObjPortfolio.php";
848 $portfolio_id = ilObjPortfolio::getDefaultPortfolio($this->getUserId());
849 if($portfolio_id)
850 {
851 include_once('./Modules/Portfolio/classes/class.ilPortfolioAccessHandler.php');
852 $access_handler = new ilPortfolioAccessHandler();
853 if($access_handler->checkAccess("read", "", $portfolio_id))
854 {
855 return $portfolio_id;
856 }
857 }
858 }
859
860 public static function getAutocompleteResult($a_field_id, $a_term)
861 {
862 global $ilUser;
863
864 $multi_fields = array("interests_general", "interests_help_offered", "interests_help_looking");
865 if(in_array($a_field_id, $multi_fields) && $a_term)
866 {
867 // registration has no current user
868 $user_id = null;
869 if($ilUser && $ilUser->getId() && $ilUser->getId() != ANONYMOUS_USER_ID)
870 {
871 $user_id = $ilUser->getId();
872 }
873
874 $result = array();
875 $cnt = 0;
876
877 // term is searched in ALL interest fields, no distinction
878 foreach(ilObjUser::findInterests($a_term, $ilUser->getId()) as $item)
879 {
880 $result[$cnt] = new stdClass();
881 $result[$cnt]->value = $item;
882 $result[$cnt]->label = $item;
883 $cnt++;
884 }
885
886 // :TODO: search in skill data
887 include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
888 foreach (ilSkillTreeNode::findSkills($a_term) as $skill)
889 {
890 $result[$cnt] = new stdClass();
891 $result[$cnt]->value = $skill;
892 $result[$cnt]->label = $skill;
893 $cnt++;
894 }
895
896 }
897
898 return $result;
899 }
900
901 protected function doProfileAutoComplete()
902 {
903 $field_id = (string)$_REQUEST["f"];
904 $term = (string)$_REQUEST["term"];
905
906 $result = self::getAutocompleteResult($field_id, $term);
907
908 include_once 'Services/JSON/classes/class.ilJsonUtil.php';
910
911 exit();
912 }
913
917 protected function approveContactRequest()
918 {
922 global $ilCtrl;
923
924 if(isset($_REQUEST['osd_id']))
925 {
926 $ilCtrl->setParameterByClass('ilBuddySystemGUI', 'osd_id', $_REQUEST['osd_id']);
927 }
928
929 $ilCtrl->setParameterByClass('ilBuddySystemGUI', 'user_id', $this->getUserId());
930 $ilCtrl->redirectByClass(array('ilPublicUserProfileGUI', 'ilBuddySystemGUI'), 'link');
931 }
932
936 protected function ignoreContactRequest()
937 {
941 global $ilCtrl;
942
943 if(isset($_REQUEST['osd_id']))
944 {
945 $ilCtrl->setParameterByClass('ilBuddySystemGUI', 'osd_id', $_REQUEST['osd_id']);
946 }
947
948 $ilCtrl->setParameterByClass('ilBuddySystemGUI', 'user_id', $this->getUserId());
949 $ilCtrl->redirectByClass(array('ilPublicUserProfileGUI', 'ilBuddySystemGUI'), 'ignore');
950 }
951}
952?>
$result
global $tpl
Definition: ilias.php:8
$_GET["client_id"]
const IL_CAL_DATE
const TEL_TYPE_HOME
const TEL_TYPE_FAX
const TEL_TYPE_CELL
const TEL_TYPE_WORK
Class ilBuddySystemGUI.
static formatDate(ilDateTime $date)
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=false)
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
Class for permanent links.
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.
handleBackUrl($a_is_portfolio=false)
static validateUser($a_user_id)
Check if given user id is valid.
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)
Default behaviour is:
static getWebspaceDir($mode="filesystem")
get webspace directory
static redirect($a_script)
http redirect to other script
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
$h
global $ilCtrl
Definition: ilias.php:18
exit
Definition: login.php:54
global $lng
Definition: privfeed.php:40
global $ilSetting
Definition: privfeed.php:40
$cmd
Definition: sahs_server.php:35
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
global $ilUser
Definition: imgupload.php:15