ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Alias.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24use ILIAS\User\Profile\Fields\NoOverrides;
28
29class Alias implements FieldDefinition
30{
31 use NoOverrides;
32
33 public function getIdentifier(): string
34 {
35 return 'username';
36 }
37
38 public function getLabel(Language $lng): string
39 {
40 return $lng->txt('login');
41 }
42
43 public function getSection(): AvailableSections
44 {
45 return AvailableSections::PersonalData;
46 }
47
48 public function visibleInRegistrationForcedTo(): ?bool
49 {
50 return true;
51 }
52
53 public function visibleToUserForcedTo(): ?bool
54 {
55 return true;
56 }
57
59 {
60 return true;
61 }
62
63 public function visibleInCoursesForcedTo(): ?bool
64 {
65 return true;
66 }
67
68 public function visibleInGroupsForcedTo(): ?bool
69 {
70 return true;
71 }
72
73 public function visibleInStudyProgrammesForcedTo(): ?bool
74 {
75 return false;
76 }
77
78 public function requiredForcedTo(): ?bool
79 {
80 return true;
81 }
82
83 public function searchableForcedTo(): ?bool
84 {
85 return true;
86 }
87
88 public function availableInCertificatesForcedTo(): ?bool
89 {
90 return true;
91 }
92
93 public function getLegacyInput(
96 ?\ilObjUser $user = null
98 $lng->loadLanguageModule('administration');
99
100 $input = new \ilUserLoginInputGUI($lng->txt('login'), 'login');
101 if ($user === null) {
102 return $input;
103 }
104
105 $input->setCurrentUserId($user->getId());
106 $input->setValue(
107 $this->retrieveValueFromUser($user)
108 );
109
110 $last_history_entry = $user->getLastHistoryData();
111 if ($last_history_entry === null) {
112 return $input;
113 }
114
115 $input->setInfo(
116 sprintf(
117 $lng->txt('usr_loginname_history_info'),
118 \ilDatePresentation::formatDate(new \ilDateTime($last_history_entry[1], IL_CAL_UNIX)),
119 $last_history_entry[0]
120 )
121 );
122 return $input;
123 }
124
125 public function addValueToUserObject(
126 \ilObjUser $user,
127 mixed $input,
128 ?\ilPropertyFormGUI $form = null
129 ): \ilObjUser {
130 $user->setLogin($input);
131 return $user;
132 }
133
134 public function retrieveValueFromUser(\ilObjUser $user): string
135 {
136 return $user->getLogin();
137 }
138}
getLegacyInput(Language $lng, Context $context, ?\ilObjUser $user=null)
You don't need to add a post_var to the input as the User will handle this for you,...
Definition: Alias.php:93
retrieveValueFromUser(\ilObjUser $user)
Definition: Alias.php:134
addValueToUserObject(\ilObjUser $user, mixed $input, ?\ilPropertyFormGUI $form=null)
Definition: Alias.php:125
const IL_CAL_UNIX
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
This class represents a property in a property form.
User class.
This class represents a property form user interface.
global $lng
Definition: privfeed.php:31
$context
Definition: webdav.php:31