ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilPersonalProfileGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
13{
14 public $tpl;
15
19 protected $lng;
20
24 protected $ctrl;
25
26 public $user_defined_fields = null;
27
29 protected $tabs;
30
33
37 protected $checklist;
38
43
48
53 public function __construct(
55 ) {
56 global $DIC;
57
58 $this->tabs = $DIC->tabs();
59 $this->user = $DIC->user();
60 $this->lng = $DIC->language();
61 $this->setting = $DIC->settings();
62 $this->tpl = $DIC->ui()->mainTemplate();
63 $this->ctrl = $DIC->ctrl();
64
65 if ($termsOfServiceEvaluation === null) {
66 $termsOfServiceEvaluation = $DIC['tos.document.evaluator'];
67 }
68 $this->termsOfServiceEvaluation = $termsOfServiceEvaluation;
69
70 include_once './Services/User/classes/class.ilUserDefinedFields.php';
71 $this->user_defined_fields = &ilUserDefinedFields::_getInstance();
72
73 $this->lng->loadLanguageModule("jsmath");
74 $this->lng->loadLanguageModule("pd");
75 $this->upload_error = "";
76 $this->password_error = "";
77 $this->lng->loadLanguageModule("user");
78 $this->ctrl->saveParameter($this, "prompted");
79
80 $this->checklist = new ilProfileChecklistGUI();
81 $this->checklist_status = new ilProfileChecklistStatus();
82
83 $this->user_settings_config = new ilUserSettingsConfig();
84 }
85
89 public function executeCommand()
90 {
91 global $DIC;
92
93 $ilUser = $DIC['ilUser'];
94 $ilCtrl = $DIC['ilCtrl'];
95 $tpl = $DIC['tpl'];
96 $ilTabs = $DIC['ilTabs'];
97 $lng = $DIC['lng'];
98
99 $next_class = $this->ctrl->getNextClass();
100
101 switch ($next_class) {
102 case "ilpublicuserprofilegui":
103 include_once("./Services/User/classes/class.ilPublicUserProfileGUI.php");
104 $_GET["user_id"] = $ilUser->getId();
105 $pub_profile_gui = new ilPublicUserProfileGUI($_GET["user_id"]);
106 $pub_profile_gui->setBackUrl($ilCtrl->getLinkTarget($this, "showPersonalData"));
107 $ilCtrl->forwardCommand($pub_profile_gui);
108 $tpl->printToStdout();
109 break;
110
111 case "iluserprivacysettingsgui":
112 $this->setHeader();
113 $this->setTabs();
114 $ilTabs->activateTab("visibility_settings");
116 $gui = new ilUserPrivacySettingsGUI();
117 $ilCtrl->forwardCommand($gui);
118 break;
119
120 default:
121 $this->setTabs();
122 $cmd = $this->ctrl->getCmd("showPersonalData");
123 $this->$cmd();
124 break;
125 }
126 return true;
127 }
128
129
134 public function workWithUserSetting(string $setting) : bool
135 {
136 return $this->user_settings_config->isVisibleAndChangeable($setting);
137 }
138
143 public function userSettingVisible(string $setting) : bool
144 {
145 return $this->user_settings_config->isVisible($setting);
146 }
147
152 public function userSettingEnabled(string $setting) : bool
153 {
154 return $this->user_settings_config->isChangeable($setting);
155 }
156
160 public function uploadUserPicture()
161 {
162 global $DIC;
163
164 $ilUser = $DIC['ilUser'];
165
166 if ($this->workWithUserSetting("upload")) {
167 if (!$this->form->hasFileUpload("userfile")) {
168 if ($this->form->getItemByPostVar("userfile")->getDeletionFlag()) {
169 $ilUser->removeUserPicture();
170 }
171 return;
172 } else {
173 $webspace_dir = ilUtil::getWebspaceDir();
174 $image_dir = $webspace_dir . "/usr_images";
175 $store_file = "usr_" . $ilUser->getID() . "." . "jpg";
176
177 // store filename
178 $ilUser->setPref("profile_image", $store_file);
179 $ilUser->update();
180
181 // move uploaded file
182
183 $pi = pathinfo($_FILES["userfile"]["name"]);
184 $uploaded_file = $this->form->moveFileUpload(
185 $image_dir,
186 "userfile",
187 "upload_" . $ilUser->getId() . "." . $pi["extension"]
188 );
189 if (!$uploaded_file) {
190 ilUtil::sendFailure($this->lng->txt("upload_error", true));
191 $this->ctrl->redirect($this, "showProfile");
192 }
193 chmod($uploaded_file, 0770);
194
195 // take quality 100 to avoid jpeg artefacts when uploading jpeg files
196 // taking only frame [0] to avoid problems with animated gifs
197 $show_file = "$image_dir/usr_" . $ilUser->getId() . ".jpg";
198 $thumb_file = "$image_dir/usr_" . $ilUser->getId() . "_small.jpg";
199 $xthumb_file = "$image_dir/usr_" . $ilUser->getId() . "_xsmall.jpg";
200 $xxthumb_file = "$image_dir/usr_" . $ilUser->getId() . "_xxsmall.jpg";
201 $uploaded_file = ilUtil::escapeShellArg($uploaded_file);
202 $show_file = ilUtil::escapeShellArg($show_file);
203 $thumb_file = ilUtil::escapeShellArg($thumb_file);
204 $xthumb_file = ilUtil::escapeShellArg($xthumb_file);
205 $xxthumb_file = ilUtil::escapeShellArg($xxthumb_file);
206
207 if (ilUtil::isConvertVersionAtLeast("6.3.8-3")) {
208 ilUtil::execConvert($uploaded_file . "[0] -geometry 200x200^ -gravity center -extent 200x200 -quality 100 JPEG:" . $show_file);
209 ilUtil::execConvert($uploaded_file . "[0] -geometry 100x100^ -gravity center -extent 100x100 -quality 100 JPEG:" . $thumb_file);
210 ilUtil::execConvert($uploaded_file . "[0] -geometry 75x75^ -gravity center -extent 75x75 -quality 100 JPEG:" . $xthumb_file);
211 ilUtil::execConvert($uploaded_file . "[0] -geometry 30x30^ -gravity center -extent 30x30 -quality 100 JPEG:" . $xxthumb_file);
212 } else {
213 ilUtil::execConvert($uploaded_file . "[0] -geometry 200x200 -quality 100 JPEG:" . $show_file);
214 ilUtil::execConvert($uploaded_file . "[0] -geometry 100x100 -quality 100 JPEG:" . $thumb_file);
215 ilUtil::execConvert($uploaded_file . "[0] -geometry 75x75 -quality 100 JPEG:" . $xthumb_file);
216 ilUtil::execConvert($uploaded_file . "[0] -geometry 30x30 -quality 100 JPEG:" . $xxthumb_file);
217 }
218 }
219 }
220
221 // $this->saveProfile();
222 }
223
227 public function removeUserPicture()
228 {
229 global $DIC;
230
231 $ilUser = $DIC['ilUser'];
232
233 $ilUser->removeUserPicture();
234
235 $this->saveProfile();
236 }
237
238
239
243 public function saveProfile()
244 {
245 global $DIC;
246
247 $ilUser = $DIC['ilUser'];
248 $ilSetting = $DIC['ilSetting'];
249
250 //init checking var
251 $form_valid = true;
252
253 // testing by ratana ty:
254 // if people check on check box it will
255 // write some datata to table usr_pref
256 // if check on Public Profile
257 if (($_POST["chk_pub"]) == "on") {
258 $ilUser->setPref("public_profile", "y");
259 } else {
260 $ilUser->setPref("public_profile", "n");
261 }
262
263 // if check on Institute
264 $val_array = array("institution", "department", "upload", "street",
265 "zip", "city", "country", "phone_office", "phone_home", "phone_mobile",
266 "fax", "email", "second_email", "hobby", "matriculation");
267
268 // set public profile preferences
269 foreach ($val_array as $key => $value) {
270 if (($_POST["chk_" . $value]) == "on") {
271 $ilUser->setPref("public_" . $value, "y");
272 } else {
273 $ilUser->setPref("public_" . $value, "n");
274 }
275 }
276
277 // check dynamically required fields
278 foreach ($this->settings as $key => $val) {
279 if (substr($key, 0, 8) == "require_") {
280 $require_keys[] = substr($key, 8);
281 }
282 }
283
284 foreach ($require_keys as $key => $val) {
285 // exclude required system and registration-only fields
286 $system_fields = array("login", "default_role", "passwd", "passwd2");
287 if (!in_array($val, $system_fields)) {
288 if ($this->workWithUserSetting($val)) {
289 if (isset($this->settings["require_" . $val]) && $this->settings["require_" . $val]) {
290 if (empty($_POST["usr_" . $val])) {
291 ilUtil::sendFailure($this->lng->txt("fill_out_all_required_fields") . ": " . $this->lng->txt($val));
292 $form_valid = false;
293 }
294 }
295 }
296 }
297 }
298
299 // Check user defined required fields
300 if ($form_valid and !$this->__checkUserDefinedRequiredFields()) {
301 ilUtil::sendFailure($this->lng->txt("fill_out_all_required_fields"));
302 $form_valid = false;
303 }
304
305 // check email
306 if ($this->workWithUserSetting("email")) {
307 if (!ilUtil::is_email($_POST["usr_email"]) and !empty($_POST["usr_email"]) and $form_valid) {
308 ilUtil::sendFailure($this->lng->txt("email_not_valid"));
309 $form_valid = false;
310 }
311 }
312 // check second email
313 if ($this->workWithUserSetting("second_email")) {
314 if (!ilUtil::is_email($_POST["usr_second_email"]) and !empty($_POST["usr_second_email"]) and $form_valid) {
315 ilUtil::sendFailure($this->lng->txt("second_email_not_valid"));
316 $form_valid = false;
317 }
318 }
319
320 //update user data (not saving!)
321 if ($this->workWithUserSetting("firstname")) {
322 $ilUser->setFirstName(ilUtil::stripSlashes($_POST["usr_firstname"]));
323 }
324 if ($this->workWithUserSetting("lastname")) {
325 $ilUser->setLastName(ilUtil::stripSlashes($_POST["usr_lastname"]));
326 }
327 if ($this->workWithUserSetting("gender")) {
328 $ilUser->setGender($_POST["usr_gender"]);
329 }
330 if ($this->workWithUserSetting("title")) {
331 $ilUser->setUTitle(ilUtil::stripSlashes($_POST["usr_title"]));
332 }
333 $ilUser->setFullname();
334 if ($this->workWithUserSetting("institution")) {
335 $ilUser->setInstitution(ilUtil::stripSlashes($_POST["usr_institution"]));
336 }
337 if ($this->workWithUserSetting("department")) {
338 $ilUser->setDepartment(ilUtil::stripSlashes($_POST["usr_department"]));
339 }
340 if ($this->workWithUserSetting("street")) {
341 $ilUser->setStreet(ilUtil::stripSlashes($_POST["usr_street"]));
342 }
343 if ($this->workWithUserSetting("zipcode")) {
344 $ilUser->setZipcode(ilUtil::stripSlashes($_POST["usr_zipcode"]));
345 }
346 if ($this->workWithUserSetting("city")) {
347 $ilUser->setCity(ilUtil::stripSlashes($_POST["usr_city"]));
348 }
349 if ($this->workWithUserSetting("country")) {
350 $ilUser->setCountry(ilUtil::stripSlashes($_POST["usr_country"]));
351 }
352 if ($this->workWithUserSetting("phone_office")) {
353 $ilUser->setPhoneOffice(ilUtil::stripSlashes($_POST["usr_phone_office"]));
354 }
355 if ($this->workWithUserSetting("phone_home")) {
356 $ilUser->setPhoneHome(ilUtil::stripSlashes($_POST["usr_phone_home"]));
357 }
358 if ($this->workWithUserSetting("phone_mobile")) {
359 $ilUser->setPhoneMobile(ilUtil::stripSlashes($_POST["usr_phone_mobile"]));
360 }
361 if ($this->workWithUserSetting("fax")) {
362 $ilUser->setFax(ilUtil::stripSlashes($_POST["usr_fax"]));
363 }
364 if ($this->workWithUserSetting("email")) {
365 $ilUser->setEmail(ilUtil::stripSlashes($_POST["usr_email"]));
366 }
367 if ($this->workWithUserSetting("second_email")) {
368 $ilUser->setSecondEmail(ilUtil::stripSlashes($_POST["usr_second_email"]));
369 }
370 if ($this->workWithUserSetting("hobby")) {
371 $ilUser->setHobby(ilUtil::stripSlashes($_POST["usr_hobby"]));
372 }
373 if ($this->workWithUserSetting("referral_comment")) {
374 $ilUser->setComment(ilUtil::stripSlashes($_POST["usr_referral_comment"]));
375 }
376 if ($this->workWithUserSetting("matriculation")) {
377 $ilUser->setMatriculation(ilUtil::stripSlashes($_POST["usr_matriculation"]));
378 }
379
380 // Set user defined data
381 $ilUser->setUserDefinedData($_POST['udf']);
382
383 // everthing's ok. save form data
384 if ($form_valid) {
385 // init reload var. page should only be reloaded if skin or style were changed
386 $reload = false;
387
388 if ($this->workWithUserSetting("skin_style")) {
389 //set user skin and style
390 if ($_POST["usr_skin_style"] != "") {
391 $sknst = explode(":", $_POST["usr_skin_style"]);
392
393 if ($ilUser->getPref("style") != $sknst[1] ||
394 $ilUser->getPref("skin") != $sknst[0]) {
395 $ilUser->setPref("skin", $sknst[0]);
396 $ilUser->setPref("style", $sknst[1]);
397 $reload = true;
398 }
399 }
400 }
401
402 if ($this->workWithUserSetting("language")) {
403 // reload page if language was changed
404 //if ($_POST["usr_language"] != "" and $_POST["usr_language"] != $_SESSION['lang'])
405 // (this didn't work as expected, alex)
406 if ($_POST["usr_language"] != $ilUser->getLanguage()) {
407 $reload = true;
408 }
409
410 // set user language
411 $ilUser->setLanguage($_POST["usr_language"]);
412 }
413 if ($this->workWithUserSetting("hits_per_page")) {
414 // set user hits per page
415 if ($_POST["hits_per_page"] != "") {
416 $ilUser->setPref("hits_per_page", $_POST["hits_per_page"]);
417 }
418 }
419
420 // set show users online
421 /*if ($this->workWithUserSetting("show_users_online"))
422 {
423 $ilUser->setPref("show_users_online", $_POST["show_users_online"]);
424 }*/
425
426 // set hide own online_status
427 if ($this->workWithUserSetting("hide_own_online_status")) {
428 if ($_POST["chk_hide_own_online_status"] != "") {
429 $ilUser->setPref("hide_own_online_status", "y");
430 } else {
431 $ilUser->setPref("hide_own_online_status", "n");
432 }
433 }
434
435 // personal desktop items in news block
436 /* Subscription Concept is abandonded for now, we show all news of pd items (Alex)
437 if ($_POST["pd_items_news"] != "")
438 {
439 $ilUser->setPref("pd_items_news","y");
440 }
441 else
442 {
443 $ilUser->setPref("pd_items_news","n");
444 }
445 */
446
447 // profile ok
448 $ilUser->setProfileIncomplete(false);
449
450 // save user data & object_data
451 $ilUser->setTitle($ilUser->getFullname());
452 $ilUser->setDescription($ilUser->getEmail());
453
454 $ilUser->update();
455
456 // update lucene index
457 include_once './Services/Search/classes/Lucene/class.ilLuceneIndexer.php';
458 ilLuceneIndexer::updateLuceneIndex(array($GLOBALS['DIC']['ilUser']->getId()));
459
460
461 // reload page only if skin or style were changed
462 // feedback
463 if (!empty($this->password_error)) {
464 ilUtil::sendFailure($this->password_error, true);
465 } elseif (!empty($this->upload_error)) {
466 ilUtil::sendFailure($this->upload_error, true);
467 } elseif ($reload) {
468 // feedback
469 ilUtil::sendSuccess($this->lng->txt("saved_successfully"), true);
470 $this->ctrl->redirect($this, "");
471 } else {
472 ilUtil::sendSuccess($this->lng->txt("saved_successfully"), true);
473 }
474 }
475
476 $this->showProfile();
477 }
478
484 public function showProfile()
485 {
486 $this->showPersonalData();
487 }
488
492 protected function showUserAgreement()
493 {
494 $this->tabs->clearTargets();
495 $this->tabs->clearSubTabs();
496
497 $tpl = new \ilTemplate('tpl.view_terms_of_service.html', true, true, 'Services/Init');
498
499 $this->tpl->setTitle($this->lng->txt('usr_agreement'));
500
501 $handleDocument = \ilTermsOfServiceHelper::isEnabled() && $this->termsOfServiceEvaluation->hasDocument();
502 if ($handleDocument) {
503 $document = $this->termsOfServiceEvaluation->document();
504 $tpl->setVariable('TERMS_OF_SERVICE_CONTENT', $document->content());
505 } else {
506 $tpl->setVariable(
507 'TERMS_OF_SERVICE_CONTENT',
508 sprintf(
509 $this->lng->txt('no_agreement_description'),
511 )
512 );
513 }
514
515 $this->tpl->setContent($tpl->get());
516 $this->tpl->setPermanentLink('usr', null, 'agreement');
517 $this->tpl->printToStdout();
518 }
519
526 public function addLocationToForm(ilPropertyFormGUI $a_form, ilObjUser $a_user)
527 {
528 global $DIC;
529
530 $ilCtrl = $DIC['ilCtrl'];
531
532 // check map activation
533 include_once("./Services/Maps/classes/class.ilMapUtil.php");
534 if (!ilMapUtil::isActivated()) {
535 return;
536 }
537
538 // Don't really know if this is still necessary...
539 $this->lng->loadLanguageModule("maps");
540
541 // Get user settings
542 $latitude = $a_user->getLatitude();
543 $longitude = $a_user->getLongitude();
544 $zoom = $a_user->getLocationZoom();
545
546 // Get Default settings, when nothing is set
547 if ($latitude == 0 && $longitude == 0 && $zoom == 0) {
549 $latitude = $def["latitude"];
550 $longitude = $def["longitude"];
551 $zoom = $def["zoom"];
552 }
553
554 $street = $a_user->getStreet();
555 if (!$street) {
556 $street = $this->lng->txt("street");
557 }
558 $city = $a_user->getCity();
559 if (!$city) {
560 $city = $this->lng->txt("city");
561 }
562 $country = $a_user->getCountry();
563 if (!$country) {
564 $country = $this->lng->txt("country");
565 }
566
567 // location property
568 $loc_prop = new ilLocationInputGUI(
569 $this->lng->txt("location"),
570 "location"
571 );
572 $loc_prop->setLatitude($latitude);
573 $loc_prop->setLongitude($longitude);
574 $loc_prop->setZoom($zoom);
575 $loc_prop->setAddress($street . "," . $city . "," . $country);
576
577 $a_form->addItem($loc_prop);
578 }
579
580 // init sub tabs
581 public function setTabs()
582 {
583 global $DIC;
584
585 $ilTabs = $DIC['ilTabs'];
586 $ilUser = $DIC['ilUser'];
587 $ilHelp = $DIC['ilHelp'];
588
589 $ilHelp->setScreenIdComponent("user");
590
591 // personal data
592 $ilTabs->addTab(
593 "personal_data",
594 $this->lng->txt("user_profile_data"),
595 $this->ctrl->getLinkTarget($this, "showPersonalData")
596 );
597
598 // publishing options
599 $ilTabs->addTab(
600 "public_profile",
601 $this->lng->txt("user_publish_options"),
602 $this->ctrl->getLinkTarget($this, "showPublicProfile")
603 );
604
605 // visibility settings
606 $txt_visibility = $this->checklist_status->anyVisibilitySettings()
607 ? $this->lng->txt("user_visibility_settings")
608 : $this->lng->txt("preview");
609 $ilTabs->addTab(
610 "visibility_settings",
611 $txt_visibility,
612 $this->ctrl->getLinkTargetByClass("ilUserPrivacySettingsGUI", "")
613 );
614
615 // export
616 $ilTabs->addTab(
617 "export",
618 $this->lng->txt("export") . "/" . $this->lng->txt("import"),
619 $this->ctrl->getLinkTarget($this, "showExportImport")
620 );
621
622 // #17570
623 /*
624 if(($ilUser->getPref("public_profile") &&
625 $ilUser->getPref("public_profile") != "n") ||
626 $this->getProfilePortfolio())
627 {
628 // profile preview
629 $ilTabs->addNonTabbedLink("profile_preview",
630 $this->lng->txt("user_profile_preview"),
631 $this->ctrl->getLinkTargetByClass("ilpublicuserprofilegui", "view"));
632 }*/
633 }
634
635
636 public function __showOtherInformations()
637 {
638 $d_set = new ilSetting("delicous");
639 if ($this->userSettingVisible("matriculation") or count($this->user_defined_fields->getVisibleDefinitions())
640 or $d_set->get("user_profile") == "1") {
641 return true;
642 }
643 return false;
644 }
645
646 public function __showUserDefinedFields()
647 {
648 global $DIC;
649
650 $ilUser = $DIC['ilUser'];
651
652 $user_defined_data = $ilUser->getUserDefinedData();
653 foreach ($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition) {
654 if ($definition['field_type'] == UDF_TYPE_TEXT) {
655 $this->tpl->setCurrentBlock("field_text");
656 $this->tpl->setVariable("FIELD_VALUE", ilUtil::prepareFormOutput($user_defined_data[$field_id]));
657 if (!$definition['changeable']) {
658 $this->tpl->setVariable("DISABLED_FIELD", 'disabled=\"disabled\"');
659 $this->tpl->setVariable("FIELD_NAME", 'udf[' . $definition['field_id'] . ']');
660 } else {
661 $this->tpl->setVariable("FIELD_NAME", 'udf[' . $definition['field_id'] . ']');
662 }
663 $this->tpl->parseCurrentBlock();
664 } else {
665 if ($definition['changeable']) {
666 $name = 'udf[' . $definition['field_id'] . ']';
667 $disabled = false;
668 } else {
669 $name = '';
670 $disabled = true;
671 }
672 $this->tpl->setCurrentBlock("field_select");
673 $this->tpl->setVariable("SELECT_BOX", ilUtil::formSelect(
674 $user_defined_data[$field_id],
675 $name,
676 $this->user_defined_fields->fieldValuesToSelectArray(
677 $definition['field_values']
678 ),
679 false,
680 true,
681 0,
682 '',
683 '',
684 $disabled
685 ));
686 $this->tpl->parseCurrentBlock();
687 }
688 $this->tpl->setCurrentBlock("user_defined");
689
690 if ($definition['required']) {
691 $name = $definition['field_name'] . "<span class=\"asterisk\">*</span>";
692 } else {
693 $name = $definition['field_name'];
694 }
695 $this->tpl->setVariable("TXT_FIELD_NAME", $name);
696 $this->tpl->parseCurrentBlock();
697 }
698 return true;
699 }
700
702 {
703 foreach ($this->user_defined_fields->getVisibleDefinitions() as $definition) {
704 $field_id = $definition['field_id'];
705 if ($definition['required'] and !strlen($_POST['udf'][$field_id])) {
706 return false;
707 }
708 }
709 return true;
710 }
711
715 public function setHeader()
716 {
717 $this->tpl->setTitle($this->lng->txt('personal_profile'));
718 }
719
720 //
721 //
722 // PERSONAL DATA FORM
723 //
724 //
725
729 public function showPersonalData($a_no_init = false, $a_migration_started = false)
730 {
731 global $DIC;
732
733 $ilUser = $DIC['ilUser'];
734 $lng = $DIC['lng'];
735 $ilTabs = $DIC['ilTabs'];
736 $prompt_service = new ilUserProfilePromptService();
737
738 $ilTabs->activateTab("personal_data");
739 $ctrl = $DIC->ctrl();
740
741 $it = "";
742 if ($_GET["prompted"] == 1) {
743 $it = $prompt_service->data()->getSettings()->getPromptText($ilUser->getLanguage());
744 }
745 if ($it === "") {
746 $it = $prompt_service->data()->getSettings()->getInfoText($ilUser->getLanguage());
747 }
748 if (trim($it) !== "") {
749 $pub_prof = in_array($ilUser->prefs["public_profile"], array("y", "n", "g"))
750 ? $ilUser->prefs["public_profile"]
751 : "n";
752 $box = $DIC->ui()->factory()->messageBox()->info($it);
753 if ($pub_prof === "n") {
754 $box = $box->withLinks(
755 [$DIC->ui()->factory()->link()->standard(
756 $lng->txt("user_make_profile_public"),
757 $ctrl->getLinkTarget($this, "showPublicProfile")
758 )]
759 );
760 }
761 $it = $DIC->ui()->renderer()->render($box);
762 }
763 $this->setHeader();
764
766
767 if (!$a_no_init) {
768 $this->initPersonalDataForm();
769 // catch feedback message
770 if ($ilUser->getProfileIncomplete()) {
771 ilUtil::sendInfo($lng->txt("profile_incomplete"));
772 }
773 }
774 $this->tpl->setContent($it . $this->form->getHTML());
775
776 $this->tpl->printToStdout();
777 }
778
782 public function initPersonalDataForm()
783 {
784 global $DIC;
785
786 $ilSetting = $DIC['ilSetting'];
787 $lng = $DIC['lng'];
788 $ilUser = $DIC['ilUser'];
789 $styleDefinition = $DIC['styleDefinition'];
790 $rbacreview = $DIC['rbacreview'];
791
792 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
793 $this->form = new ilPropertyFormGUI();
794 $this->form->setFormAction($this->ctrl->getFormAction($this));
795
796 // user defined fields
797 $user_defined_data = $ilUser->getUserDefinedData();
798
799
800 foreach ($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition) {
801 $value = $user_defined_data["f_" . $field_id];
802
803 include_once './Services/User/classes/class.ilCustomUserFieldsHelper.php';
804 $fprop = ilCustomUserFieldsHelper::getInstance()->getFormPropertyForDefinition(
805 $definition,
806 $definition['changeable'],
807 $value
808 );
809 if ($fprop instanceof ilFormPropertyGUI) {
810 $this->input['udf_' . $definition['field_id']] = $fprop;
811 }
812 }
813
814 // standard fields
815 include_once("./Services/User/classes/class.ilUserProfile.php");
816 $up = new ilUserProfile();
817 $up->skipField("password");
818 $up->skipGroup("settings");
819 $up->skipGroup("preferences");
820
821 $up->setAjaxCallback(
822 $this->ctrl->getLinkTargetByClass('ilPublicUserProfileGUI', 'doProfileAutoComplete', '', true)
823 );
824
825 // standard fields
826 $up->addStandardFieldsToForm($this->form, $ilUser, $this->input);
827
828 $this->addLocationToForm($this->form, $ilUser);
829
830 $this->form->addCommandButton("savePersonalData", $lng->txt("user_save_continue"));
831 }
832
837 public function savePersonalData()
838 {
839 global $DIC;
840
841 $tpl = $DIC['tpl'];
842 $lng = $DIC['lng'];
843 $ilCtrl = $DIC['ilCtrl'];
844 $ilUser = $DIC['ilUser'];
845 $ilSetting = $DIC['ilSetting'];
846
847 $this->initPersonalDataForm();
848 if ($this->form->checkInput()) {
849 $form_valid = true;
850
851 // if form field name differs from setter
852 $map = array(
853 "firstname" => "FirstName",
854 "lastname" => "LastName",
855 "title" => "UTitle",
856 "sel_country" => "SelectedCountry",
857 "phone_office" => "PhoneOffice",
858 "phone_home" => "PhoneHome",
859 "phone_mobile" => "PhoneMobile",
860 "referral_comment" => "Comment",
861 "interests_general" => "GeneralInterests",
862 "interests_help_offered" => "OfferingHelp",
863 "interests_help_looking" => "LookingForHelp"
864 );
865 include_once("./Services/User/classes/class.ilUserProfile.php");
866 $up = new ilUserProfile();
867 foreach ($up->getStandardFields() as $f => $p) {
868 // if item is part of form, it is currently valid (if not disabled)
869 $item = $this->form->getItemByPostVar("usr_" . $f);
870 if ($item && !$item->getDisabled()) {
871 $value = $this->form->getInput("usr_" . $f);
872 switch ($f) {
873 case "birthday":
874 $value = $item->getDate();
875 $ilUser->setBirthday($value
876 ? $value->get(IL_CAL_DATE)
877 : "");
878 break;
879 case "second_email":
880 $ilUser->setSecondEmail($value);
881 break;
882 default:
883 $m = ucfirst($f);
884 if (isset($map[$f])) {
885 $m = $map[$f];
886 }
887 $ilUser->{"set" . $m}($value);
888 break;
889 }
890 }
891 }
892 $ilUser->setFullname();
893
894 // check map activation
895 include_once("./Services/Maps/classes/class.ilMapUtil.php");
897 // #17619 - proper escaping
898 $location = $this->form->getInput("location");
899 $lat = ilUtil::stripSlashes($location["latitude"]);
900 $long = ilUtil::stripSlashes($location["longitude"]);
901 $zoom = ilUtil::stripSlashes($location["zoom"]);
902 $ilUser->setLatitude(is_numeric($lat) ? $lat : null);
903 $ilUser->setLongitude(is_numeric($long) ? $long : null);
904 $ilUser->setLocationZoom(is_numeric($zoom) ? $zoom : null);
905 }
906
907 // Set user defined data
908 $defs = $this->user_defined_fields->getVisibleDefinitions();
909 $udf = array();
910 foreach ($defs as $definition) {
911 $f = "udf_" . $definition['field_id'];
912 $item = $this->form->getItemByPostVar($f);
913 if ($item && !$item->getDisabled()) {
914 $udf[$definition['field_id']] = $this->form->getInput($f);
915 }
916 }
917 $ilUser->setUserDefinedData($udf);
918
919 // if loginname is changeable -> validate
920 $un = $this->form->getInput('username');
921 if ((int) $ilSetting->get('allow_change_loginname') &&
922 $un != $ilUser->getLogin()) {
923 if (!strlen($un) || !ilUtil::isLogin($un)) {
924 ilUtil::sendFailure($lng->txt('form_input_not_valid'));
925 $this->form->getItemByPostVar('username')->setAlert($this->lng->txt('login_invalid'));
926 $form_valid = false;
927 } elseif (ilObjUser::_loginExists($un, $ilUser->getId())) {
928 ilUtil::sendFailure($lng->txt('form_input_not_valid'));
929 $this->form->getItemByPostVar('username')->setAlert($this->lng->txt('loginname_already_exists'));
930 $form_valid = false;
931 } else {
932 $ilUser->setLogin($un);
933
934 try {
935 $ilUser->updateLogin($ilUser->getLogin());
936 } catch (ilUserException $e) {
937 ilUtil::sendFailure($lng->txt('form_input_not_valid'));
938 $this->form->getItemByPostVar('username')->setAlert($e->getMessage());
939 $form_valid = false;
940 }
941 }
942 }
943
944 // everthing's ok. save form data
945 if ($form_valid) {
946 $this->uploadUserPicture();
947
948 // profile ok
949 $ilUser->setProfileIncomplete(false);
950
951 // save user data & object_data
952 $ilUser->setTitle($ilUser->getFullname());
953 $ilUser->setDescription($ilUser->getEmail());
954
955 $ilUser->update();
956
957 $this->checklist_status->saveStepSucess(ilProfileChecklistStatus::STEP_PROFILE_DATA);
958 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
959
960 $ilCtrl->redirect($this, "showPublicProfile");
961 }
962 }
963
964 $this->form->setValuesByPost();
965 $this->showPersonalData(true);
966 }
967
968 //
969 //
970 // PUBLIC PROFILE FORM
971 //
972 //
973
977 public function showPublicProfile($a_no_init = false)
978 {
979 $ilTabs = $this->tabs;
980
981 $ilTabs->activateTab("public_profile");
983
984 $this->setHeader();
985
986 if (!$a_no_init) {
987 $this->initPublicProfileForm();
988 }
989
990 $this->tpl->setContent($this->form->getHTML());
991 $this->tpl->printToStdout();
992 }
993
999 protected function getProfilePortfolio()
1000 {
1001 global $DIC;
1002
1003 $ilUser = $DIC['ilUser'];
1004 $ilSetting = $DIC['ilSetting'];
1005
1006 if ($ilSetting->get('user_portfolios')) {
1007 include_once "Modules/Portfolio/classes/class.ilObjPortfolio.php";
1009 }
1010 }
1011
1017 public function initPublicProfileForm()
1018 {
1019 global $DIC;
1020
1021 $lng = $DIC['lng'];
1022 $ilUser = $DIC['ilUser'];
1023 $ilSetting = $DIC['ilSetting'];
1024
1025 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1026 $this->form = new ilPropertyFormGUI();
1027
1028 $this->form->setTitle($lng->txt("user_publish_options"));
1029 $this->form->setDescription($lng->txt("user_public_profile_info"));
1030 $this->form->setFormAction($this->ctrl->getFormAction($this));
1031
1032 $portfolio_id = $this->getProfilePortfolio();
1033
1034 if (!$portfolio_id) {
1035 // Activate public profile
1036 $radg = new ilRadioGroupInputGUI($lng->txt("user_activate_public_profile"), "public_profile");
1037 $info = $this->lng->txt("user_activate_public_profile_info");
1038 $profile_mode = new ilPersonalProfileMode($ilUser, $ilSetting);
1039 $pub_prof = $profile_mode->getMode();
1040 $radg->setValue($pub_prof);
1041 $op1 = new ilRadioOption($lng->txt("usr_public_profile_disabled"), "n", $lng->txt("usr_public_profile_disabled_info"));
1042 $radg->addOption($op1);
1043 $op2 = new ilRadioOption($lng->txt("usr_public_profile_logged_in"), "y");
1044 $radg->addOption($op2);
1045 if ($ilSetting->get('enable_global_profiles')) {
1046 $op3 = new ilRadioOption($lng->txt("usr_public_profile_global"), "g");
1047 $radg->addOption($op3);
1048 }
1049 $this->form->addItem($radg);
1050
1051 // #11773
1052 if ($ilSetting->get('user_portfolios')) {
1053 // #10826
1054 $prtf = "<br />" . $lng->txt("user_profile_portfolio");
1055 $prtf .= "<br /><a href=\"ilias.php?baseClass=ilDashboardGUI&cmd=jumpToPortfolio\">&raquo; " .
1056 $lng->txt("user_portfolios") . "</a>";
1057 $info .= $prtf;
1058 }
1059
1060 $radg->setInfo($info);
1061 } else {
1062 $prtf = $lng->txt("user_profile_portfolio_selected");
1063 $prtf .= "<br /><a href=\"ilias.php?baseClass=ilDashboardGUI&cmd=jumpToPortfolio&prt_id=" . $portfolio_id . "\">&raquo; " .
1064 $lng->txt("portfolio") . "</a>";
1065
1066 $info = new ilCustomInputGUI($lng->txt("user_activate_public_profile"));
1067 $info->setHTML($prtf);
1068 $this->form->addItem($info);
1069 $this->showPublicProfileFields($this->form, $ilUser->prefs);
1070 }
1071
1072 if (is_object($op2)) {
1073 $this->showPublicProfileFields($this->form, $ilUser->prefs, $op2, false, "-1");
1074 }
1075 if (is_object($op3)) {
1076 $this->showPublicProfileFields($this->form, $ilUser->prefs, $op3, false, "-2");
1077 }
1078 $this->form->setForceTopButtons(true);
1079 $this->form->addCommandButton("savePublicProfile", $lng->txt("user_save_continue"));
1080 }
1081
1091 ilPropertyformGUI $form,
1092 array $prefs,
1093 $parent = null,
1094 $anonymized = false,
1095 $key_suffix = ""
1096 ) {
1097 global $DIC;
1098
1099 $ilUser = $DIC['ilUser'];
1100
1101 $birthday = $ilUser->getBirthday();
1102 if ($birthday) {
1103 $birthday = ilDatePresentation::formatDate(new ilDate($birthday, IL_CAL_DATE));
1104 }
1105 $gender = $ilUser->getGender();
1106 if ($gender) {
1107 $gender = $this->lng->txt("gender_" . $gender);
1108 }
1109
1110 if ($ilUser->getSelectedCountry() != "") {
1111 $this->lng->loadLanguageModule("meta");
1112 $txt_sel_country = $this->lng->txt("meta_c_" . $ilUser->getSelectedCountry());
1113 }
1114
1115 // profile picture
1116 $pic = ilObjUser::_getPersonalPicturePath($ilUser->getId(), "xsmall", true, true);
1117 if ($pic) {
1118 $pic = "<img src=\"" . $pic . "\" />";
1119 }
1120
1121 // personal data
1122 $val_array = array(
1123 "title" => $ilUser->getUTitle(),
1124 "birthday" => $birthday,
1125 "gender" => $gender,
1126 "upload" => $pic,
1127 "interests_general" => $ilUser->getGeneralInterestsAsText(),
1128 "interests_help_offered" => $ilUser->getOfferingHelpAsText(),
1129 "interests_help_looking" => $ilUser->getLookingForHelpAsText(),
1130 "org_units" => $ilUser->getOrgUnitsRepresentation(),
1131 "institution" => $ilUser->getInstitution(),
1132 "department" => $ilUser->getDepartment(),
1133 "street" => $ilUser->getStreet(),
1134 "zipcode" => $ilUser->getZipcode(),
1135 "city" => $ilUser->getCity(),
1136 "country" => $ilUser->getCountry(),
1137 "sel_country" => $txt_sel_country,
1138 "phone_office" => $ilUser->getPhoneOffice(),
1139 "phone_home" => $ilUser->getPhoneHome(),
1140 "phone_mobile" => $ilUser->getPhoneMobile(),
1141 "fax" => $ilUser->getFax(),
1142 "email" => $ilUser->getEmail(),
1143 "second_email" => $ilUser->getSecondEmail(),
1144 "hobby" => $ilUser->getHobby(),
1145 "matriculation" => $ilUser->getMatriculation()
1146 );
1147
1148 // location
1149 include_once("./Services/Maps/classes/class.ilMapUtil.php");
1150 if (ilMapUtil::isActivated()) {
1151 $val_array["location"] = ((int) $ilUser->getLatitude() + (int) $ilUser->getLongitude() + (int) $ilUser->getLocationZoom() > 0)
1152 ? " "
1153 : "";
1154 }
1155 foreach ($val_array as $key => $value) {
1156 if (in_array($value, ["", "-"]) && !$anonymized) {
1157 continue;
1158 }
1159 if ($anonymized) {
1160 $value = null;
1161 }
1162
1163 if ($this->userSettingVisible($key)) {
1164 // #18795 - we should use ilUserProfile
1165 switch ($key) {
1166 case "upload":
1167 $caption = "personal_picture";
1168 break;
1169
1170 case "title":
1171 $caption = "person_title";
1172 break;
1173
1174 default:
1175 $caption = $key;
1176 }
1177 $cb = new ilCheckboxInputGUI($this->lng->txt($caption), "chk_" . $key . $key_suffix);
1178 if ($prefs["public_" . $key] == "y") {
1179 $cb->setChecked(true);
1180 }
1181 //$cb->setInfo($value);
1182 $cb->setOptionTitle($value);
1183
1184 if (!$parent) {
1185 $form->addItem($cb);
1186 } else {
1187 $parent->addSubItem($cb);
1188 }
1189 }
1190 }
1191
1192 // additional defined user data fields
1193 $user_defined_data = array();
1194 if (!$anonymized) {
1195 $user_defined_data = $ilUser->getUserDefinedData();
1196 }
1197 foreach ($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition) {
1198 // public setting
1199 $cb = new ilCheckboxInputGUI($definition["field_name"], "chk_udf_" . $definition["field_id"]);
1200 $cb->setOptionTitle($user_defined_data["f_" . $definition["field_id"]]);
1201 if ($prefs["public_udf_" . $definition["field_id"]] == "y") {
1202 $cb->setChecked(true);
1203 }
1204
1205 if (!$parent) {
1206 $form->addItem($cb);
1207 } else {
1208 $parent->addSubItem($cb);
1209 }
1210 }
1211
1212 if (!$anonymized) {
1213 include_once "Services/Badge/classes/class.ilBadgeHandler.php";
1214 $handler = ilBadgeHandler::getInstance();
1215 if ($handler->isActive()) {
1216 $badge_options = array();
1217
1218 include_once "Services/Badge/classes/class.ilBadgeAssignment.php";
1219 include_once "Services/Badge/classes/class.ilBadge.php";
1220 foreach (ilBadgeAssignment::getInstancesByUserId($ilUser->getId()) as $ass) {
1221 // only active
1222 if ($ass->getPosition()) {
1223 $badge = new ilBadge($ass->getBadgeId());
1224 $badge_options[] = $badge->getTitle();
1225 }
1226 }
1227
1228 if (sizeof($badge_options) > 1) {
1229 $badge_order = new ilNonEditableValueGUI($this->lng->txt("obj_bdga"), "bpos" . $key_suffix);
1230 $badge_order->setMultiValues($badge_options);
1231 $badge_order->setValue(array_shift($badge_options));
1232 $badge_order->setMulti(true, true, false);
1233
1234 if (!$parent) {
1235 $form->addItem($badge_order);
1236 } else {
1237 $parent->addSubItem($badge_order);
1238 }
1239 }
1240 }
1241 }
1242
1243 // permalink
1244 $ne = new ilNonEditableValueGUI($this->lng->txt("perma_link"), "");
1245 $ne->setValue(ilLink::_getLink($this->user->getId(), "usr"));
1246 if (!$parent) {
1247 $form->addItem($ne);
1248 } else {
1249 $parent->addSubItem($ne);
1250 }
1251
1252 }
1253
1258 public function savePublicProfile()
1259 {
1260 global $DIC;
1261
1262 $tpl = $DIC['tpl'];
1263 $lng = $DIC['lng'];
1264 $ilCtrl = $DIC['ilCtrl'];
1265 $ilUser = $DIC['ilUser'];
1266
1267 $this->initPublicProfileForm();
1268 if ($this->form->checkInput()) {
1269 // with active portfolio no options are presented
1270 if (isset($_POST["public_profile"])) {
1271 $ilUser->setPref("public_profile", $_POST["public_profile"]);
1272 }
1273
1274 // if check on Institute
1275 $val_array = array("title", "birthday", "gender", "org_units", "institution", "department", "upload",
1276 "street", "zipcode", "city", "country", "sel_country", "phone_office", "phone_home", "phone_mobile",
1277 "fax", "email", "second_email", "hobby", "matriculation", "location",
1278 "interests_general", "interests_help_offered", "interests_help_looking");
1279
1280 // set public profile preferences
1281 $checked_values = $this->getCheckedValues();
1282 foreach ($val_array as $key => $value) {
1283 if (($checked_values["chk_" . $value])) {
1284 $ilUser->setPref("public_" . $value, "y");
1285 } else {
1286 $ilUser->setPref("public_" . $value, "n");
1287 }
1288 }
1289
1290 // additional defined user data fields
1291 foreach ($this->user_defined_fields->getVisibleDefinitions() as $field_id => $definition) {
1292 if (($checked_values["chk_udf_" . $definition["field_id"]])) {
1293 $ilUser->setPref("public_udf_" . $definition["field_id"], "y");
1294 } else {
1295 $ilUser->setPref("public_udf_" . $definition["field_id"], "n");
1296 }
1297 }
1298
1299 $ilUser->update();
1300
1301 switch ($_POST["public_profile"]) {
1302 case "y":
1303 $key_suffix = "-1";
1304 break;
1305 case "g":
1306 $key_suffix = "-2";
1307 break;
1308 }
1309
1310 include_once "Services/Badge/classes/class.ilBadgeHandler.php";
1311 $handler = ilBadgeHandler::getInstance();
1312 if ($handler->isActive()) {
1313 $badgePositions = [];
1314 if (isset($_POST["bpos" . $key_suffix]) && is_array($_POST["bpos" . $key_suffix])) {
1315 $badgePositions = $_POST["bpos" . $key_suffix];
1316 }
1317
1318 if (count($badgePositions) > 0) {
1319 include_once "Services/Badge/classes/class.ilBadgeAssignment.php";
1320 ilBadgeAssignment::updatePositions($ilUser->getId(), $badgePositions);
1321 }
1322 }
1323
1324 // update lucene index
1325 include_once './Services/Search/classes/Lucene/class.ilLuceneIndexer.php';
1326 ilLuceneIndexer::updateLuceneIndex(array((int) $GLOBALS['DIC']['ilUser']->getId()));
1327
1328 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1329
1330 $this->checklist_status->saveStepSucess(ilProfileChecklistStatus::STEP_PUBLISH_OPTIONS);
1331
1332 if (ilSession::get('orig_request_target')) {
1333 $target = ilSession::get('orig_request_target');
1334 ilSession::set('orig_request_target', '');
1335 ilUtil::redirect($target);
1336 } elseif ($redirect = $_SESSION['profile_complete_redirect']) {
1337 unset($_SESSION['profile_complete_redirect']);
1338 ilUtil::redirect($redirect);
1339 } else {
1340 $ilCtrl->redirectByClass("iluserprivacysettingsgui", "");
1341 }
1342 }
1343 $this->form->setValuesByPost();
1344 $tpl->showPublicProfile(true);
1345 }
1346
1352 protected function getCheckedValues()
1353 {
1354 $checked_values = [];
1355 foreach ($_POST as $k => $v) {
1356 if (substr($k, 0, 4) == "chk_") {
1357 $k = str_replace("-1", "", $k);
1358 $k = str_replace("-2", "", $k);
1359 $checked_values[$k] = $v;
1360 }
1361 }
1362 return $checked_values;
1363 }
1364
1365
1372 public function showExportImport()
1373 {
1374 global $DIC;
1375
1376 $ilToolbar = $DIC['ilToolbar'];
1377 $ilCtrl = $DIC['ilCtrl'];
1378 $tpl = $DIC['tpl'];
1379 $ilTabs = $DIC['ilTabs'];
1380 $ilUser = $DIC['ilUser'];
1381
1382 $ilTabs->activateTab("export");
1383 $this->setHeader();
1384
1385 include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
1386 $button = ilLinkButton::getInstance();
1387 $button->setCaption("pd_export_profile");
1388 $button->setUrl($ilCtrl->getLinkTarget($this, "exportPersonalData"));
1389 $ilToolbar->addStickyItem($button);
1390
1391 $exp_file = $ilUser->getPersonalDataExportFile();
1392 if ($exp_file != "") {
1393 $ilToolbar->addSeparator();
1394 $ilToolbar->addButton(
1395 $this->lng->txt("pd_download_last_export_file"),
1396 $ilCtrl->getLinkTarget($this, "downloadPersonalData")
1397 );
1398 }
1399
1400 $ilToolbar->addSeparator();
1401 $ilToolbar->addButton(
1402 $this->lng->txt("pd_import_personal_data"),
1403 $ilCtrl->getLinkTarget($this, "importPersonalDataSelection")
1404 );
1405
1406 $tpl->printToStdout();
1407 }
1408
1409
1413 public function exportPersonalData()
1414 {
1415 global $DIC;
1416
1417 $ilCtrl = $DIC['ilCtrl'];
1418 $ilUser = $DIC['ilUser'];
1419
1420 $ilUser->exportPersonalData();
1421 $ilUser->sendPersonalDataFile();
1422 $ilCtrl->redirect($this, "showExportImport");
1423 }
1424
1431 public function downloadPersonalData()
1432 {
1433 global $DIC;
1434
1435 $ilUser = $DIC['ilUser'];
1436
1437 $ilUser->sendPersonalDataFile();
1438 }
1439
1447 {
1448 global $DIC;
1449
1450 $lng = $DIC['lng'];
1451 $ilCtrl = $DIC['ilCtrl'];
1452 $tpl = $DIC['tpl'];
1453 $ilTabs = $DIC['ilTabs'];
1454
1455 $ilTabs->activateTab("export");
1456 $this->setHeader();
1457
1458 $this->initPersonalDataImportForm();
1459
1460 $tpl->setContent($this->form->getHTML());
1461 $tpl->printToStdout();
1462 }
1463
1471 {
1472 global $DIC;
1473
1474 $lng = $DIC['lng'];
1475 $ilCtrl = $DIC['ilCtrl'];
1476
1477 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1478 $this->form = new ilPropertyFormGUI();
1479
1480 // input file
1481 $fi = new ilFileInputGUI($lng->txt("file"), "file");
1482 $fi->setRequired(true);
1483 $fi->setSuffixes(array("zip"));
1484 $this->form->addItem($fi);
1485
1486 // profile data
1487 $cb = new ilCheckboxInputGUI($this->lng->txt("pd_profile_data"), "profile_data");
1488 $this->form->addItem($cb);
1489
1490 // settings
1491 $cb = new ilCheckboxInputGUI($this->lng->txt("settings"), "settings");
1492 $this->form->addItem($cb);
1493
1494 // personal notes
1495 $cb = new ilCheckboxInputGUI($this->lng->txt("notes"), "notes");
1496 $this->form->addItem($cb);
1497
1498 // calendar entries
1499 $cb = new ilCheckboxInputGUI($this->lng->txt("pd_private_calendars"), "calendar");
1500 $this->form->addItem($cb);
1501
1502 $this->form->addCommandButton("importPersonalData", $lng->txt("import"));
1503 $this->form->addCommandButton("showExportImport", $lng->txt("cancel"));
1504
1505 $this->form->setTitle($lng->txt("pd_import_personal_data"));
1506 $this->form->setFormAction($ilCtrl->getFormAction($this));
1507 }
1508
1509
1516 public function importPersonalData()
1517 {
1518 global $DIC;
1519
1520 $ilUser = $DIC['ilUser'];
1521 $ilCtrl = $DIC['ilCtrl'];
1522 $tpl = $DIC['tpl'];
1523 $ilTabs = $DIC['ilTabs'];
1524
1525 $this->initPersonalDataImportForm();
1526 if ($this->form->checkInput()) {
1527 $ilUser->importPersonalData(
1528 $_FILES["file"],
1529 (int) $_POST["profile_data"],
1530 (int) $_POST["settings"],
1531 (int) $_POST["notes"],
1532 (int) $_POST["calendar"]
1533 );
1534 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1535 $ilCtrl->redirect($this, "");
1536 } else {
1537 $ilTabs->activateTab("export");
1538 $this->setHeader();
1539 $this->form->setValuesByPost();
1540 $tpl->setContent($this->form->getHtml());
1541 $tpl->printToStdout();
1542 }
1543 }
1544
1550 protected function showChecklist($active_step)
1551 {
1552 $main_tpl = $this->tpl;
1553
1554 $main_tpl->setRightContent($this->checklist->render($active_step));
1555 }
1556}
user()
Definition: user.php:4
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$location
Definition: buildRTE.php:44
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATE
const UDF_TYPE_TEXT
static getInstancesByUserId($a_user_id)
static updatePositions($a_user_id, array $a_positions)
static getInstance()
Constructor.
Class ilBadge.
This class represents a checkbox property in a property form.
This class represents a custom property in a property form.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
Class for single dates.
This class represents a file property in a property form.
This class represents a property in a property form.
static getInstance()
Factory.
This class represents a location property in a property form.
static updateLuceneIndex($a_obj_ids)
Update lucene index.
static isActivated()
Checks whether Map feature is activated.
static getDefaultSettings()
Get default longitude, latitude and zoom.
This class represents a non editable value in a property form.
static getDefaultPortfolio($a_user_id)
Get default portfolio of user.
static _getPersonalPicturePath( $a_usr_id, $a_size="small", $a_force_pic=false, $a_prevent_no_photo_image=false)
Get path to personal picture.
getLatitude()
Get Latitude.
getCountry()
Get country (free text)
getLongitude()
Get Longitude.
getLocationZoom()
Get Location Zoom.
getStreet()
get street @access public
getCity()
get city @access public
static _loginExists($a_login, $a_user_id=0)
check if a login name already exists You may exclude a user from the check by giving his user id as 2...
GUI class for personal profile.
saveProfile()
save user profile data
initPersonalDataImportForm()
Init personal data import form.
showPersonalData($a_no_init=false, $a_migration_started=false)
Personal data form.
getCheckedValues()
Get checked values.
importPersonalData()
Import personal data.
showPublicProfile($a_no_init=false)
Public profile form.
__construct(\ilTermsOfServiceDocumentEvaluation $termsOfServiceEvaluation=null)
constructor
initPersonalDataForm()
Init personal form.
savePersonalData()
Save personal data form.
savePublicProfile()
Save public profile form.
exportPersonalData()
Export personal data.
removeUserPicture()
remove user image
getProfilePortfolio()
has profile set to a portfolio?
showExportImport()
Show export/import.
uploadUserPicture()
Upload user image.
downloadPersonalData()
Download personal data export file.
showPublicProfileFields(ilPropertyformGUI $form, array $prefs, $parent=null, $anonymized=false, $key_suffix="")
Add fields to form.
importPersonalDataSelection()
Import personal data selection.
initPublicProfileForm()
Init public profile form.
showChecklist($active_step)
Show checklist.
addLocationToForm(ilPropertyFormGUI $a_form, ilObjUser $a_user)
Add location fields to form if activated.
Personal profile publishing mode of a iser.
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).
GUI class for public user profile presentation.
This class represents a property in a property form.
This class represents an option in a radio group.
static set($a_var, $a_val)
Set a value.
static get($a_var)
Get a value.
ILIAS Setting Class.
static getMailsToAddress()
Get mailto: emails.
static _getInstance()
Get instance.
Class for user related exception handling in ILIAS.
User privacy settings (currently located under "Profile and Privacy")
Class ilUserProfile.
User settings configuration (what preferences can be visible/changed/...)
static isConvertVersionAtLeast($a_version)
Compare convert version numbers.
static escapeShellArg($a_arg)
static getWebspaceDir($mode="filesystem")
get webspace directory
static execConvert($args)
execute convert command
static redirect($a_script)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static is_email($a_email, ilMailRfc822AddressParserFactory $mailAddressParserFactory=null)
This preg-based function checks whether an e-mail address is formally valid.
static isLogin($a_login)
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static formSelect( $selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
global $ilCtrl
Definition: ilias.php:18
Interface ilTermsOfServiceDocumentEvaluation.
if($format !==null) $name
Definition: metadata.php:230
global $ilSetting
Definition: privfeed.php:17
$lng
settings()
Definition: settings.php:2
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46