19declare(strict_types=1);
61 private \ilGlobalTemplateInterface
$tpl;
63 private \ilPropertyFormGUI
$form;
97 $this->
tabs = $DIC[
'ilTabs'];
98 $this->
toolbar = $DIC[
'ilToolbar'];
99 $this->
help = $DIC[
'ilHelp'];
100 $this->
http = $DIC[
'http'];
101 $this->
user = $DIC[
'ilUser'];
102 $this->auth_session =
$DIC[
'ilAuthSession'];
103 $this->
lng = $DIC[
'lng'];
104 $this->
settings = $DIC[
'ilSetting'];
105 $this->tpl =
$DIC[
'tpl'];
106 $this->
ctrl = $DIC[
'ilCtrl'];
107 $this->error_handler =
$DIC[
'ilErr'];
108 $this->
event = $DIC[
'ilAppEventHandler'];
109 $this->ui_factory =
$DIC[
'ui.factory'];
110 $this->ui_renderer =
$DIC[
'ui.renderer'];
111 $this->uploads =
$DIC[
'upload'];
112 $this->ui_factory =
$DIC[
'ui.factory'];
113 $this->ui_renderer =
$DIC[
'ui.renderer'];
115 $this->auth_session =
$DIC[
'ilAuthSession'];
116 $this->static_url =
$DIC[
'static_url'];
120 $this->
profile = $local_dic[Profile::class];
121 $this->user_settings = $local_dic[UserSettings::class];
122 $this->change_mail_token_repo =
new ChangeMailDBRepository(
133 $this->prompt_repository =
new PromptRepository(
143 $this->
lng->loadLanguageModule(
'jsmath');
144 $this->
lng->loadLanguageModule(
'awrn');
145 $this->
lng->loadLanguageModule(
'pd');
146 $this->
lng->loadLanguageModule(
'user');
147 $this->
lng->loadLanguageModule(
'maps');
148 $this->
ctrl->saveParameter($this,
'prompted');
153 $next_class = $this->
ctrl->getNextClass();
155 switch ($next_class) {
156 case strtolower(PublicProfileGUI::class):
158 $pub_profile_gui->setBackUrl($this->
ctrl->getLinkTarget($this,
'showPersonalData'));
159 $this->
ctrl->forwardCommand($pub_profile_gui);
160 $this->tpl->printToStdout();
163 case strtolower(PrivacySettingsGUI::class):
166 $this->
tabs->activateTab(
'visibility_settings');
168 $this->
ctrl->forwardCommand(
169 new PrivacySettingsGUI(
173 $this->
http->request(),
179 $this->user_settings,
185 $this->checklist_status,
192 case strtolower(\ilLegalDocumentsAgreementGUI::class):
194 $this->tpl->printToStdout();
197 case strtolower(\ilLegalDocumentsWithdrawalGUI::class):
199 $this->tpl->printToStdout();
204 $cmd = $this->
ctrl->getCmd(
'showPersonalData');
223 $this->
help->setScreenIdComponent(
'user');
228 $this->
lng->txt(
'user_profile_data'),
229 $this->ctrl->getLinkTarget($this,
'showPersonalData')
235 $this->
lng->txt(
'user_publish_options'),
236 $this->ctrl->getLinkTarget($this,
'showPublicProfile')
240 $txt_visibility = $this->checklist_status->anyVisibilitySettings()
241 ? $this->
lng->txt(
'user_visibility_settings')
242 : $this->
lng->txt(
'preview');
244 'visibility_settings',
246 $this->
ctrl->getLinkTargetByClass(PrivacySettingsGUI::class,
'')
252 $this->
lng->txt(
'export') .
'/' . $this->lng->txt(
'import'),
253 $this->ctrl->getLinkTarget($this,
'showExportImport')
259 $this->tpl->setTitle($this->
lng->txt(
'personal_profile'));
263 bool $a_no_init =
false
265 $this->
tabs->activateTab(
'personal_data');
274 if ($this->
user->getProfileIncomplete()) {
275 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'profile_incomplete'));
280 if ($this->email_change_confirmation_modal !==
null) {
281 $modal = $this->ui_renderer->render($this->email_change_confirmation_modal);
284 $this->tpl->setContent($this->
buildInfoText() . $this->
form->getHTML() . $modal);
286 $this->tpl->printToStdout();
291 $change_mail_info =
'';
292 if ($this->change_mail_token_repo->hasUserValidEmailConfirmationToken($this->user)) {
293 $change_mail_info = $this->
lng->txt(
'change_email_info_message');
297 if ($this->profile_request->getPrompted() === 1) {
298 $it = $this->prompt_repository->getSettings()->getPromptText($this->
user->getLanguage());
301 $it = $this->prompt_repository->getSettings()->getInfoText($this->
user->getLanguage());
303 if (trim($it) ===
'') {
304 return $change_mail_info ===
''
306 : $this->ui_renderer->render($this->ui_factory->messageBox()->info($change_mail_info));
309 if ($change_mail_info !==
'') {
310 $it .=
'<br>' . $change_mail_info;
313 $pub_prof = in_array($this->
user->getPref(
'public_profile'), [
'y',
'n',
'g'])
314 ? $this->
user->getPref(
'public_profile')
316 $box = $this->ui_factory->messageBox()->info($it);
317 if ($pub_prof ===
'n') {
318 $box = $box->withLinks(
319 [$this->ui_factory->link()->standard(
320 $this->lng->txt(
'user_make_profile_public'),
321 $this->ctrl->getLinkTarget($this,
'showPublicProfile')
325 return $this->ui_renderer->render($box);
330 $this->
form = new \ilPropertyFormGUI();
331 $this->
form->setFormAction($this->
ctrl->getFormAction($this));
332 $this->
form->setId(self::PERSONAL_DATA_FORM_ID);
334 $this->
form = $this->
profile->addFieldsToForm($this->
form, Context::User,
true, $this->
user);
336 $this->
form->addCommandButton(
'savePersonalData', $this->
lng->txt(
'user_save_continue'));
341 $this->initPersonalDataForm();
342 $this->uploads->process();
344 if (!$this->
form->checkInput()
345 || !$this->emailCompletionForced()
346 && $this->emailChanged()
347 && $this->addEmailChangeModal()
348 || $this->loginChanged() && !$this->updateLoginOrSetErrorMessages()) {
349 $this->
form->setValuesByPost();
351 $this->showPersonalData(
true);
355 $this->addDataFromFormToUser();
357 $this->
user = $this->checklist_status->setStepSucessOnUser(
361 $this->
user->update();
363 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
364 $this->
ctrl->redirect($this,
'showPublicProfile');
369 $identifier_email = $this->
profile->getFieldByClass(Email::class)->getIdentifier();
370 $email_input = $this->
form->getItemByPostVar($identifier_email);
371 if ($email_input !==
null && !$email_input->getDisabled()
372 && $this->form->getInput($identifier_email) !== $this->user->getEmail()) {
381 $current_email = $this->
user->getEmail();
383 $this->
user->getProfileIncomplete()
384 && $this->profile->getFieldByClass(Email::class)->isRequired()
385 && ($current_email ===
null || $current_email ===
'')
395 $form_id =
'form_' . self::PERSONAL_DATA_FORM_ID;
397 $message = $this->
lng->txt(
'confirm_logout_for_email_change');
399 $message .=
'<br>' . $this->
lng->txt(
'confirm_logout_for_email_change_with_confirmation');
402 $modal = $this->ui_factory->modal()->interruptive(
403 $this->
lng->txt(
'confirm'),
406 )->withActionButtonLabel($this->
lng->txt(
'change'));
407 $this->email_change_confirmation_modal = $modal->withOnLoad($modal->getShowSignal())
408 ->withAdditionalOnLoadCode(
409 static function (
$id) use ($form_id) {
410 return "var button = {$id}.querySelector('input[type=\"submit\"]'); "
411 .
"button.addEventListener('click', (e) => {e.preventDefault();"
412 .
"document.getElementById('{$form_id}').submit();});";
416 $this->
form->setFormAction($this->
ctrl->getFormActionByClass(self::class,
'goToEmailConfirmation'));
422 if ($this->
profile->userFieldEditableByUser(
'username')
423 && $this->form->getInput(
'username') !== $this->user->getLogin()) {
432 $login = $this->
form->getInput(
'username');
434 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'form_input_not_valid'));
435 $this->
form->getItemByPostVar(
'username')->setAlert($this->
lng->txt(
'login_invalid'));
440 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'form_input_not_valid'));
441 $this->
form->getItemByPostVar(
'username')->setAlert($this->
lng->txt(
'loginname_already_exists'));
446 $this->
user->updateLogin($login, Context::User);
449 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'form_input_not_valid'));
450 $this->
form->getItemByPostVar(
'username')->setAlert($e->getMessage());
457 $this->initPersonalDataForm();
458 if (!$this->
form->checkInput()
459 || $this->loginChanged() && !$this->updateLoginOrSetErrorMessages()) {
460 $this->
form->setValuesByPost();
461 $this->showPersonalData(
true);
464 $this->addDataFromFormToUser([Email::class]);
465 $this->
user->update();
468 $this->auth_session->logout();
470 $token = $this->change_mail_token_repo->getNewTokenForUser(
472 $this->
form->getInput(
473 $this->profile->getFieldByClass(Email::class)->getIdentifier()
477 $this->
ctrl->redirectToURL(
478 $token->getUriForStatus($this->static_url->builder())->__toString()
483 array $skip_fields = []
486 $this->
user->setProfileIncomplete(
false);
488 $this->
user->setTitle($this->
user->getFullname());
489 $this->
user->setDescription($this->
user->getEmail());
494 $token = $this->change_mail_token_repo->getTokenForTokenString(
495 $this->profile_request->getToken(),
500 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'email_could_not_be_changed'));
501 $this->showPublicProfile();
505 if (
$token->getStatus() === ChangeMailStatus::Login
509 $this->change_mail_token_repo->moveToNextStep(
$token, time())
510 ->getUriForStatus($this->static_url->builder()),
513 ))->
send(
$token->getNewEmail(), ChangeMailStatus::EmailConfirmation->getValidity($this->
settings));
514 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'change_email_email_sent'));
515 $this->showPublicProfile();
520 $this->
user->update();
521 $this->change_mail_token_repo->deleteEntryByToken(
$token->getToken());
522 $this->change_mail_token_repo->deleteExpiredEntries();
524 $this->tpl->setOnScreenMessage(
526 $this->
lng->txt(
'saved_successfully')
528 $this->showPublicProfile();
534 $this->
tabs->activateTab(
'public_profile');
535 $this->showChecklist(ChecklistStatus::STEP_PUBLISH_OPTIONS);
540 $this->initPublicProfileForm();
543 $this->tpl->setContent($this->
form->getHTML());
544 $this->tpl->printToStdout();
549 if ($this->
settings->get(
'user_portfolios')) {
550 return \ilObjPortfolio::getDefaultPortfolio($this->
user->getId());
557 $this->
form = new \ilPropertyFormGUI();
559 $this->
form->setTitle($this->
lng->txt(
'user_publish_options'));
560 $this->
form->setDescription($this->
lng->txt(
'user_public_profile_info'));
561 $this->
form->setFormAction($this->
ctrl->getFormAction($this));
563 $portfolio_id = $this->getProfilePortfolio();
565 if (!$portfolio_id) {
567 $radg = new \ilRadioGroupInputGUI($this->
lng->txt(
'user_activate_public_profile'),
'public_profile');
568 $info = $this->
lng->txt(
'user_activate_public_profile_info');
572 $op1 = new \ilRadioOption($this->
lng->txt(
'usr_public_profile_disabled'),
'n', $this->lng->txt(
'usr_public_profile_disabled_info'));
573 $radg->addOption($op1);
574 $op2 = new \ilRadioOption($this->
lng->txt(
'usr_public_profile_logged_in'),
'y');
575 $radg->addOption($op2);
576 if ($this->
settings->get(
'enable_global_profiles')) {
577 $op3 = new \ilRadioOption($this->
lng->txt(
'usr_public_profile_global'),
'g');
578 $radg->addOption($op3);
580 $this->
form->addItem($radg);
583 if ($this->
settings->get(
'user_portfolios')) {
585 $href = $this->
ctrl->getLinkTargetByClass(\ilDashboardGUI::class,
'jumpToPortfolio');
586 $prtf =
'<br />' . $this->
lng->txt(
'user_profile_portfolio');
587 $prtf .=
'<br /><a href="' . $href .
'">» ' .
588 $this->
lng->txt(
'user_portfolios') .
'</a>';
592 $radg->setInfo(
$info);
594 $this->
ctrl->setParameterByClass(\ilDashboardGUI::class,
'prt_id', $portfolio_id);
595 $href = $this->
ctrl->getLinkTargetByClass(\ilDashboardGUI::class,
'jumpToPortfolio');
596 $this->
ctrl->clearParameterByClass(\ilDashboardGUI::class,
'prt_id');
597 $prtf = $this->
lng->txt(
'user_profile_portfolio_selected');
598 $prtf .=
'<br /><a href="' . $href .
'">» ' .
599 $this->
lng->txt(
'portfolio') .
'</a>';
601 $info = new \ilCustomInputGUI($this->
lng->txt(
'user_activate_public_profile'));
602 $info->setHtml($prtf);
604 $this->showPublicProfileFields($this->
form);
608 $this->showPublicProfileFields($this->
form,
null, $op2,
false,
'-1');
611 $this->showPublicProfileFields($this->
form,
null, $op3,
false,
'-2');
613 $this->
form->setForceTopButtons(
true);
614 $this->
form->addCommandButton(
'savePublicProfile', $this->
lng->txt(
'user_save_continue'));
619 ?array $prefs =
null,
621 bool $anonymized =
false,
622 string $key_suffix =
''
624 foreach ($this->
profile->getVisibleFields(
630 $value = $field->retrieveValueFromUser($this->
user);
631 if (!$anonymized && ($value ===
'' || $value ===
'-' || $value ===
null)) {
638 if ($field->isVisibleToUser()) {
640 switch ($field->getIdentifier()) {
642 $caption = $this->
lng->txt(
'personal_picture');
643 $value =
"<img src='{$value}' alt='{$this->lng->txt('user_avatar')}' />";
647 $caption = $field->getLabel($this->
lng);
649 $cb = new \ilCheckboxInputGUI($caption, self::PUBLISH_SETTINGS_PREFIX . $field->getIdentifier() . $key_suffix);
652 ? $field->isPublishedByUser($this->user)
653 : $prefs[
"public_{$field->getIdentifier()}"] ??
false
658 $this->refinery->kindlyTo()->string(),
659 $this->refinery->custom()->transformation(
660 function (mixed $v):
string {
662 $this->
refinery->kindlyTo()->listOf(
663 $this->refinery->kindlyTo()->string()
665 static fn(
string $c,
string $v):
string =>
$c ===
''
678 $parent->addSubItem($cb);
690 if ($ass->getPosition()) {
691 $badge = new \ilBadge($ass->getBadgeId());
692 $badge_options[] = $badge->getTitle();
696 if (count($badge_options) > 1) {
697 $badge_order = new \ilNonEditableValueGUI($this->
lng->txt(
'obj_bdga'),
'bpos' . $key_suffix);
698 $badge_order->setMultiValues($badge_options);
699 $badge_order->setValue(array_shift($badge_options));
700 $badge_order->setMulti(
true,
true,
false);
703 $form->addItem($badge_order);
705 $parent->addSubItem($badge_order);
712 $ne = new \ilNonEditableValueGUI($this->
lng->txt(
'perma_link'),
'');
713 $ne->setValue(\ilLink::_getLink($this->
user->getId(),
'usr'));
717 $parent->addSubItem($ne);
723 $this->initPublicProfileForm();
724 if (!$this->
form->checkInput()) {
725 $this->
form->setValuesByPost();
726 $this->tpl->showPublicProfile(
true);
729 if ($this->
form->getInput(
'public_profile') !==
'') {
730 $this->
user->setPref(
'public_profile', $this->
form->getInput(
'public_profile'));
733 $this->
user = array_reduce(
734 $this->
profile->getVisibleFields(Context::User, $this->user),
736 $v->setPublishedOnUser(
$c, $this->getPublishedFromPost($v->getIdentifier())),
741 $badge_positions = $this->
form->getInput(
'bpos' . $this->buildKeySuffix()) ?? [];
742 if (is_array($badge_positions) && $badge_positions !== []) {
747 $this->
user = $this->checklist_status->setStepSucessOnUser(
748 ChecklistStatus::STEP_PUBLISH_OPTIONS,
751 $this->
user->update();
755 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
763 $this->
ctrl->redirectByClass([self::class, PrivacySettingsGUI::class],
'');
768 $this->
tabs->activateTab(
'export');
771 $button = $this->ui_factory->link()->standard(
772 $this->
lng->txt(
'pd_export_profile'),
773 $this->ctrl->getLinkTarget($this,
'exportPersonalData')
775 $this->
toolbar->addStickyItem($button);
777 $exp_file = $this->
user->getPersonalDataExportFile();
778 if ($exp_file !=
'') {
779 $this->
toolbar->addSeparator();
781 $this->ui_factory->link()->standard(
782 $this->lng->txt(
"pd_download_last_export_file"),
783 $this->ctrl->getLinkTarget($this,
"downloadPersonalData")
788 $this->
toolbar->addSeparator();
790 $this->ui_factory->link()->standard(
791 $this->lng->txt(
"pd_import_personal_data"),
792 $this->ctrl->getLinkTarget($this,
"importPersonalDataSelection")
796 $this->tpl->printToStdout();
801 $this->
user->exportPersonalData();
802 $this->
user->sendPersonalDataFile();
803 $this->
ctrl->redirect($this,
'showExportImport');
811 $this->
user->sendPersonalDataFile();
816 $this->
tabs->activateTab(
'export');
819 $this->initPersonalDataImportForm();
821 $this->tpl->setContent($this->
form->getHTML());
822 $this->tpl->printToStdout();
827 $this->
form = new \ilPropertyFormGUI();
830 $fi = new \ilFileInputGUI($this->
lng->txt(
'file'),
'file');
831 $fi->setRequired(
true);
832 $fi->setSuffixes([
'zip']);
833 $this->
form->addItem($fi);
836 $cb = new \ilCheckboxInputGUI($this->
lng->txt(
'pd_profile_data'),
'profile_data');
837 $this->
form->addItem($cb);
840 $cb = new \ilCheckboxInputGUI($this->
lng->txt(
'settings'),
'settings');
841 $this->
form->addItem($cb);
844 $cb = new \ilCheckboxInputGUI($this->
lng->txt(
'notes'),
'notes');
845 $this->
form->addItem($cb);
848 $cb = new \ilCheckboxInputGUI($this->
lng->txt(
'pd_private_calendars'),
'calendar');
849 $this->
form->addItem($cb);
851 $this->
form->addCommandButton(
'importPersonalData', $this->
lng->txt(
'import'));
852 $this->
form->addCommandButton(
'showExportImport', $this->
lng->txt(
'cancel'));
854 $this->
form->setTitle($this->
lng->txt(
'pd_import_personal_data'));
855 $this->
form->setFormAction($this->
ctrl->getFormAction($this));
860 $this->initPersonalDataImportForm();
861 if ($this->
form->checkInput()) {
862 $this->
user->importPersonalData(
864 (
bool) $this->
form->getInput(
'profile_data'),
865 (
bool) $this->form->getInput(
'settings'),
866 (
bool) $this->form->getInput(
'notes'),
867 (
bool) $this->form->getInput(
'calendar')
869 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
870 $this->
ctrl->redirect($this,
'');
872 $this->
tabs->activateTab(
'export');
874 $this->
form->setValuesByPost();
875 $this->tpl->setContent($this->
form->getHTML());
876 $this->tpl->printToStdout();
882 $main_tpl = $this->tpl;
883 $main_tpl->setRightContent($this->checklist->render($active_step));
888 $key = self::PUBLISH_SETTINGS_PREFIX . $identifier . $this->buildKeySuffix();
890 if (!$this->
http->wrapper()->post()->has($key)) {
894 return $this->
http->wrapper()->post()->retrieve(
896 $this->
refinery->kindlyTo()->string()
902 switch ($this->
form->getInput(
'public_profile')) {
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Builds a Color from either hex- or rgb values.
const STEP_VISIBILITY_OPTIONS
GUI class for personal profile.
importPersonalDataSelection()
const PUBLISH_SETTINGS_PREFIX
downloadPersonalData()
Download personal data export file.
updateLoginOrSetErrorMessages()
ilAuthSession $auth_session
showPublicProfile(bool $a_no_init=false)
const PERSONAL_DATA_FORM_ID
ChecklistStatus $checklist_status
ProfileImplementation $profile
initPersonalDataImportForm()
StaticUrlServices $static_url
showPersonalData(bool $a_no_init=false)
addDataFromFormToUser(array $skip_fields=[])
showProfile()
show profile form
showPublicProfileFields(\ilPropertyFormGUI $form, ?array $prefs=null, \ilRadioOption|\ilCheckboxGroupInputGUI|null $parent=null, bool $anonymized=false, string $key_suffix='')
Interruptive $email_change_confirmation_modal
getPublishedFromPost(string $identifier)
ilGlobalTemplateInterface $tpl
showChecklist(int $active_step)
UserSettings $user_settings
GUIRequest $profile_request
ChangeMailRepository $change_mail_token_repo
PromptRepository $prompt_repository
ilErrorHandling $error_handler
GUI class for public user profile presentation.
Personal profile publishing mode of a user.
__construct()
Constructor setup ILIAS global object @access public.
static updatePositions(int $a_user_id, array $a_positions)
static getInstancesByUserId(int $a_user_id)
static getLogger(string $a_component_id)
Get component logger.
static updateLuceneIndex(array $a_obj_ids)
Update lucene index.
static _loginExists(string $a_login, int $a_user_id=0)
This class represents an option in a radio group.
static get(string $a_var)
static setClosingContext(int $a_context)
set closing context (for statistics)
static set(string $a_var, $a_val)
Set a value.
const int SESSION_CLOSE_USER
static isLogin(string $a_login)
static redirect(string $a_script)
An entity that renders components to a string output.
addFormValuesToUser(\ilPropertyFormGUI $form, Context $context, \ilObjUser $current_user)
static http()
Fetches the global http state from ILIAS.
form(?array $class_path, string $cmd, string $submit_caption="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
catch(ilCmiXapiException $e) send($response)