29 include_once
'./Services/User/classes/class.ilUserDefinedFields.php';
36 $this->settings = $ilias->getAllSettings();
37 $lng->loadLanguageModule(
"jsmath");
38 $this->upload_error =
"";
39 $this->password_error =
"";
40 $lng->loadLanguageModule(
"user");
51 $next_class = $this->ctrl->getNextClass();
55 case "ilpublicuserprofilegui":
56 include_once(
"./Services/User/classes/class.ilPublicUserProfileGUI.php");
57 $_GET[
"user_id"] = $ilUser->getId();
59 $pub_profile_gui->setBackUrl($ilCtrl->getLinkTarget($this,
"showPersonalData"));
60 $ilCtrl->forwardCommand($pub_profile_gui);
66 $cmd = $this->ctrl->getCmd(
"showPersonalData");
81 if ($this->settings[
"usr_settings_hide_".$setting] == 1)
85 if ($this->settings[
"usr_settings_disable_".$setting] == 1)
99 if (isset($this->settings[
"usr_settings_hide_".$setting]) &&
100 $this->settings[
"usr_settings_hide_".$setting] == 1)
114 if ($this->settings[
"usr_settings_disable_".$setting] == 1)
130 if (!$this->form->hasFileUpload(
"userfile"))
132 if ($this->form->getItemByPostVar(
"userfile")->getDeletionFlag())
134 $ilUser->removeUserPicture();
141 $image_dir = $webspace_dir.
"/usr_images";
142 $store_file =
"usr_".$ilUser->getID().
".".
"jpg";
145 $ilUser->setPref(
"profile_image", $store_file);
149 $uploaded_file = $this->form->moveFileUpload($image_dir,
150 "userfile",
"upload_".$ilUser->getId().
"pic");
155 $this->ctrl->redirect($this,
"showProfile");
157 chmod($uploaded_file, 0770);
161 $show_file =
"$image_dir/usr_".$ilUser->getId().
".jpg";
162 $thumb_file =
"$image_dir/usr_".$ilUser->getId().
"_small.jpg";
163 $xthumb_file =
"$image_dir/usr_".$ilUser->getId().
"_xsmall.jpg";
164 $xxthumb_file =
"$image_dir/usr_".$ilUser->getId().
"_xxsmall.jpg";
173 ilUtil::execConvert($uploaded_file .
"[0] -geometry 200x200^ -gravity center -extent 200x200 -quality 100 JPEG:".$show_file);
174 ilUtil::execConvert($uploaded_file .
"[0] -geometry 100x100^ -gravity center -extent 100x100 -quality 100 JPEG:".$thumb_file);
175 ilUtil::execConvert($uploaded_file .
"[0] -geometry 75x75^ -gravity center -extent 75x75 -quality 100 JPEG:".$xthumb_file);
176 ilUtil::execConvert($uploaded_file .
"[0] -geometry 30x30^ -gravity center -extent 30x30 -quality 100 JPEG:".$xxthumb_file);
180 ilUtil::execConvert($uploaded_file .
"[0] -geometry 200x200 -quality 100 JPEG:".$show_file);
181 ilUtil::execConvert($uploaded_file .
"[0] -geometry 100x100 -quality 100 JPEG:".$thumb_file);
182 ilUtil::execConvert($uploaded_file .
"[0] -geometry 75x75 -quality 100 JPEG:".$xthumb_file);
183 ilUtil::execConvert($uploaded_file .
"[0] -geometry 30x30 -quality 100 JPEG:".$xxthumb_file);
198 $ilUser->removeUserPicture();
219 if ((
$_POST[
"chk_pub"])==
"on")
221 $ilUser->setPref(
"public_profile",
"y");
225 $ilUser->setPref(
"public_profile",
"n");
229 $val_array = array(
"institution",
"department",
"upload",
"street",
230 "zip",
"city",
"country",
"phone_office",
"phone_home",
"phone_mobile",
231 "fax",
"email",
"hobby",
"matriculation");
234 foreach($val_array as $key => $value)
236 if ((
$_POST[
"chk_".$value]) ==
"on")
238 $ilUser->setPref(
"public_".$value,
"y");
242 $ilUser->setPref(
"public_".$value,
"n");
247 if ($d_set->get(
"user_profile"))
249 if ((
$_POST[
"chk_delicious"]) ==
"on")
251 $ilUser->setPref(
"public_delicious",
"y");
255 $ilUser->setPref(
"public_delicious",
"n");
261 foreach($this->settings as $key => $val)
263 if (substr($key,0,8) ==
"require_")
265 $require_keys[] = substr($key,8);
269 foreach($require_keys as $key => $val)
272 $system_fields = array(
"login",
"default_role",
"passwd",
"passwd2");
273 if (!in_array($val, $system_fields))
277 if (isset($this->settings[
"require_" . $val]) && $this->settings[
"require_" . $val])
279 if (empty(
$_POST[
"usr_" . $val]))
281 ilUtil::sendFailure($this->lng->txt(
"fill_out_all_required_fields") .
": " . $this->lng->txt($val));
317 $ilUser->setGender(
$_POST[
"usr_gender"]);
323 $ilUser->setFullname();
383 if ($d_set->get(
"user_profile"))
401 $ilUser->setUserDefinedData(
$_POST[
'udf']);
412 if (
$_POST[
"usr_skin_style"] !=
"")
414 $sknst = explode(
":",
$_POST[
"usr_skin_style"]);
416 if ($ilUser->getPref(
"style") != $sknst[1] ||
417 $ilUser->getPref(
"skin") != $sknst[0])
419 $ilUser->setPref(
"skin", $sknst[0]);
420 $ilUser->setPref(
"style", $sknst[1]);
431 if (
$_POST[
"usr_language"] != $ilUser->getLanguage())
437 $ilUser->setLanguage(
$_POST[
"usr_language"]);
443 if (
$_POST[
"hits_per_page"] !=
"")
445 $ilUser->setPref(
"hits_per_page",
$_POST[
"hits_per_page"]);
452 $ilUser->setPref(
"show_users_online",
$_POST[
"show_users_online"]);
458 if (
$_POST[
"chk_hide_own_online_status"] !=
"")
460 $ilUser->setPref(
"hide_own_online_status",
"y");
464 $ilUser->setPref(
"hide_own_online_status",
"n");
481 $ilUser->setProfileIncomplete(
false);
484 $ilUser->setTitle($ilUser->getFullname());
485 $ilUser->setDescription($ilUser->getEmail());
491 if (!empty($this->password_error))
495 elseif (!empty($this->upload_error))
503 $this->ctrl->redirect($this,
"");
536 include_once(
"./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php");
542 $this->lng->loadLanguageModule(
"gmaps");
550 if ($latitude == 0 && $longitude == 0 && $zoom == 0)
553 $latitude = $def[
"latitude"];
554 $longitude = $def[
"longitude"];
555 $zoom = $def[
"zoom"];
561 $street = $this->lng->txt(
"street");
566 $city = $this->lng->txt(
"city");
571 $country = $this->lng->txt(
"country");
578 $loc_prop->setLongitude($longitude);
579 $loc_prop->setZoom($zoom);
580 $loc_prop->setAddress($street.
",".$city.
",".$country);
588 global $ilTabs, $ilUser;
591 $ilTabs->addTab(
"personal_data",
592 $this->lng->txt(
"personal_data"),
593 $this->ctrl->getLinkTarget($this,
"showPersonalData"));
596 $ilTabs->addTab(
"public_profile",
597 $this->lng->txt(
"public_profile"),
598 $this->ctrl->getLinkTarget($this,
"showPublicProfile"));
603 $ilTabs->addNonTabbedLink(
"profile_preview",
604 $this->lng->txt(
"user_profile_preview"),
605 $this->ctrl->getLinkTargetByClass(
"ilpublicuserprofilegui",
"view"));
613 if($this->
userSettingVisible(
"matriculation") or count($this->user_defined_fields->getVisibleDefinitions())
614 or $d_set->get(
"user_profile") ==
"1")
625 $user_defined_data = $ilUser->getUserDefinedData();
626 foreach($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition)
630 $this->tpl->setCurrentBlock(
"field_text");
632 if(!$definition[
'changeable'])
634 $this->tpl->setVariable(
"DISABLED_FIELD",
'disabled=\"disabled\"');
635 $this->tpl->setVariable(
"FIELD_NAME",
'udf['.$definition[
'field_id'].
']');
639 $this->tpl->setVariable(
"FIELD_NAME",
'udf['.$definition[
'field_id'].
']');
641 $this->tpl->parseCurrentBlock();
645 if($definition[
'changeable'])
647 $name =
'udf['.$definition[
'field_id'].
']';
655 $this->tpl->setCurrentBlock(
"field_select");
656 $this->tpl->setVariable(
"SELECT_BOX",
ilUtil::formSelect($user_defined_data[$field_id],
658 $this->user_defined_fields->fieldValuesToSelectArray(
659 $definition[
'field_values']),
661 true,0,
'',
'',$disabled));
662 $this->tpl->parseCurrentBlock();
664 $this->tpl->setCurrentBlock(
"user_defined");
666 if($definition[
'required'])
668 $name = $definition[
'field_name'].
"<span class=\"asterisk\">*</span>";
672 $name = $definition[
'field_name'];
674 $this->tpl->setVariable(
"TXT_FIELD_NAME",$name);
675 $this->tpl->parseCurrentBlock();
682 foreach($this->user_defined_fields->getVisibleDefinitions() as $definition)
684 $field_id = $definition[
'field_id'];
685 if($definition[
'required'] and !strlen(
$_POST[
'udf'][$field_id]))
699 $this->tpl->setVariable(
'HEADER', $this->lng->txt(
'personal_profile'));
715 $ilTabs->activateTab(
"personal_data");
717 $settings = $ilias->getAllSettings();
725 if ($ilUser->getProfileIncomplete())
730 $this->tpl->setContent($this->form->getHTML());
742 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
744 $this->form->setFormAction($this->ctrl->getFormAction($this));
747 $user_defined_data = $ilUser->getUserDefinedData();
749 foreach($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition)
753 $this->input[
"udf_".$definition[
'field_id']] =
754 new ilTextInputGUI($definition[
'field_name'],
"udf_".$definition[
'field_id']);
755 $this->input[
"udf_".$definition[
'field_id']]->setMaxLength(255);
756 $this->input[
"udf_".$definition[
'field_id']]->setSize(40);
760 $this->input[
"udf_".$definition[
'field_id']] =
762 $this->input[
"udf_".$definition[
'field_id']]->setUseRte(
true);
766 $options = $this->user_defined_fields->fieldValuesToSelectArray($definition[
'field_values']);
767 $this->input[
"udf_".$definition[
'field_id']] =
768 new ilSelectInputGUI($definition[
'field_name'],
"udf_".$definition[
'field_id']);
769 $this->input[
"udf_".$definition[
'field_id']]->setOptions($options);
772 $value = $user_defined_data[
"f_".$field_id];
773 $this->input[
"udf_".$definition[
'field_id']]->setValue($value);
775 if($definition[
'required'])
777 $this->input[
"udf_".$definition[
'field_id']]->setRequired(
true);
779 if(!$definition[
'changeable'] && (!$definition[
'required'] || $value))
781 $this->input[
"udf_".$definition[
'field_id']]->setDisabled(
true);
787 $options = array(
""=>$lng->txt(
"please_select")) + $options;
788 $this->input[
"udf_".$definition[
'field_id']]->setOptions($options);
793 include_once(
"./Services/User/classes/class.ilUserProfile.php");
795 $up->skipField(
"password");
796 $up->skipGroup(
"settings");
797 $up->skipGroup(
"preferences");
800 $up->addStandardFieldsToForm($this->form, $ilUser, $this->input);
804 $this->form->addCommandButton(
"savePersonalData", $lng->txt(
"save"));
817 if ($this->form->checkInput())
823 "firstname" =>
"FirstName",
824 "lastname" =>
"LastName",
826 "sel_country" =>
"SelectedCountry",
827 "phone_office" =>
"PhoneOffice",
828 "phone_home" =>
"PhoneHome",
829 "phone_mobile" =>
"PhoneMobile",
830 "referral_comment" =>
"Comment"
832 include_once(
"./Services/User/classes/class.ilUserProfile.php");
834 foreach($up->getStandardFields() as $f => $p)
837 $item = $this->form->getItemByPostVar(
"usr_".$f);
838 if($item && !$item->getDisabled())
840 $value = $this->form->getInput(
"usr_".$f);
844 if (is_array($value))
846 if (is_array($value[
'date']))
848 if (($value[
'd'] > 0) && ($value[
'm'] > 0) && ($value[
'y'] > 0))
850 $ilUser->setBirthday(sprintf(
"%04d-%02d-%02d", $value[
'y'], $value[
'm'], $value[
'd']));
854 $ilUser->setBirthday(
"");
859 $ilUser->setBirthday($value[
'date']);
870 $ilUser->{
"set".$m}($value);
875 $ilUser->setFullname();
880 $ilUser->setInstantMessengerId(
'icq', $this->form->getInput(
"usr_im_icq"));
881 $ilUser->setInstantMessengerId(
'yahoo', $this->form->getInput(
"usr_im_yahoo"));
882 $ilUser->setInstantMessengerId(
'msn', $this->form->getInput(
"usr_im_msn"));
883 $ilUser->setInstantMessengerId(
'aim', $this->form->getInput(
"usr_im_aim"));
884 $ilUser->setInstantMessengerId(
'skype', $this->form->getInput(
"usr_im_skype"));
885 $ilUser->setInstantMessengerId(
'jabber', $this->form->getInput(
"usr_im_jabber"));
886 $ilUser->setInstantMessengerId(
'voip', $this->form->getInput(
"usr_im_voip"));
890 include_once(
"./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php");
893 $location = $this->form->getInput(
"location");
900 $defs = $this->user_defined_fields->getVisibleDefinitions();
902 foreach ($defs as $definition)
904 $f =
"udf_".$definition[
'field_id'];
905 $item = $this->form->getItemByPostVar($f);
906 if ($item && !$item->getDisabled())
908 $udf[$definition[
'field_id']] = $this->form->getInput($f);
911 $ilUser->setUserDefinedData($udf);
914 $un = $this->form->getInput(
'username');
915 if((
int)$ilSetting->get(
'allow_change_loginname') &&
916 $un != $ilUser->getLogin())
921 $this->form->getItemByPostVar(
'username')->setAlert($this->lng->txt(
'login_invalid'));
927 $this->form->getItemByPostVar(
'username')->setAlert($this->lng->txt(
'loginname_already_exists'));
932 $ilUser->setLogin($un);
936 $ilUser->updateLogin($ilUser->getLogin());
937 $ilAuth->setAuth($ilUser->getLogin());
943 $this->form->getItemByPostVar(
'username')->setAlert($e->getMessage());
955 $ilUser->setProfileIncomplete(
false);
958 $ilUser->setTitle($ilUser->getFullname());
959 $ilUser->setDescription($ilUser->getEmail());
965 unset(
$_SESSION[
'profile_complete_redirect']);
969 $ilCtrl->redirect($this,
"showPersonalData");
973 $this->form->setValuesByPost();
986 function showPublicProfile($a_no_init =
false)
990 $ilTabs->activateTab(
"public_profile");
996 $this->initPublicProfileForm();
999 $ptpl =
new ilTemplate(
"tpl.edit_personal_profile.html",
true,
true,
"Services/User");
1000 $ptpl->setVariable(
"FORM", $this->form->getHTML());
1001 include_once(
"./Services/User/classes/class.ilPublicUserProfileGUI.php");
1003 $ptpl->setVariable(
"PREVIEW", $pub_profile->getEmbeddable());
1004 $this->tpl->setContent($ptpl->get());
1013 protected function getProfilePortfolio()
1017 if ($ilSetting->get(
'user_portfolios'))
1019 include_once
"Services/Portfolio/classes/class.ilObjPortfolio.php";
1029 public function initPublicProfileForm()
1033 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
1036 $this->form->setTitle($lng->txt(
"public_profile"));
1037 $this->form->setDescription($lng->txt(
"user_public_profile_info").$prtf);
1038 $this->form->setFormAction($this->ctrl->getFormAction($this));
1040 $portfolio_id = $this->getProfilePortfolio();
1046 $radg->
setInfo($this->lng->txt(
"user_activate_public_profile_info"));
1047 $pub_prof = in_array($ilUser->prefs[
"public_profile"], array(
"y",
"n",
"g"))
1048 ? $ilUser->prefs[
"public_profile"]
1050 if (!$ilSetting->get(
'enable_global_profiles') && $pub_prof ==
"g")
1054 $radg->setValue($pub_prof);
1055 $op1 =
new ilRadioOption($lng->txt(
"usr_public_profile_disabled"),
"n",$lng->txt(
"usr_public_profile_disabled_info"));
1056 $radg->addOption($op1);
1057 $op2 =
new ilRadioOption($lng->txt(
"usr_public_profile_logged_in"),
"y");
1058 $radg->addOption($op2);
1059 if ($ilSetting->get(
'enable_global_profiles'))
1061 $op3 =
new ilRadioOption($lng->txt(
"usr_public_profile_global"),
"g");
1062 $radg->addOption($op3);
1064 $this->form->addItem($radg);
1066 $radg->
setInfo($lng->txt(
"user_profile_portfolio"));
1070 $prtf = $lng->txt(
"user_profile_portfolio_selected");
1071 $prtf .=
"<br /><a href=\"ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToPortfolio&prt_id=".$portfolio_id.
"\">» ".
1072 $lng->txt(
"portfolio").
"</a>";
1075 $info->setHTML($prtf);
1076 $this->form->addItem($info);
1079 $this->showPublicProfileFields($this->form, $ilUser->prefs);
1081 $this->form->addCommandButton(
"savePublicProfile", $lng->txt(
"save"));
1091 public function showPublicProfileFields(ilPropertyformGUI $form, array $prefs, $parent = null)
1095 $birthday = $ilUser->getBirthday();
1100 $gender = $ilUser->getGender();
1103 $gender = $this->lng->txt(
"gender_".$gender);
1106 if ($ilUser->getSelectedCountry() !=
"")
1108 $this->lng->loadLanguageModule(
"meta");
1109 $txt_sel_country = $this->lng->txt(
"meta_c_".$ilUser->getSelectedCountry());
1114 "title" => $ilUser->getUTitle(),
1115 "birthday" => $birthday,
1116 "gender" => $gender,
1117 "institution" => $ilUser->getInstitution(),
1118 "department" => $ilUser->getDepartment(),
1120 "street" => $ilUser->getStreet(),
1121 "zipcode" => $ilUser->getZipcode(),
1122 "city" => $ilUser->getCity(),
1123 "country" => $ilUser->getCountry(),
1124 "sel_country" => $txt_sel_country,
1125 "phone_office" => $ilUser->getPhoneOffice(),
1126 "phone_home" => $ilUser->getPhoneHome(),
1127 "phone_mobile" => $ilUser->getPhoneMobile(),
1128 "fax" => $ilUser->getFax(),
1129 "email" => $ilUser->getEmail(),
1130 "hobby" => $ilUser->getHobby(),
1131 "matriculation" => $ilUser->getMatriculation(),
1132 "delicious" => $ilUser->getDelicious()
1136 include_once(
"./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php");
1139 $val_array[
"location"] =
"";
1142 foreach($val_array as $key => $value)
1144 if ($this->userSettingVisible($key))
1147 if ($key ==
"upload")
1155 if ($prefs[
"public_".$key] ==
"y")
1160 $cb->setOptionTitle($value);
1164 $form->addItem($cb);
1168 $parent->addSubItem($cb);
1173 $im_arr = array(
"icq",
"yahoo",
"msn",
"aim",
"skype",
"jabber",
"voip");
1174 if ($this->userSettingVisible(
"instant_messengers"))
1176 foreach ($im_arr as $im)
1182 if ($prefs[
"public_im_".$im] !=
"n")
1184 $cb->setChecked(
true);
1189 $form->addItem($cb);
1193 $parent->addSubItem($cb);
1199 $user_defined_data = $ilUser->getUserDefinedData();
1200 foreach($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition)
1203 $cb =
new ilCheckboxInputGUI($definition[
"field_name"],
"chk_udf_".$definition[
"field_id"]);
1204 $cb->setOptionTitle($user_defined_data[
"f_".$definition[
"field_id"]]);
1205 if ($prefs[
"public_udf_".$definition[
"field_id"]] ==
"y")
1207 $cb->setChecked(
true);
1212 $form->addItem($cb);
1216 $parent->addSubItem($cb);
1225 public function savePublicProfile()
1229 $this->initPublicProfileForm();
1230 if ($this->form->checkInput())
1233 if(isset(
$_POST[
"public_profile"]))
1235 $ilUser->setPref(
"public_profile",
$_POST[
"public_profile"]);
1239 $val_array = array(
"title",
"birthday",
"gender",
"institution",
"department",
"upload",
"street",
1240 "zipcode",
"city",
"country",
"sel_country",
"phone_office",
"phone_home",
"phone_mobile",
1241 "fax",
"email",
"hobby",
"matriculation",
"location");
1244 foreach($val_array as $key => $value)
1246 if ((
$_POST[
"chk_".$value]))
1248 $ilUser->setPref(
"public_".$value,
"y");
1252 $ilUser->setPref(
"public_".$value,
"n");
1256 $im_arr = array(
"icq",
"yahoo",
"msn",
"aim",
"skype",
"jabber",
"voip");
1257 if ($this->userSettingVisible(
"instant_messengers"))
1259 foreach ($im_arr as $im)
1261 if ((
$_POST[
"chk_im_".$im]))
1263 $ilUser->setPref(
"public_im_".$im,
"y");
1267 $ilUser->setPref(
"public_im_".$im,
"n");
1275 if ((
$_POST[
"chk_delicious"]))
1277 $ilUser->setPref(
"public_delicious",
"y");
1281 $ilUser->setPref(
"public_delicious",
"n");
1286 foreach($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition)
1288 if ((
$_POST[
"chk_udf_".$definition[
"field_id"]]))
1290 $ilUser->setPref(
"public_udf_".$definition[
"field_id"],
"y");
1294 $ilUser->setPref(
"public_udf_".$definition[
"field_id"],
"n");
1300 $ilCtrl->redirect($this,
"showPublicProfile");
1302 $this->form->setValuesByPost();
1303 $tpl->showPublicProfile(
true);