ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilUserProfile Class Reference

Class ilUserProfile. More...

+ Collaboration diagram for ilUserProfile:

Public Member Functions

 __construct ()
 Constructor. More...
 
 getStandardFields ()
 Get standard user fields array. More...
 
 getLocalUserAdministrationFields ()
 Get visible fields in local user administration. More...
 
 skipGroup ($a_group)
 Skip a group. More...
 
 skipField ($a_field)
 Skip a field. More...
 
 addStandardFieldsToForm ($a_form, $a_user=null, array $custom_fields=null)
 Add standard fields to form. More...
 
 setAjaxCallback ($a_href)
 

Static Public Member Functions

static userSettingVisible ($a_setting)
 Checks whether user setting is visible. More...
 
static setMode ($mode)
 
static isProfileIncomplete ($a_user, $a_include_udf=true, $a_personal_data_only=true)
 Check if all required personal data fields are set. More...
 
static getIgnorableRequiredSettings ()
 Returns an array of all ignorable profiel fields. More...
 

Data Fields

const MODE_DESKTOP = 1
 
const MODE_REGISTRATION = 2
 

Static Protected Member Functions

static isEditableByUser ($setting)
 Returns whether a profile setting is editable by an user in the profile gui. More...
 

Static Private Attributes

static $mode = self::MODE_DESKTOP
 
static $user_field
 

Detailed Description

Class ilUserProfile.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 15 of file class.ilUserProfile.php.

Constructor & Destructor Documentation

◆ __construct()

ilUserProfile::__construct ( )

Constructor.

Definition at line 373 of file class.ilUserProfile.php.

374 {
375 global $lng;
376
377 $this->skip_groups = array();
378 $this->skip_fields = array();
379
380 // for hide me from awareness tool text
381 // not nicest workaround, but better than using common block
382 $lng->loadLanguageModule("awrn");
383 $lng->loadLanguageModule("buddysystem");
384 }
global $lng
Definition: privfeed.php:17

References $lng.

Member Function Documentation

◆ addStandardFieldsToForm()

ilUserProfile::addStandardFieldsToForm (   $a_form,
  $a_user = null,
array  $custom_fields = null 
)

Add standard fields to form.

Definition at line 444 of file class.ilUserProfile.php.

