/**
  * get public profile html code
  * 
  * Used in Personal Profile (as preview) and Portfolio (as page block)
  */
 function getEmbeddable($a_add_goto = false)
 {
     global $ilSetting, $lng, $ilCtrl, $lng, $ilSetting, $ilUser;
     // get user object
     if (!ilObject::_exists($this->getUserId())) {
         return "";
     }
     $user = new ilObjUser($this->getUserId());
     $tpl = new ilTemplate("tpl.usr_public_profile.html", true, true, "Services/User");
     $tpl->setVariable("ROWCOL1", "tblrow1");
     $tpl->setVariable("ROWCOL2", "tblrow2");
     if (!$this->offline && $ilUser->getId() != ANONYMOUS_USER_ID) {
         $ref_url = str_replace("&", "&", $this->getBackUrl());
         if (!$ref_url) {
             $ref_url = basename($_SERVER['REQUEST_URI']);
         }
         $tpl->setCurrentBlock("mail");
         $tpl->setVariable("TXT_MAIL", $lng->txt("send_mail"));
         require_once 'Services/Mail/classes/class.ilMailFormCall.php';
         $tpl->setVariable('HREF_MAIL', ilMailFormCall::getLinkTarget($ref_url, '', array(), array('type' => 'new', 'rcp_to' => urlencode($user->getLogin()))));
         $tpl->parseCurrentBlock();
     }
     $first_name = "";
     if ($this->getPublicPref($user, "public_title") == "y") {
         $first_name .= $user->getUTitle() . " ";
     }
     $first_name .= $user->getFirstName();
     $tpl->setVariable("TXT_NAME", $lng->txt("name"));
     $tpl->setVariable("FIRSTNAME", $first_name);
     $tpl->setVariable("LASTNAME", $user->getLastName());
     if (!$this->offline) {
         // vcard
         $tpl->setCurrentBlock("vcard");
         $tpl->setVariable("TXT_VCARD", $lng->txt("vcard"));
         $tpl->setVariable("TXT_DOWNLOAD_VCARD", $lng->txt("vcard_download"));
         $ilCtrl->setParameter($this, "user", $this->getUserId());
         $tpl->setVariable("HREF_VCARD", $ilCtrl->getLinkTarget($this, "deliverVCard"));
         //$tpl->setVariable("IMG_VCARD", ilUtil::getImagePath("vcard.png"));
     }
     $webspace_dir = ilUtil::getWebspaceDir("user");
     $check_dir = ilUtil::getWebspaceDir();
     $imagefile = $webspace_dir . "/usr_images/" . $user->getPref("profile_image") . "?dummy=" . rand(1, 999999);
     $check_file = $check_dir . "/usr_images/" . $user->getPref("profile_image");
     if (!@is_file($check_file)) {
         $imagefile = $check_file = ilObjUser::_getPersonalPicturePath($user->getId(), "small", false, true);
     }
     if ($this->getPublicPref($user, "public_upload") == "y" && $imagefile != "") {
         //Getting the flexible path of image form ini file
         //$webspace_dir = ilUtil::getWebspaceDir("output");
         $tpl->setCurrentBlock("image");
         $tpl->setVariable("TXT_IMAGE", $lng->txt("image"));
         $tpl->setVariable("IMAGE_PATH", $imagefile);
         $tpl->setVariable("IMAGE_ALT", $lng->txt("personal_picture"));
         $tpl->parseCurrentBlock();
     }
     // address
     if ($this->getPublicPref($user, "public_street") == "y" || $this->getPublicPref($user, "public_zipcode") == "y" || $this->getPublicPref($user, "public_city") == "y" || $this->getPublicPref($user, "public_country") == "y") {
         $address = array();
         $val_arr = array("getStreet" => "street", "getZipcode" => "zipcode", "getCity" => "city", "getCountry" => "country", "getSelectedCountry" => "sel_country");
         foreach ($val_arr as $key => $value) {
             // if value "y" show information
             if ($this->getPublicPref($user, "public_" . $value) == "y") {
                 $address_value = $user->{$key}();
                 // only if set
                 if (trim($address_value) != "") {
                     switch ($value) {
                         case "street":
                             $address[0] = $address_value;
                             break;
                         case "zipcode":
                         case "city":
                             $address[1] .= " " . $address_value;
                             break;
                         case "sel_country":
                             $lng->loadLanguageModule("meta");
                             $address[2] = $lng->txt("meta_c_" . $address_value);
                             break;
                         case "country":
                             $address[2] = $address_value;
                             break;
                     }
                 }
             }
         }
         if (sizeof($address)) {
             $tpl->setCurrentBlock("address_line");
             foreach ($address as $line) {
                 if (trim($line)) {
                     $tpl->setVariable("TXT_ADDRESS_LINE", trim($line));
                     $tpl->parseCurrentBlock();
                 }
             }
             $tpl->setCurrentBlock("address");
             $tpl->setVariable("TXT_ADDRESS", $lng->txt("address"));
             $tpl->parseCurrentBlock();
         }
     }
     // institution / department
     if ($this->getPublicPref($user, "public_institution") == "y" || $this->getPublicPref($user, "public_department") == "y") {
         $tpl->setCurrentBlock("inst_dep");
         $sep = "";
         if ($this->getPublicPref($user, "public_institution") == "y") {
             $h = $lng->txt("institution");
             $v = $user->getInstitution();
             $sep = " / ";
         }
         if ($this->getPublicPref($user, "public_department") == "y") {
             $h .= $sep . $lng->txt("department");
             $v .= $sep . $user->getDepartment();
         }
         $tpl->setVariable("TXT_INST_DEP", $h);
         $tpl->setVariable("INST_DEP", $v);
         $tpl->parseCurrentBlock();
     }
     // contact
     $val_arr = array("getPhoneOffice" => "phone_office", "getPhoneHome" => "phone_home", "getPhoneMobile" => "phone_mobile", "getFax" => "fax", "getEmail" => "email");
     $v = $sep = "";
     foreach ($val_arr as $key => $value) {
         // if value "y" show information
         if ($this->getPublicPref($user, "public_" . $value) == "y") {
             $v .= $sep . $lng->txt($value) . ": " . $user->{$key}();
             $sep = "<br />";
         }
     }
     if ($ilSetting->get("usr_settings_hide_instant_messengers") != 1) {
         $im_arr = array("icq", "yahoo", "msn", "aim", "skype", "jabber", "voip");
         foreach ($im_arr as $im_name) {
             if ($im_id = $user->getInstantMessengerId($im_name)) {
                 if ($this->getPublicPref($user, "public_im_" . $im_name) != "n") {
                     $v .= $sep . $lng->txt('im_' . $im_name) . ": " . $im_id;
                     $sep = "<br />";
                 }
             }
         }
     }
     if ($v != "") {
         $tpl->parseCurrentBlock("contact");
         $tpl->setVariable("TXT_CONTACT", $lng->txt("contact"));
         $tpl->setVariable("CONTACT", $v);
         $tpl->parseCurrentBlock();
     }
     $val_arr = array("getHobby" => "hobby", "getMatriculation" => "matriculation", "getClientIP" => "client_ip");
     foreach ($val_arr as $key => $value) {
         // if value "y" show information
         if ($this->getPublicPref($user, "public_" . $value) == "y") {
             $tpl->setCurrentBlock("profile_data");
             $tpl->setVariable("TXT_DATA", $lng->txt($value));
             $tpl->setVariable("DATA", $user->{$key}());
             $tpl->parseCurrentBlock();
         }
     }
     // delicious row
     //$d_set = new ilSetting("delicious");
     if ($this->getPublicPref($user, "public_delicious") == "y") {
         $tpl->setCurrentBlock("delicious_row");
         $tpl->setVariable("TXT_DELICIOUS", $lng->txt("delicious"));
         $tpl->setVariable("TXT_DEL_ICON", $lng->txt("delicious"));
         $tpl->setVariable("SRC_DEL_ICON", ilUtil::getImagePath("icon_delicious.png"));
         $tpl->setVariable("DEL_ACCOUNT", $user->getDelicious());
         $tpl->parseCurrentBlock();
     }
     // map
     include_once "./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php";
     if (ilGoogleMapUtil::isActivated() && $this->getPublicPref($user, "public_location") == "y" && $user->getLatitude() != "") {
         $tpl->setVariable("TXT_LOCATION", $lng->txt("location"));
         include_once "./Services/GoogleMaps/classes/class.ilGoogleMapGUI.php";
         $map_gui = new ilGoogleMapGUI();
         $map_gui->setMapId("user_map");
         $map_gui->setWidth("350px");
         $map_gui->setHeight("230px");
         $map_gui->setLatitude($user->getLatitude());
         $map_gui->setLongitude($user->getLongitude());
         $map_gui->setZoom($user->getLocationZoom());
         $map_gui->setEnableNavigationControl(true);
         $map_gui->addUserMarker($user->getId());
         $tpl->setVariable("MAP_CONTENT", $map_gui->getHTML());
     }
     // additional defined user data fields
     include_once './Services/User/classes/class.ilUserDefinedFields.php';
     $this->user_defined_fields =& ilUserDefinedFields::_getInstance();
     $user_defined_data = $user->getUserDefinedData();
     foreach ($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition) {
         // public setting
         if ($this->getPublicPref($user, "public_udf_" . $definition["field_id"]) == "y") {
             if ($user_defined_data["f_" . $definition["field_id"]] != "") {
                 $tpl->setCurrentBlock("udf_data");
                 $tpl->setVariable("TXT_UDF_DATA", $definition["field_name"]);
                 $tpl->setVariable("UDF_DATA", $user_defined_data["f_" . $definition["field_id"]]);
                 $tpl->parseCurrentBlock();
             }
         }
     }
     // additional information
     $additional = $this->getAdditional();
     if (is_array($additional)) {
         foreach ($additional as $key => $val) {
             $tpl->setCurrentBlock("profile_data");
             $tpl->setVariable("TXT_DATA", $key);
             $tpl->setVariable("DATA", $val);
             $tpl->parseCurrentBlock();
         }
     }
     $goto = "";
     if ($a_add_goto) {
         include_once 'Services/PermanentLink/classes/class.ilPermanentLinkGUI.php';
         $goto = new ilPermanentLinkGUI("usr", $user->getId());
         $goto = $goto->getHTML();
     }
     return $tpl->get() . $goto;
 }
 /**
  * Add fields to form
  *
  * @param ilPropertyformGUI $form
  * @param array $prefs
  * @param object $parent
  * @param bool $a_anonymized
  */
 public function showPublicProfileFields(ilPropertyformGUI $form, array $prefs, $parent = null, $anonymized = false)
 {
     global $ilUser;
     $birthday = $ilUser->getBirthday();
     if ($birthday) {
         $birthday = ilDatePresentation::formatDate(new ilDate($birthday, IL_CAL_DATE));
     }
     $gender = $ilUser->getGender();
     if ($gender) {
         $gender = $this->lng->txt("gender_" . $gender);
     }
     if ($ilUser->getSelectedCountry() != "") {
         $this->lng->loadLanguageModule("meta");
         $txt_sel_country = $this->lng->txt("meta_c_" . $ilUser->getSelectedCountry());
     }
     // profile picture
     $pic = ilObjUser::_getPersonalPicturePath($ilUser->getId(), "xsmall", true, true);
     if ($pic) {
         $pic = "<img src=\"" . $pic . "\" />";
     }
     // personal data
     $val_array = array("title" => $ilUser->getUTitle(), "birthday" => $birthday, "gender" => $gender, "institution" => $ilUser->getInstitution(), "department" => $ilUser->getDepartment(), "upload" => $pic, "street" => $ilUser->getStreet(), "zipcode" => $ilUser->getZipcode(), "city" => $ilUser->getCity(), "country" => $ilUser->getCountry(), "sel_country" => $txt_sel_country, "phone_office" => $ilUser->getPhoneOffice(), "phone_home" => $ilUser->getPhoneHome(), "phone_mobile" => $ilUser->getPhoneMobile(), "fax" => $ilUser->getFax(), "email" => $ilUser->getEmail(), "hobby" => $ilUser->getHobby(), "matriculation" => $ilUser->getMatriculation(), "delicious" => $ilUser->getDelicious());
     // location
     include_once "./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php";
     if (ilGoogleMapUtil::isActivated()) {
         $val_array["location"] = "";
     }
     foreach ($val_array as $key => $value) {
         if ($anonymized) {
             $value = null;
         }
         if ($this->userSettingVisible($key)) {
             // public setting
             if ($key == "upload") {
                 $cb = new ilCheckboxInputGUI($this->lng->txt("personal_picture"), "chk_" . $key);
             } else {
                 $cb = new ilCheckboxInputGUI($this->lng->txt($key), "chk_" . $key);
             }
             if ($prefs["public_" . $key] == "y") {
                 $cb->setChecked(true);
             }
             //$cb->setInfo($value);
             $cb->setOptionTitle($value);
             if (!$parent) {
                 $form->addItem($cb);
             } else {
                 $parent->addSubItem($cb);
             }
         }
     }
     $im_arr = array("icq", "yahoo", "msn", "aim", "skype", "jabber", "voip");
     if ($this->userSettingVisible("instant_messengers")) {
         foreach ($im_arr as $im) {
             // public setting
             $cb = new ilCheckboxInputGUI($this->lng->txt("im_" . $im), "chk_im_" . $im);
             //$cb->setInfo($ilUser->getInstantMessengerId($im));
             $cb->setOptionTitle($ilUser->getInstantMessengerId($im));
             if ($prefs["public_im_" . $im] != "n") {
                 $cb->setChecked(true);
             }
             if (!$parent) {
                 $form->addItem($cb);
             } else {
                 $parent->addSubItem($cb);
             }
         }
     }
     // additional defined user data fields
     $user_defined_data = array();
     if (!$anonymized) {
         $user_defined_data = $ilUser->getUserDefinedData();
     }
     foreach ($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition) {
         // public setting
         $cb = new ilCheckboxInputGUI($definition["field_name"], "chk_udf_" . $definition["field_id"]);
         $cb->setOptionTitle($user_defined_data["f_" . $definition["field_id"]]);
         if ($prefs["public_udf_" . $definition["field_id"]] == "y") {
             $cb->setChecked(true);
         }
         if (!$parent) {
             $form->addItem($cb);
         } else {
             $parent->addSubItem($cb);
         }
     }
 }
 /**
  * set sub tabs
  *
  * @access protected
  * @param
  * @return
  */
 protected function setSubTabs($a_tab)
 {
     global $rbacsystem, $ilUser, $ilAccess;
     switch ($a_tab) {
         case 'members':
             // for admins
             if ($ilAccess->checkAccess('write', '', $this->object->getRefId())) {
                 $this->tabs_gui->addSubTabTarget("grp_edit_members", $this->ctrl->getLinkTarget($this, 'members'), "members", get_class($this));
             }
             // for all
             $this->tabs_gui->addSubTabTarget("grp_members_gallery", $this->ctrl->getLinkTarget($this, 'membersGallery'), "membersGallery", get_class($this));
             // members map
             include_once "./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php";
             if (ilGoogleMapUtil::isActivated() && $this->object->getEnableGroupMap()) {
                 $this->tabs_gui->addSubTabTarget("grp_members_map", $this->ctrl->getLinkTarget($this, 'membersMap'), "membersMap", get_class($this));
             }
             $this->tabs_gui->addSubTabTarget("mail_members", $this->ctrl->getLinkTarget($this, 'mailMembers'), "mailMembers", get_class($this));
             if ($ilAccess->checkAccess('write', '', $this->object->getRefId())) {
                 $this->tabs_gui->addSubTabTarget("events", $this->ctrl->getLinkTargetByClass('ilsessionoverviewgui', 'listSessions'), "", 'ilsessionoverviewgui');
             }
             include_once 'Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
             if (ilPrivacySettings::_getInstance()->checkExportAccess($this->object->getRefId())) {
                 $this->tabs_gui->addSubTabTarget('grp_export_members', $this->ctrl->getLinkTargetByClass('ilmemberexportgui', 'show'), "", 'ilmemberexportgui');
             }
             break;
         case 'settings':
             $this->tabs_gui->addSubTabTarget("grp_settings", $this->ctrl->getLinkTarget($this, 'edit'), "edit", get_class($this));
             $this->tabs_gui->addSubTabTarget("grp_info_settings", $this->ctrl->getLinkTarget($this, 'editInfo'), "editInfo", get_class($this));
             // custom icon
             if ($this->ilias->getSetting("custom_icons")) {
                 $this->tabs_gui->addSubTabTarget("grp_icon_settings", $this->ctrl->getLinkTarget($this, 'editGroupIcons'), "editGroupIcons", get_class($this));
             }
             include_once "./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php";
             if (ilGoogleMapUtil::isActivated()) {
                 $this->tabs_gui->addSubTabTarget("grp_map_settings", $this->ctrl->getLinkTarget($this, 'editMapSettings'), "editMapSettings", get_class($this));
             }
             $this->tabs_gui->addSubTabTarget('groupings', $this->ctrl->getLinkTargetByClass('ilobjcoursegroupinggui', 'listGroupings'), 'listGroupings', get_class($this));
             include_once 'Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
             include_once 'Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php';
             // only show if export permission is granted
             if (ilPrivacySettings::_getInstance()->checkExportAccess($this->object->getRefId()) or ilCourseDefinedFieldDefinition::_hasFields($this->object->getId())) {
                 $this->tabs_gui->addSubTabTarget('grp_custom_user_fields', $this->ctrl->getLinkTargetByClass('ilobjectcustomuserfieldsgui'), '', 'ilobjectcustomuserfieldsgui');
             }
             break;
     }
 }
 /**
  * Members map
  */
 function membersMapObject()
 {
     global $tpl;
     $this->tabs_gui->setTabActive("members");
     $this->setSubTabs('members');
     $this->tabs_gui->setSubTabActive("crs_members_map");
     include_once "./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php";
     if (!ilGoogleMapUtil::isActivated() || !$this->object->getEnableCourseMap()) {
         return;
     }
     include_once "./Services/GoogleMaps/classes/class.ilGoogleMapGUI.php";
     $map = new ilGoogleMapGUI();
     $map->setMapId("course_map");
     $map->setWidth("700px");
     $map->setHeight("500px");
     $map->setLatitude($this->object->getLatitude());
     $map->setLongitude($this->object->getLongitude());
     $map->setZoom($this->object->getLocationZoom());
     $map->setEnableTypeControl(true);
     $map->setEnableNavigationControl(true);
     $map->setEnableCentralMarker(true);
     include_once './Modules/Course/classes/class.ilCourseParticipants.php';
     $members = ilCourseParticipants::_getInstanceByObjId($this->object->getId())->getParticipants();
     if (count($members)) {
         foreach ($members as $user_id) {
             $map->addUserMarker($user_id);
         }
     }
     $tpl->setContent($map->getHTML());
     $tpl->setLeftContent($map->getUserListHTML());
 }