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