445 {
446 global $ilSetting, $lng, $rbacreview, $ilias;
447
448 // custom registration settings
449 if (self::$mode == self::MODE_REGISTRATION) {
450 include_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
451 $registration_settings = new ilRegistrationSettings();
452
453 self::$user_field["username"]["group"] = "login_data";
454 self::$user_field["password"]["group"] = "login_data";
455 self::$user_field["language"]["default"] = $lng->lang_key;
456
457 // different position for role
458 $roles = self::$user_field["roles"];
459 unset(self::$user_field["roles"]);
460 self::$user_field["roles"] = $roles;
461 self::$user_field["roles"]["group"] = "settings";
462 }
463
464 $fields = $this->getStandardFields();
465 $current_group = "";
466 $custom_fields_done = false;
467 foreach ($fields as $f => $p) {
468 // next group? -> diplay subheader
469 if (($p["group"] != $current_group) &&
471 if (is_array($custom_fields) && !$custom_fields_done) {
472 // should be appended to "other" or at least before "settings"
473 if ($current_group == "other" || $p["group"] == "settings") {
474 // add "other" subheader
475 if ($current_group != "other") {
476 $sh = new ilFormSectionHeaderGUI();
477 $sh->setTitle($lng->txt("other"));
478 $a_form->addItem($sh);
479 }
480 foreach ($custom_fields as $custom_field) {
481 $a_form->addItem($custom_field);
482 }
483 $custom_fields_done = true;
484 }
485 }
486
487 $sh = new ilFormSectionHeaderGUI();
488 $sh->setTitle($lng->txt($p["group"]));
489 $a_form->addItem($sh);
490 $current_group = $p["group"];
491 }
492
493 $m = "";
494 if (isset($p["method"])) {
495 $m = $p["method"];
496 }
497
498 $lv = (isset($p["lang_var"]) && $p["lang_var"] != "")
499 ? $p["lang_var"]
500 : $f;
501
502 switch ($p["input"]) {
503 case "login":
504 if ((int) $ilSetting->get('allow_change_loginname') || self::$mode == self::MODE_REGISTRATION) {
505 $val = new ilTextInputGUI($lng->txt('username'), 'username');
506 if ($a_user) {
507 $val->setValue($a_user->getLogin());
508 }
509 $val->setMaxLength($p['maxlength']);
510 $val->setSize(40);
511 $val->setRequired(true);
512 } else {
513 // user account name
514 $val = new ilNonEditableValueGUI($lng->txt("username"), 'ne_un');
515 if ($a_user) {
516 $val->setValue($a_user->getLogin());
517 }
518 }
519 $a_form->addItem($val);
520 break;
521
522 case "text":
524 $ti = new ilTextInputGUI($lng->txt($lv), "usr_" . $f);
525 if ($a_user) {
526 $ti->setValue($a_user->$m());
527 }
528 $ti->setMaxLength($p["maxlength"]);
529 $ti->setSize($p["size"]);
530 $ti->setRequired($ilSetting->get("require_" . $f));
531 if (!$ti->getRequired() || $ti->getValue()) {
532 $ti->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
533 }
534 $a_form->addItem($ti);
535 }
536 break;
537
538 case "sel_country":
540 include_once("./Services/Form/classes/class.ilCountrySelectInputGUI.php");
541 $ci = new ilCountrySelectInputGUI($lng->txt($lv), "usr_" . $f);
542 if ($a_user) {
543 $ci->setValue($a_user->$m());
544 }
545 $ci->setRequired($ilSetting->get("require_" . $f));
546 if (!$ci->getRequired() || $ci->getValue()) {
547 $ci->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
548 }
549 $a_form->addItem($ci);
550 }
551 break;
552
553 case "birthday":
555 $bi = new ilBirthdayInputGUI($lng->txt($lv), "usr_" . $f);
556 include_once "./Services/Calendar/classes/class.ilDateTime.php";
557 $date = null;
558 if ($a_user && strlen($a_user->$m())) {
559 $date = new ilDateTime($a_user->$m(), IL_CAL_DATE);
560 $bi->setDate($date);
561 }
562 $bi->setRequired($ilSetting->get("require_" . $f));
563 if (!$bi->getRequired() || $date) {
564 $bi->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
565 }
566 $a_form->addItem($bi);
567 }
568 break;
569
570 case "radio":
572 $rg = new ilRadioGroupInputGUI($lng->txt($lv), "usr_" . $f);
573 if ($a_user) {
574 $rg->setValue($a_user->$m());
575 }
576 foreach ($p["values"] as $k => $v) {
577 $op = new ilRadioOption($lng->txt($v), $k);
578 $rg->addOption($op);
579 }
580 $rg->setRequired($ilSetting->get("require_" . $f));
581 if (!$rg->getRequired() || $rg->getValue()) {
582 $rg->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
583 }
584 $a_form->addItem($rg);
585 }
586 break;
587
588 case "picture":
589 if (ilUserProfile::userSettingVisible("upload") && $a_user) {
590 $ii = new ilImageFileInputGUI($lng->txt("personal_picture"), "userfile");
591 $ii->setDisabled($ilSetting->get("usr_settings_disable_upload"));
592
593 $upload = $a_form->getFileUpload("userfile");
594 if ($upload["name"]) {
595 $ii->setPending($upload["name"]);
596 } else {
597 $im = ilObjUser::_getPersonalPicturePath(
598 $a_user->getId(),
599 "small",
600 true,
601 true
602 );
603 if ($im != "") {
604 $ii->setImage($im);
605 $ii->setAlt($lng->txt("personal_picture"));
606 }
607 }
608
609 $a_form->addItem($ii);
610 }
611 break;
612
613 case "roles":
614 if (self::$mode == self::MODE_DESKTOP) {
616 $global_roles = $rbacreview->getGlobalRoles();
617 foreach ($global_roles as $role_id) {
618 if (in_array($role_id, $rbacreview->assignedRoles($a_user->getId()))) {
619 $roleObj = $ilias->obj_factory->getInstanceByObjId($role_id);
620 $role_names .= $roleObj->getTitle() . ", ";
621 unset($roleObj);
622 }
623 }
624 $dr = new ilNonEditableValueGUI($lng->txt("default_roles"), "ne_dr");
625 $dr->setValue(substr($role_names, 0, -2));
626 $a_form->addItem($dr);
627 }
628 } elseif (self::$mode == self::MODE_REGISTRATION) {
629 if ($registration_settings->roleSelectionEnabled()) {
630 include_once("./Services/AccessControl/classes/class.ilObjRole.php");
631 $options = array();
632 foreach (ilObjRole::_lookupRegisterAllowed() as $role) {
633 $options[$role["id"]] = $role["title"];
634 }
635 // registration form validation will take care of missing field / value
636 if ($options) {
637 if (sizeof($options) > 1) {
638 $ta = new ilSelectInputGUI($lng->txt('default_role'), "usr_" . $f);
639 $ta->setOptions($options);
640 $ta->setRequired($ilSetting->get("require_" . $f));
641 if (!$ta->getRequired()) {
642 $ta->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
643 }
644 }
645 // no need for select if only 1 option
646 else {
647 $ta = new ilHiddenInputGUI("usr_" . $f);
648 $ta->setValue(array_shift(array_keys($options)));
649 }
650 $a_form->addItem($ta);
651 }
652 }
653 }
654 break;
655
656 case "email":
658 $em = new ilEMailInputGUI($lng->txt($lv), "usr_" . $f);
659 if ($a_user) {
660 $em->setValue($a_user->$m());
661 }
662 $em->setRequired($ilSetting->get("require_" . $f));
663 if (!$em->getRequired() || $em->getValue()) {
664 $em->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
665 }
666 if (self::MODE_REGISTRATION == self::$mode) {
667 $em->setRetype(true);
668 }
669 $a_form->addItem($em);
670 }
671 break;
672 case "second_email":
674 $em = new ilEMailInputGUI($lng->txt($lv), "usr_" . $f);
675 if ($a_user) {
676 $em->setValue($a_user->$m());
677 }
678 $em->setRequired($ilSetting->get("require_" . $f));
679 if (!$em->getRequired() || $em->getValue()) {
680 $em->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
681 }
682 if (self::MODE_REGISTRATION == self::$mode) {
683 $em->setRetype(true);
684 }
685 $a_form->addItem($em);
686 }
687 break;
688 case "textarea":
690 $ta = new ilTextAreaInputGUI($lng->txt($lv), "usr_" . $f);
691 if ($a_user) {
692 $ta->setValue($a_user->$m());
693 }
694 $ta->setRows($p["rows"]);
695 $ta->setCols($p["cols"]);
696 $ta->setRequired($ilSetting->get("require_" . $f));
697 if (!$ta->getRequired() || $ta->getValue()) {
698 $ta->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
699 }
700 $a_form->addItem($ta);
701 }
702 break;
703
704 case "password":
705 if (self::$mode == self::MODE_REGISTRATION) {
706 if (!$registration_settings->passwordGenerationEnabled()) {
707 $ta = new ilPasswordInputGUI($lng->txt($lv), "usr_" . $f);
708 $ta->setUseStripSlashes(false);
709 $ta->setRequired(true);
711 // $ta->setDisabled($ilSetting->get("usr_settings_disable_".$f));
712 } else {
713 $ta = new ilNonEditableValueGUI($lng->txt($lv));
714 $ta->setValue($lng->txt("reg_passwd_via_mail"));
715 }
716 $a_form->addItem($ta);
717 }
718 break;
719
720 case "language":
722 $ta = new ilSelectInputGUI($lng->txt($lv), "usr_" . $f);
723 if ($a_user) {
724 $ta->setValue($a_user->$m());
725 }
726 $options = array();
727 $lng->loadLanguageModule("meta");
728 foreach ($lng->getInstalledLanguages() as $lang_key) {
729 $options[$lang_key] = $lng->txt("meta_l_" . $lang_key);
730 }
731 asort($options); // #9728
732 $ta->setOptions($options);
733 $ta->setRequired($ilSetting->get("require_" . $f));
734 if (!$ta->getRequired() || $ta->getValue()) {
735 $ta->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
736 }
737 $a_form->addItem($ta);
738 }
739 break;
740
741 case "multitext":
743 $ti = new ilTextInputGUI($lng->txt($lv), "usr_" . $f);
744 $ti->setMulti(true);
745 if ($a_user) {
746 $ti->setValue($a_user->$m());
747 }
748 $ti->setMaxLength($p["maxlength"]);
749 $ti->setSize($p["size"]);
750 $ti->setRequired($ilSetting->get("require_" . $f));
751 if (!$ti->getRequired() || $ti->getValue()) {
752 $ti->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
753 }
754 if ($this->ajax_href) {
755 // add field to ajax call
756 $ti->setDataSource($this->ajax_href . "&f=" . $f);
757 }
758 $a_form->addItem($ti);
759 }
760 break;
761 case "noneditable":
762 if (self::$mode == self::MODE_DESKTOP && ilUserProfile::userSettingVisible($f)) {
763 $ne = new ilNonEditableValueGUI($lng->txt($lv));
764 $ne->setValue($a_user->$m());
765 $a_form->addItem($ne);
766 }
767 break;
768 }
769 }
770
771 // append custom fields as "other"
772 if (is_array($custom_fields) && !$custom_fields_done) {
773 // add "other" subheader
774 if ($current_group != "other") {
775 $sh = new ilFormSectionHeaderGUI();
776 $sh->setTitle($lng->txt("other"));
777 $a_form->addItem($sh);
778 }
779 foreach ($custom_fields as $custom_field) {
780 $a_form->addItem($custom_field);
781 }
782 }
783 }
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
const IL_CAL_DATE
This class represents a text property in a property form.
This class represents a selection list property in a property form.
@classDescription Date and time handling
This class represents a email property in a property form.
This class represents a section header in a property form.
This class represents a hidden form property in a property form.
This class represents an image file property in a property form.
This class represents a non editable value in a property form.
static _lookupRegisterAllowed()
get all roles that are activated in user registration
This class represents a password property in a property form.
This class represents a property in a property form.
This class represents an option in a radio group.
Class ilObjAuthSettingsGUI.
This class represents a selection list property in a property form.
This class represents a text area property in a property form.
This class represents a text property in a property form.
getStandardFields()
Get standard user fields array.
static userSettingVisible($a_setting)
Checks whether user setting is visible.
static getPasswordRequirementsInfo()
infotext for ilPasswordInputGUI setInfo()
global $ilSetting
Definition: privfeed.php:17

