19 declare(strict_types=1);
33 private int $mode = self::MODE_DESKTOP;
51 $this->
lng = $DIC[
'lng'];
52 $this->rbac_review = $DIC[
'rbacreview'];
54 $this->user_fields = (
new DefaultFields())->getDefaultProfileFields();
57 $this->skip_groups = [];
58 $this->skip_fields = [];
60 $this->
lng->loadLanguageModule(
'awrn');
61 $this->
lng->loadLanguageModule(
'buddysystem');
67 foreach ($this->user_fields as
$f => $p) {
69 if (in_array($p[
'group'], $this->skip_groups) ||
70 in_array(
$f, $this->skip_fields)) {
82 if ($this->
settings->get(
'usr_settings_visib_lua_' . $field,
'1')) {
83 $fields[$field] = $info;
84 } elseif ($info[
'visib_lua_fix_value'] ??
false) {
85 $fields[$field] = $info;
93 $this->skip_groups[] = $group;
98 $this->skip_fields[] = $field;
104 array $custom_fields = []
106 $registration_settings =
null;
107 if ($this->mode === self::MODE_REGISTRATION) {
113 $custom_fields_done =
false;
116 if (($field_definition[
'group'] !== $current_group) &&
121 $field_definition[
'group'],
131 $registration_settings
136 if ($custom_fields !== [] && !$custom_fields_done) {
147 $this->user_fields[
'username'][
'group'] =
'login_data';
148 $this->user_fields[
'password'][
'group'] =
'login_data';
149 $this->user_fields[
'language'][
'default'] = $this->
lng->lang_key;
152 $roles = $this->user_fields[
'roles'];
153 unset($this->user_fields[
'roles']);
154 $this->user_fields[
'roles'] = $roles;
155 $this->user_fields[
'roles'][
'group'] =
'settings';
160 string $current_group,
162 array $custom_fields,
163 bool $custom_fields_done
165 if ($custom_fields !== [] && !$custom_fields_done
166 && ($current_group ===
'other' || $next_group ===
'settings')) {
173 $custom_fields_done =
true;
177 $section_header->setTitle($this->
lng->txt($next_group));
178 $form->
addItem($section_header);
188 array $field_definition,
193 $method = $field_definition[
'method'] ??
'';
195 $lang_var = (isset($field_definition[
'lang_var']) && $field_definition[
'lang_var'] !==
'')
196 ? $field_definition[
'lang_var']
199 switch ($field_definition[
'input']) {
301 $roles_input = $this->
getRolesInput($field_id, $registration_settings, $user);
302 if ($roles_input !==
null) {
309 $email_mandatory = $this->mode === self::MODE_REGISTRATION
310 && $field_definition[
'input'] ===
'email' 311 && $registration_settings !==
null 330 if ($this->mode !== self::MODE_REGISTRATION) {
338 $registration_settings
374 array $field_definition,
379 $text_input =
new ilTextInputGUI($this->
lng->txt($lang_var),
'usr_' . $field_id);
380 $text_input->setValue(
'');
381 if ($user !==
null) {
382 $text_input->setValue($user->$method() ??
'');
384 $text_input->setMaxLength($field_definition[
'maxlength']);
385 $text_input->setSize($field_definition[
'size']);
386 $text_input->setRequired((
bool) $this->
settings->get(
'require_' . $field_id));
387 if (!$text_input->getRequired() || $text_input->getValue()) {
388 $text_input->setDisabled((
bool) $this->
settings->get(
'usr_settings_disable_' . $field_id));
396 array $field_definition,
402 if ($user !==
null) {
403 $text_area->
setValue($user->$method() ??
'');
405 $text_area->setRows($field_definition[
'rows']);
406 $text_area->setCols($field_definition[
'cols']);
407 $text_area->setRequired((
bool) $this->
settings->get(
'require_' . $field_id));
408 if (!$text_area->getRequired() || $text_area->getValue()) {
409 $text_area->setDisabled((
bool) $this->
settings->get(
'usr_settings_disable_' . $field_id));
416 array $field_definition,
421 $multi_text_input =
new ilTextInputGUI($this->
lng->txt($lang_var),
'usr_' . $field_id);
422 $multi_text_input->setMulti(
true);
423 if ($user !==
null) {
424 $multi_text_input->setValue($user->$method());
426 $multi_text_input->setMaxLength($field_definition[
'maxlength']);
427 $multi_text_input->setSize($field_definition[
'size']);
428 $multi_text_input->setRequired((
bool) $this->
settings->get(
'require_' . $field_id));
429 if (!$multi_text_input->getRequired() || $multi_text_input->getValue()) {
430 $multi_text_input->setDisabled((
bool) $this->
settings->get(
'usr_settings_disable_' . $field_id));
432 if ($this->ajax_href) {
434 $multi_text_input->setDataSource($this->ajax_href .
'&f=' . $field_id);
436 return $multi_text_input;
441 array $field_definition,
448 $radio_group->
setValue($user->$method());
450 foreach ($field_definition[
'values'] as $k => $v) {
452 $radio_group->addOption($op);
454 $radio_group->setRequired((
bool) $this->
settings->get(
'require_' . $field_id));
455 if (!$radio_group->getRequired() || $radio_group->getValue()) {
456 $radio_group->
setDisabled((
bool) $this->
settings->get(
'usr_settings_disable_' . $field_id));
462 array $field_definition,
467 if ((
int) $this->
settings->get(
'allow_change_loginname') || $this->mode == self::MODE_REGISTRATION) {
469 $login_input->setMaxLength((
int) $field_definition[
'maxlength']);
470 $login_input->setSize(255);
471 $login_input->setRequired(
true);
474 if ($user !==
null) {
475 $login_input->setValue($user->
getLogin());
488 $country_input->
setValue($user->$method());
490 $country_input->setRequired((
bool) $this->
settings->get(
'require_' . $field_id));
491 if (!$country_input->getRequired() || $country_input->getValue()) {
492 $country_input->setDisabled((
bool) $this->
settings->get(
'usr_settings_disable_' . $field_id));
494 return $country_input;
505 if ($user && $user->$method() && strlen($user->$method())) {
507 $birthday_input->setDate($date);
509 $birthday_input->setRequired((
bool) $this->
settings->get(
'require_' . $field_id));
510 if (!$birthday_input->getRequired() || $date !==
null) {
511 $birthday_input->setDisabled((
bool) $this->
settings->get(
'usr_settings_disable_' . $field_id));
513 return $birthday_input;
522 $image_input->setDisabled((
bool) $this->
settings->get(
'usr_settings_disable_upload'));
524 if ($file_upload[
'name'] ??
false) {
525 $image_input->setPending($file_upload[
'name']);
533 if ($picture_path !==
'') {
534 $image_input->setImage($picture_path);
535 $image_input->setAlt($this->
lng->txt(
'personal_picture'));
547 if ($this->mode === self::MODE_DESKTOP
549 $global_roles = $this->rbac_review->getGlobalRoles();
550 foreach ($global_roles as $role_id) {
551 if (in_array($role_id, $this->rbac_review->assignedRoles($user->
getId()))) {
553 $role_names .= $role_obj->getTitle() .
', ';
558 $roles_input->setValue(substr($role_names, 0, -2));
562 if ($this->mode === self::MODE_REGISTRATION
566 $options[$role[
'id']] = $role[
'title'];
569 if ($options === []) {
573 if (count($options) === 1) {
575 $keys = array_keys($options);
576 $roles_input->setValue((
string) array_shift($keys));
580 $options_with_empty_value = [
'' => $this->
lng->txt(
'please_choose')] + $options;
582 $roles_input->
setOptions($options_with_empty_value);
583 $roles_input->setRequired(
true);
584 if (!$roles_input->getRequired()) {
585 $roles_input->setDisabled((
bool) $this->
settings->get(
'usr_settings_disable_' . $field_id));
597 bool $email_mandatory,
602 $email_input->
setValue($user->$method());
604 $email_input->setRequired($email_mandatory || $this->
settings->get(
'require_' . $field_id));
605 if (!$email_input->getRequired() || $email_input->getValue()) {
606 $email_input->setDisabled((
bool) $this->
settings->get(
'usr_settings_disable_' . $field_id));
608 if (self::MODE_REGISTRATION === $this->mode) {
609 $email_input->setRetype(
true);
621 $password_input->setValue($this->
lng->txt(
'reg_passwd_via_mail'));
622 return $password_input;
627 $password_input->setRequired(
true);
629 return $password_input;
639 $this->
lng->loadLanguageModule(
'meta');
640 foreach ($this->
lng->getInstalledLanguages() as $lang_key) {
641 $options[$lang_key] = $this->
lng->txt(
'meta_l_' . $lang_key);
646 if ($user !==
null) {
647 $language_input->
setValue($user->$method());
650 $language_input->setOptions($options);
651 $language_input->setRequired((
bool) $this->
settings->get(
'require_' . $field_id));
652 if (!$language_input->getRequired() || $language_input->getValue()) {
653 $language_input->setDisabled(
654 $this->
settings->get(
'usr_settings_disable_' . $field_id) ===
'1' 655 || count($options) <= 1
658 return $language_input;
667 $non_editable_input->setValue($user->$method());
668 return $non_editable_input;
673 array $custom_fields,
674 string $current_group
676 if ($current_group !==
'other') {
678 $section_header->setTitle($this->
lng->txt(
'other'));
679 $form->
addItem($section_header);
681 foreach ($custom_fields as $custom_field) {
689 $this->ajax_href = $href;
694 if ($this->mode === self::MODE_DESKTOP) {
695 return ($this->user_settings_config->isVisible($setting));
698 if (isset($this->user_fields[$setting][
'visib_reg_hide'])
699 && $this->user_fields[$setting][
'visib_reg_hide'] ===
true) {
703 return ($this->
settings->get(
'usr_settings_visib_reg_' . $setting,
'1')
704 || $this->
settings->get(
'require_' . $setting,
'0'));
709 if (in_array($mode, [self::MODE_DESKTOP, self::MODE_REGISTRATION])) {
718 bool $include_udf =
true,
719 bool $personal_data_only =
true 722 foreach ($this->user_fields as $field => $definition) {
724 if ($personal_data_only && !$this->user_settings_config->isVisible($field)) {
728 if ($this->
settings->get(
'require_' . $field) && $definition[
'method']
729 && empty($user->{$definition[
'method']}())) {
739 $user_defined_data = $user->getUserDefinedData();
741 foreach ($user_defined_fields->getRequiredDefinitions() as $field => $definition) {
743 if ($personal_data_only && !$definition[
'visible']) {
747 if (!($user_defined_data[
'f_' . $field] ??
false)) {
758 return $this->user_settings_config->isVisibleAndChangeable($setting);
763 $ignorableSettings = [];
765 foreach (array_keys($this->user_fields) as $field) {
767 if (
'username' == $field ||
768 'password' == $field) {
773 if (!$this->
settings->get(
'require_' . $field)) {
778 $ignorableSettings[] = $field;
782 return $ignorableSettings;
This class represents an option in a radio group.
getEmailInput(string $field_id, string $method, string $lang_var, bool $email_mandatory, ?ilObjUser $user)
setAjaxCallback(string $href)
getIgnorableRequiredSettings()
addCustomFieldsToForm(ilPropertyFormGUI $form, array $custom_fields, string $current_group)
static getLogger(string $a_component_id)
Get component logger.
getLocalUserAdministrationFields()
static _lookupRegisterAllowed()
get all roles that are activated in user registration
setDisabled(bool $a_disabled)
userSettingVisible(string $setting)
getRolesInput(string $field_id, ?ilRegistrationSettings $registration_settings, ?ilObjUser $user)
getTextareaInput(string $field_id, array $field_definition, string $method, string $lang_var, ?ilObjUser $user)
addStandardFieldsToForm(ilPropertyFormGUI $form, ?ilObjUser $user=null, array $custom_fields=[])
getMultitextInput(string $field_id, array $field_definition, string $method, string $lang_var, ?ilObjUser $user)
getBirthdayInput(string $field_id, string $method, string $lang_var, ?ilObjUser $user)
handleSectionChange(ilPropertyFormGUI $form, string $current_group, string $next_group, array $custom_fields, bool $custom_fields_done)
passwordGenerationEnabled()
setValue(string $a_value)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
ilRbacReview $rbac_review
addFieldToForm(string $field_id, array $field_definition, ?ilObjUser $user, ilPropertyFormGUI $form, ?ilRegistrationSettings $registration_settings)
addRegistrationFieldsToFieldArray()
getLoginInput(array $field_definition, ?ilObjUser $user)
getTextInput(string $field_id, array $field_definition, string $method, string $lang_var, ?ilObjUser $user)
static getPasswordRequirementsInfo()
infotext for ilPasswordInputGUI setInfo()
getNonEditableInput(string $method, string $lang_var, ilObjUser $user)
static _getPersonalPicturePath(int $a_usr_id, string $a_size='small', bool $a_force_pic=false, bool $a_prevent_no_photo_image=false, bool $html_export=false)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
Class ilObjAuthSettingsGUI.
ilUserSettingsConfig $user_settings_config
isProfileIncomplete(ilObjUser $user, bool $include_udf=true, bool $personal_data_only=true)
getPasswordInput(string $field_id, string $lang_var, ilRegistrationSettings $registration_settings)
__construct(Container $dic, ilPlugin $plugin)
This class represents a text area property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getRadioInput(string $field_id, array $field_definition, string $method, string $lang_var, ?ilObjUser $user)
getCountryInput(string $field_id, string $method, string $lang_var, ?ilObjUser $user)
getLanguageInput(string $field_id, string $method, string $lang_var, ?ilObjUser $user)
isEditableByUser(string $setting)
getImageInput(array $file_upload, ?ilObjUser $user)