ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ClientIP.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 ClientIP implements FieldDefinition
30{
31 use NoOverrides;
32
33 public function getIdentifier(): string
34 {
35 return 'client_ip';
36 }
37
38 public function getLabel(Language $lng): string
39 {
40 return $lng->txt($this->getIdentifier());
41 }
42
43 public function getSection(): AvailableSections
44 {
46 }
47
48 public function hiddenInLists(): bool
49 {
50 return true;
51 }
52
53 public function visibleInRegistrationForcedTo(): ?bool
54 {
55 return false;
56 }
57
58 public function visibleToUserForcedTo(): ?bool
59 {
60 return false;
61 }
62
64 {
65 return false;
66 }
67
68 public function visibleInCoursesForcedTo(): ?bool
69 {
70 return false;
71 }
72
73 public function visibleInGroupsForcedTo(): ?bool
74 {
75 return false;
76 }
77
78 public function visibleInStudyProgrammesForcedTo(): ?bool
79 {
80 return false;
81 }
82
83 public function changeableByUserForcedTo(): ?bool
84 {
85 return false;
86 }
87
88 public function requiredForcedTo(): ?bool
89 {
90 return false;
91 }
92
93 public function searchableForcedTo(): ?bool
94 {
95 return false;
96 }
97
98 public function availableInCertificatesForcedTo(): ?bool
99 {
100 return false;
101 }
102
103 public function getLegacyInput(
106 ?\ilObjUser $user = null
108 $input = new \ilTextInputGUI($this->getLabel($lng));
109 $input->setSize(40);
110 $input->setMaxLength(255);
111 $input->setInfo($lng->txt('current_ip') . ' ' . $_SERVER['REMOTE_ADDR'] . ' <br />' .
112 '<span class="warning">' . $lng->txt('current_ip_alert') . '</span>');
113 if ($user === null) {
114 return $input;
115 }
116 $input->setValue(
117 $this->retrieveValueFromUser($user)
118 );
119 return $input;
120 }
121
122 public function addValueToUserObject(
123 \ilObjUser $user,
124 mixed $input,
125 ?\ilPropertyFormGUI $form = null
126 ): \ilObjUser {
127 $user->setClientIP($input);
128 return $user;
129 }
130
131 public function retrieveValueFromUser(\ilObjUser $user): string
132 {
133 return $user->getClientIP();
134 }
135}
addValueToUserObject(\ilObjUser $user, mixed $input, ?\ilPropertyFormGUI $form=null)
Definition: ClientIP.php:122
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: ClientIP.php:103
This class represents a property in a property form.
User class.
This class represents a property form user interface.
This class represents a text property in a property form.
global $lng
Definition: privfeed.php:31
$_SERVER['HTTP_HOST']
Definition: raiseError.php:26
$context
Definition: webdav.php:31