References $ilSetting, $lng, $m, $options, ilObjRole\_lookupRegisterAllowed(), ilUtil\getPasswordRequirementsInfo(), getStandardFields(), IL_CAL_DATE, MODE_REGISTRATION, and userSettingVisible().

+ Here is the call graph for this function:

◆ getIgnorableRequiredSettings()

static ilUserProfile::getIgnorableRequiredSettings ( )
static

Returns an array of all ignorable profiel fields.

Returns
array @access public

@global ilSetting

Definition at line 905 of file class.ilUserProfile.php.

906 {
912 global $ilSetting;
913
914 $ignorableSettings = array();
915
916 foreach (self::$user_field as $field => $definition) {
917 // !!!username and password must not be ignored!!!
918 if ('username' == $field ||
919 'password' == $field) {
920 continue;
921 }
922
923 // Field is not required -> continue
924 if (!$ilSetting->get('require_' . $field)) {
925 continue;
926 }
927
928 if (self::isEditableByUser($field)) {
929 $ignorableSettings[] = $field;
930 }
931 }
932
933 return $ignorableSettings;
934 }

References $ilSetting.

Referenced by ilObjUserGUI\handleIgnoredRequiredFields().

+ Here is the caller graph for this function:

◆ getLocalUserAdministrationFields()

