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