19declare(strict_types=1);
55 private \ilGlobalTemplateInterface
$tpl;
57 private \ilPropertyFormGUI
$form;
91 $this->
tabs = $DIC[
'ilTabs'];
92 $this->
toolbar = $DIC[
'ilToolbar'];
93 $this->
help = $DIC[
'ilHelp'];
94 $this->
http = $DIC[
'http'];
95 $this->
user = $DIC[
'ilUser'];
96 $this->auth_session =
$DIC[
'ilAuthSession'];
97 $this->
lng = $DIC[
'lng'];
99 $this->tpl =
$DIC[
'tpl'];
100 $this->
ctrl = $DIC[
'ilCtrl'];
101 $this->error_handler =
$DIC[
'ilErr'];
102 $this->
event = $DIC[
'ilAppEventHandler'];
103 $this->ui_factory =
$DIC[
'ui.factory'];
104 $this->ui_renderer =
$DIC[
'ui.renderer'];
105 $this->uploads =
$DIC[
'upload'];
106 $this->ui_factory =
$DIC[
'ui.factory'];
107 $this->ui_renderer =
$DIC[
'ui.renderer'];
109 $this->auth_session =
$DIC[
'ilAuthSession'];
110 $this->static_url =
$DIC[
'static_url'];
114 $this->
profile = $local_dic[Profile::class];
115 $this->user_settings = $local_dic[UserSettings::class];
116 $this->change_mail_token_repo =
new ChangeMailDBRepository(
127 $this->prompt_repository =
new PromptRepository(
137 $this->
lng->loadLanguageModule(
'jsmath');
138 $this->
lng->loadLanguageModule(
'awrn');
139 $this->
lng->loadLanguageModule(
'pd');
140 $this->
lng->loadLanguageModule(
'user');
141 $this->
lng->loadLanguageModule(
'maps');
142 $this->
ctrl->saveParameter($this,
'prompted');
147 $next_class = $this->
ctrl->getNextClass();
149 switch ($next_class) {
150 case strtolower(PublicProfileGUI::class):
152 $pub_profile_gui->setBackUrl($this->
ctrl->getLinkTarget($this,
'showPersonalData'));
153 $this->
ctrl->forwardCommand($pub_profile_gui);
154 $this->tpl->printToStdout();
157 case strtolower(PrivacySettingsGUI::class):
160 $this->
tabs->activateTab(
'visibility_settings');
162 $this->
ctrl->forwardCommand(
163 new PrivacySettingsGUI(
167 $this->
http->request(),
173 $this->user_settings,
179 $this->checklist_status,
186 case strtolower(\ilLegalDocumentsAgreementGUI::class):
188 $this->tpl->printToStdout();
191 case strtolower(\ilLegalDocumentsWithdrawalGUI::class):
193 $this->tpl->printToStdout();
198 $cmd = $this->
ctrl->getCmd(
'showPersonalData');
206 return $this->user_settings_config->isVisible(
$setting);
222 $this->
help->setScreenIdComponent(
'user');
227 $this->
lng->txt(
'user_profile_data'),
228 $this->ctrl->getLinkTarget($this,
'showPersonalData')
234 $this->
lng->txt(
'user_publish_options'),
235 $this->ctrl->getLinkTarget($this,
'showPublicProfile')
239 $txt_visibility = $this->checklist_status->anyVisibilitySettings()
240 ? $this->
lng->txt(
'user_visibility_settings')
241 : $this->
lng->txt(
'preview');
243 'visibility_settings',
245 $this->
ctrl->getLinkTargetByClass(PrivacySettingsGUI::class,
'')
251 $this->
lng->txt(
'export') .
'/' . $this->lng->txt(
'import'),
252 $this->ctrl->getLinkTarget($this,
'showExportImport')
258 $this->tpl->setTitle($this->
lng->txt(
'personal_profile'));
262 bool $a_no_init =
false
264 $this->
tabs->activateTab(
'personal_data');
273 if ($this->
user->getProfileIncomplete()) {
274 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'profile_incomplete'));
279 if ($this->email_change_confirmation_modal !==
null) {
280 $modal = $this->ui_renderer->render($this->email_change_confirmation_modal);
283 $this->tpl->setContent($this->
buildInfoText() . $this->
form->getHTML() . $modal);
285 $this->tpl->printToStdout();
290 $change_mail_info =
'';
291 if ($this->change_mail_token_repo->hasUserValidEmailConfirmationToken($this->user)) {
292 $change_mail_info = $this->
lng->txt(
'change_email_info_message');
296 if ($this->profile_request->getPrompted() === 1) {
297 $it = $this->prompt_repository->getSettings()->getPromptText($this->
user->getLanguage());
300 $it = $this->prompt_repository->getSettings()->getInfoText($this->
user->getLanguage());
302 if (trim($it) ===
'') {
303 return $change_mail_info ===
''
305 : $this->ui_renderer->render($this->ui_factory->messageBox()->info($change_mail_info));
308 if ($change_mail_info !==
'') {
309 $it .=
'<br>' . $change_mail_info;
312 $pub_prof = in_array($this->
user->getPref(
'public_profile'), [
'y',
'n',
'g'])
313 ? $this->
user->getPref(
'public_profile')
315 $box = $this->ui_factory->messageBox()->info($it);
316 if ($pub_prof ===
'n') {
317 $box = $box->withLinks(
318 [$this->ui_factory->link()->standard(
319 $this->lng->txt(
'user_make_profile_public'),
320 $this->ctrl->getLinkTarget($this,
'showPublicProfile')
324 return $this->ui_renderer->render($box);
329 $this->
form = new \ilPropertyFormGUI();
330 $this->
form->setFormAction($this->
ctrl->getFormAction($this));
331 $this->
form->setId(self::PERSONAL_DATA_FORM_ID);
333 $this->
form = $this->
profile->addFieldsToForm($this->
form, Context::User,
true, $this->
user);
335 $this->
form->addCommandButton(
'savePersonalData', $this->
lng->txt(
'user_save_continue'));
340 $this->initPersonalDataForm();
341 $this->uploads->process();
343 if (!$this->
form->checkInput()
344 || !$this->emailCompletionForced()
345 && $this->emailChanged()
346 && $this->addEmailChangeModal()
347 || $this->loginChanged() && !$this->updateLoginOrSetErrorMessages()) {
348 $this->
form->setValuesByPost();
350 $this->showPersonalData(
true);
354 $this->addDataFromFormToUser();
356 $this->
user = $this->checklist_status->setStepSucessOnUser(
360 $this->
user->update();
362 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
363 $this->
ctrl->redirect($this,
'showPublicProfile');
368 $email_input = $this->
form->getItemByPostVar(
'usr_email');
369 if ($email_input !==
null && !$email_input->getDisabled()
370 && $this->form->getInput(
'usr_email') !== $this->user->getEmail()) {
379 $current_email = $this->
user->getEmail();
381 $this->
user->getProfileIncomplete()
382 && $this->settings->get(
'require_email') ===
'1'
383 && ($current_email ===
null || $current_email ===
'')
393 $form_id =
'form_' . self::PERSONAL_DATA_FORM_ID;
395 $message = $this->
lng->txt(
'confirm_logout_for_email_change');
397 $message .=
'<br>' . $this->
lng->txt(
'confirm_logout_for_email_change_with_confirmation');
400 $modal = $this->ui_factory->modal()->interruptive(
401 $this->
lng->txt(
'confirm'),
404 )->withActionButtonLabel($this->
lng->txt(
'change'));
405 $this->email_change_confirmation_modal = $modal->withOnLoad($modal->getShowSignal())
406 ->withAdditionalOnLoadCode(
407 static function (
$id) use ($form_id) {
408 return "var button = {$id}.querySelector('input[type=\"submit\"]'); "
409 .
"button.addEventListener('click', (e) => {e.preventDefault();"
410 .
"document.getElementById('{$form_id}').submit();});";
414 $this->
form->setFormAction($this->
ctrl->getFormActionByClass(self::class,
'goToEmailConfirmation'));
420 if ($this->
profile->userFieldEditableByUser(
'username')
421 && $this->form->getInput(
'username') !== $this->user->getLogin()) {
430 $login = $this->
form->getInput(
'username');
432 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'form_input_not_valid'));
433 $this->
form->getItemByPostVar(
'username')->setAlert($this->
lng->txt(
'login_invalid'));
438 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'form_input_not_valid'));
439 $this->
form->getItemByPostVar(
'username')->setAlert($this->
lng->txt(
'loginname_already_exists'));
444 $this->
user->updateLogin($login);
447 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'form_input_not_valid'));
448 $this->
form->getItemByPostVar(
'username')->setAlert($e->getMessage());
455 $this->initPersonalDataForm();
456 if (!$this->
form->checkInput()
457 || $this->loginChanged() && !$this->updateLoginOrSetErrorMessages()) {
458 $this->
form->setValuesByPost();
459 $this->showPersonalData(
true);
462 $this->addDataFromFormToUser();
463 $this->
user->update();
466 $this->auth_session->logout();
468 $token = $this->change_mail_token_repo->getNewTokenForUser(
470 $this->
form->getInput(
'usr_email'),
473 $this->
ctrl->redirectToURL(
474 $token->getUriForStatus($this->static_url->builder())->__toString()
480 $this->
user = $this->
profile->addFormValuesToUser($this->
form, Context::User, $this->
user);
481 $this->
user->setProfileIncomplete(
false);
483 $this->
user->setTitle($this->
user->getFullname());
484 $this->
user->setDescription($this->
user->getEmail());
489 $token = $this->change_mail_token_repo->getTokenForTokenString(
490 $this->profile_request->getToken(),
495 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'email_could_not_be_changed'));
496 $this->showPublicProfile();
500 if (
$token->getStatus() === ChangeMailStatus::Login
504 $this->change_mail_token_repo->moveToNextStep(
$token, time())
505 ->getUriForStatus($this->static_url->builder()),
508 ))->
send(
$token->getNewEmail(), ChangeMailStatus::EmailConfirmation->getValidity($this->
settings));
509 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'change_email_email_sent'));
510 $this->showPublicProfile();
515 $this->
user->update();
516 $this->change_mail_token_repo->deleteEntryByToken(
$token->getToken());
517 $this->change_mail_token_repo->deleteExpiredEntries();
519 $this->tpl->setOnScreenMessage(
521 $this->
lng->txt(
'saved_successfully')
523 $this->showPublicProfile();
529 $this->
tabs->activateTab(
'public_profile');
535 $this->initPublicProfileForm();
538 $this->tpl->setContent($this->
form->getHTML());
539 $this->tpl->printToStdout();
544 if ($this->
settings->get(
'user_portfolios')) {
545 return \ilObjPortfolio::getDefaultPortfolio($this->
user->getId());
552 $this->
form = new \ilPropertyFormGUI();
554 $this->
form->setTitle($this->
lng->txt(
'user_publish_options'));
555 $this->
form->setDescription($this->
lng->txt(
'user_public_profile_info'));
556 $this->
form->setFormAction($this->
ctrl->getFormAction($this));
558 $portfolio_id = $this->getProfilePortfolio();
560 if (!$portfolio_id) {
562 $radg = new \ilRadioGroupInputGUI($this->
lng->txt(
'user_activate_public_profile'),
'public_profile');
563 $info = $this->
lng->txt(
'user_activate_public_profile_info');
567 $op1 = new \ilRadioOption($this->
lng->txt(
'usr_public_profile_disabled'),
'n', $this->lng->txt(
'usr_public_profile_disabled_info'));
568 $radg->addOption($op1);
569 $op2 = new \ilRadioOption($this->
lng->txt(
'usr_public_profile_logged_in'),
'y');
570 $radg->addOption($op2);
571 if ($this->
settings->get(
'enable_global_profiles')) {
572 $op3 = new \ilRadioOption($this->
lng->txt(
'usr_public_profile_global'),
'g');
573 $radg->addOption($op3);
575 $this->
form->addItem($radg);
578 if ($this->
settings->get(
'user_portfolios')) {
580 $href = $this->
ctrl->getLinkTargetByClass(\ilDashboardGUI::class,
'jumpToPortfolio');
581 $prtf =
'<br />' . $this->
lng->txt(
'user_profile_portfolio');
582 $prtf .=
'<br /><a href="' . $href .
'">» ' .
583 $this->
lng->txt(
'user_portfolios') .
'</a>';
587 $radg->setInfo(
$info);
589 $this->
ctrl->setParameterByClass(\ilDashboardGUI::class,
'prt_id', $portfolio_id);
590 $href = $this->
ctrl->getLinkTargetByClass(\ilDashboardGUI::class,
'jumpToPortfolio');
591 $this->
ctrl->clearParameterByClass(\ilDashboardGUI::class,
'prt_id');
592 $prtf = $this->
lng->txt(
'user_profile_portfolio_selected');
593 $prtf .=
'<br /><a href="' . $href .
'">» ' .
594 $this->
lng->txt(
'portfolio') .
'</a>';
596 $info = new \ilCustomInputGUI($this->
lng->txt(
'user_activate_public_profile'));
597 $info->setHtml($prtf);
599 $this->showPublicProfileFields($this->
form);
603 $this->showPublicProfileFields($this->
form,
null, $op2,
false,
'-1');
606 $this->showPublicProfileFields($this->
form,
null, $op3,
false,
'-2');
608 $this->
form->setForceTopButtons(
true);
609 $this->
form->addCommandButton(
'savePublicProfile', $this->
lng->txt(
'user_save_continue'));
614 ?array $prefs =
null,
616 bool $anonymized =
false,
617 string $key_suffix =
''
620 $value = $field->retrieveValueFromUser($this->
user);
621 if (!$anonymized && ($value ===
'' || $value ===
'-')) {
628 if ($field->isVisibleToUser()) {
630 switch ($field->getIdentifier()) {
632 $caption =
'personal_picture';
636 $caption =
'person_title';
640 $caption = $field->getLabel($this->
lng);
642 $cb = new \ilCheckboxInputGUI($caption, self::PUBLISH_SETTINGS_PREFIX . $field->getIdentifier() . $key_suffix);
645 ? $field->isPublishedByUser($this->user)
646 : $prefs[
"public_{$field->getIdentifier()}"] ??
false
651 $this->refinery->kindlyTo()->string(),
652 $this->refinery->custom()->transformation(
653 function (mixed $v):
string {
655 $this->
refinery->kindlyTo()->listOf(
656 $this->refinery->kindlyTo()->string()
658 static fn(
string $c,
string $v):
string =>
$c ===
''
671 $parent->addSubItem($cb);
683 if ($ass->getPosition()) {
684 $badge = new \ilBadge($ass->getBadgeId());
685 $badge_options[] = $badge->getTitle();
689 if (count($badge_options) > 1) {
690 $badge_order = new \ilNonEditableValueGUI($this->
lng->txt(
'obj_bdga'),
'bpos' . $key_suffix);
691 $badge_order->setMultiValues($badge_options);
692 $badge_order->setValue(array_shift($badge_options));
693 $badge_order->setMulti(
true,
true,
false);
696 $form->addItem($badge_order);
698 $parent->addSubItem($badge_order);
705 $ne = new \ilNonEditableValueGUI($this->
lng->txt(
'perma_link'),
'');
706 $ne->setValue(\ilLink::_getLink($this->
user->getId(),
'usr'));
710 $parent->addSubItem($ne);
716 $this->initPublicProfileForm();
717 if (!$this->
form->checkInput()) {
718 $this->
form->setValuesByPost();
719 $this->tpl->showPublicProfile(
true);
722 if ($this->
form->getInput(
'public_profile') !==
'') {
723 $this->
user->setPref(
'public_profile', $this->
form->getInput(
'public_profile'));
726 $this->
user = array_reduce(
727 $this->
profile->getVisibleFields(Context::User, $this->user),
729 $v->setPublishedOnUser(
$c, $this->getPublishedFromPost($v->getIdentifier())),
734 $badge_positions = $this->
form->getInput(
'bpos' . $this->buildKeySuffix()) ?? [];
735 if (is_array($badge_positions) && $badge_positions !== []) {
740 $this->
user = $this->checklist_status->setStepSucessOnUser(
741 ChecklistStatus::STEP_PUBLISH_OPTIONS,
744 $this->
user->update();
748 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
756 $this->
ctrl->redirectByClass([self::class, PrivacySettingsGUI::class],
'');
761 $this->
tabs->activateTab(
'export');
764 $button = $this->ui_factory->link()->standard(
765 $this->
lng->txt(
'pd_export_profile'),
766 $this->ctrl->getLinkTarget($this,
'exportPersonalData')
768 $this->
toolbar->addStickyItem($button);
770 $exp_file = $this->
user->getPersonalDataExportFile();
771 if ($exp_file !=
'') {
772 $this->
toolbar->addSeparator();
774 $this->ui_factory->link()->standard(
775 $this->lng->txt(
"pd_download_last_export_file"),
776 $this->ctrl->getLinkTarget($this,
"downloadPersonalData")
781 $this->
toolbar->addSeparator();
783 $this->ui_factory->link()->standard(
784 $this->lng->txt(
"pd_import_personal_data"),
785 $this->ctrl->getLinkTarget($this,
"importPersonalDataSelection")
789 $this->tpl->printToStdout();
794 $this->
user->exportPersonalData();
795 $this->
user->sendPersonalDataFile();
796 $this->
ctrl->redirect($this,
'showExportImport');
804 $this->
user->sendPersonalDataFile();
809 $this->
tabs->activateTab(
'export');
812 $this->initPersonalDataImportForm();
814 $this->tpl->setContent($this->
form->getHTML());
815 $this->tpl->printToStdout();
820 $this->
form = new \ilPropertyFormGUI();
823 $fi = new \ilFileInputGUI($this->
lng->txt(
'file'),
'file');
824 $fi->setRequired(
true);
825 $fi->setSuffixes([
'zip']);
826 $this->
form->addItem($fi);
829 $cb = new \ilCheckboxInputGUI($this->
lng->txt(
'pd_profile_data'),
'profile_data');
830 $this->
form->addItem($cb);
833 $cb = new \ilCheckboxInputGUI($this->
lng->txt(
'settings'),
'settings');
834 $this->
form->addItem($cb);
837 $cb = new \ilCheckboxInputGUI($this->
lng->txt(
'notes'),
'notes');
838 $this->
form->addItem($cb);
841 $cb = new \ilCheckboxInputGUI($this->
lng->txt(
'pd_private_calendars'),
'calendar');
842 $this->
form->addItem($cb);
844 $this->
form->addCommandButton(
'importPersonalData', $this->
lng->txt(
'import'));
845 $this->
form->addCommandButton(
'showExportImport', $this->
lng->txt(
'cancel'));
847 $this->
form->setTitle($this->
lng->txt(
'pd_import_personal_data'));
848 $this->
form->setFormAction($this->
ctrl->getFormAction($this));
853 $this->initPersonalDataImportForm();
854 if ($this->
form->checkInput()) {
855 $this->
user->importPersonalData(
857 (
bool) $this->
form->getInput(
'profile_data'),
858 (
bool) $this->form->getInput(
'settings'),
859 (
bool) $this->form->getInput(
'notes'),
860 (
bool) $this->form->getInput(
'calendar')
862 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
863 $this->
ctrl->redirect($this,
'');
865 $this->
tabs->activateTab(
'export');
867 $this->
form->setValuesByPost();
868 $this->tpl->setContent($this->
form->getHTML());
869 $this->tpl->printToStdout();
875 $main_tpl = $this->tpl;
876 $main_tpl->setRightContent($this->checklist->render($active_step));
881 $key = self::PUBLISH_SETTINGS_PREFIX . $identifier . $this->buildKeySuffix();
883 if (!$this->
http->wrapper()->post()->has($key)) {
887 return $this->
http->wrapper()->post()->retrieve(
889 $this->
refinery->kindlyTo()->string()
895 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
const STEP_PUBLISH_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
userSettingVisible(string $setting)
initPersonalDataImportForm()
StaticUrlServices $static_url
showPersonalData(bool $a_no_init=false)
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.
getVisibleFields(Context $context, ?\ilObjUser $user=null, array $groups_to_skip=[], array $fields_to_skip=[])
static http()
Fetches the global http state from ILIAS.
form( $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)