ilUserProfile::getLocalUserAdministrationFields ( )

Get visible fields in local user administration.

Returns

Definition at line 407 of file class.ilUserProfile.php.

408 {
409 global $ilSetting;
410
411 $settings = $ilSetting->getAll();
412
413 $fields = array();
414 foreach ($this->getStandardFields() as $field => $info) {
415 if ($ilSetting->get('usr_settings_visib_lua_' . $field, 1)) {
416 $fields[$field] = $info;
417 } elseif ($info['visib_lua_fix_value']) {
418 $fields[$field] = $info;
419 }
420 }
421 return $fields;
422 }
$info
Definition: index.php:5

References $ilSetting, $info, and getStandardFields().

+ Here is the call graph for this function:

◆ getStandardFields()

ilUserProfile::getStandardFields ( )

Get standard user fields array.

Definition at line 389 of file class.ilUserProfile.php.

390 {
391 $fields = array();
392 foreach (self::$user_field as $f => $p) {
393 // skip hidden groups
394 if (in_array($p["group"], $this->skip_groups) ||
395 in_array($f, $this->skip_fields)) {
396 continue;
397 }
398 $fields[$f] = $p;
399 }
400 return $fields;
401 }

Referenced by addStandardFieldsToForm(), and getLocalUserAdministrationFields().

+ Here is the caller graph for this function:

◆ isEditableByUser()

static ilUserProfile::isEditableByUser (   $setting)
staticprotected

Returns whether a profile setting is editable by an user in the profile gui.

Parameters
stringA key of a profile setting
Returns
boolean Determines whether the passed setting can be edited by the user itself @access protected

@global ilSetting

Definition at line 877 of file class.ilUserProfile.php.

878 {
884 global $ilSetting;
885
886 // Not visible in personal data or not changeable
887 if ($ilSetting->get('usr_settings_hide_' . $setting) == 1 ||
888 $ilSetting->get('usr_settings_disable_' . $setting) == 1) {
889 // User has no chance to edit this field
890 return false;
891 }
892
893 return true;
894 }

References $ilSetting.

◆ isProfileIncomplete()

static ilUserProfile::isProfileIncomplete (   $a_user,
  $a_include_udf = true,
  $a_personal_data_only = true 
)
static

Check if all required personal data fields are set.

Parameters
ilObjUser$a_user
bool$a_include_udfcheck custom fields, too
bool$a_personal_data_onlyonly check fields which are visible in personal data
Returns
bool

Definition at line 826 of file class.ilUserProfile.php.

827 {
828 global $ilSetting;
829
830 // standard fields
831 foreach (self::$user_field as $field => $definition) {
832 // only if visible in personal data
833 if ($a_personal_data_only && $ilSetting->get("usr_settings_hide_" . $field)) {
834 continue;
835 }
836
837 if ($ilSetting->get("require_" . $field) && $definition["method"]) {
838 $value = $a_user->{$definition["method"]}();
839 if ($value == "") {
840 return true;
841 }
842 }
843 }
844
845 // custom fields
846 if ($a_include_udf) {
847 $user_defined_data = $a_user->getUserDefinedData();
848
849 include_once './Services/User/classes/class.ilUserDefinedFields.php';
850 $user_defined_fields = ilUserDefinedFields::_getInstance();
851 foreach ($user_defined_fields->getRequiredDefinitions() as $field => $definition) {
852 // only if visible in personal data
853 if ($a_personal_data_only && !$definition["visible"]) {
854 continue;
855 }
856
857 if (!$user_defined_data["f_" . $field]) {
858 ilLoggerFactory::getLogger('user')->info('Profile is incomplete due to missing required udf.');
859 return true;
860 }
861 }
862 }
863
864 return false;
865 }
static getLogger($a_component_id)
Get component logger.
static _getInstance()
Get instance.

References $ilSetting.

Referenced by ilUserImportParser\checkProfileIncomplete(), ilAuthFrontend\handleAuthenticationSuccess(), ilAuthBase\loginObserver(), ilObjUserGUI\saveObject(), and ilObjUserGUI\updateObject().

+ Here is the caller graph for this function:

◆ setAjaxCallback()

ilUserProfile::setAjaxCallback (   $a_href)

Definition at line 785 of file class.ilUserProfile.php.

786 {
787 $this->ajax_href = $a_href;
788 }

◆ setMode()

static ilUserProfile::setMode (   $mode)
static

Definition at line 807 of file class.ilUserProfile.php.

808 {
809 global $lng;
810
811 if (in_array($mode, array(self::MODE_DESKTOP, self::MODE_REGISTRATION))) {
812 self::$mode = $mode;
813 return true;
814 }
815 return false;
816 }

References $lng, and $mode.

◆ skipField()

ilUserProfile::skipField (   $a_field)

Skip a field.

Definition at line 436 of file class.ilUserProfile.php.

437 {
438 $this->skip_fields[] = $a_field;
439 }

◆ skipGroup()

ilUserProfile::skipGroup (   $a_group)

Skip a group.

Definition at line 428 of file class.ilUserProfile.php.

429 {
430 $this->skip_groups[] = $a_group;
431 }

◆ userSettingVisible()

static ilUserProfile::userSettingVisible (   $a_setting)
static

Checks whether user setting is visible.

Definition at line 793 of file class.ilUserProfile.php.

794 {
795 global $ilSetting;
796
797 if (self::$mode == self::MODE_DESKTOP) {
798 return ($ilSetting->get("usr_settings_hide_" . $a_setting) != 1);
799 } else {
800 if (isset(self::$user_field[$a_setting]["visib_reg_hide"]) && self::$user_field[$a_setting]["visib_reg_hide"] === true) {
801 return true;
802 }
803 return ($ilSetting->get("usr_settings_visib_reg_" . $a_setting, "1") || $ilSetting->get("require_" . $a_setting, "0"));
804 }
805 }

References $ilSetting.

Referenced by addStandardFieldsToForm(), and ilUserDataSet\importRecord().

+ Here is the caller graph for this function:

Field Documentation

◆ $mode

ilUserProfile::$mode = self::MODE_DESKTOP
staticprivate

Definition at line 20 of file class.ilUserProfile.php.

Referenced by setMode().

◆ $user_field

ilUserProfile::$user_field
staticprivate

Definition at line 46 of file class.ilUserProfile.php.

◆ MODE_DESKTOP

const ilUserProfile::MODE_DESKTOP = 1

Definition at line 17 of file class.ilUserProfile.php.

◆ MODE_REGISTRATION

const ilUserProfile::MODE_REGISTRATION = 2

The documentation for this class was generated from the following file: