ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Interests.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 Interests implements FieldDefinition
30{
31 use NoOverrides;
32 use BuildAutocompletionUrl;
33
34 public function __construct(
35 private readonly \ilCtrl $ctrl
36 ) {
37 }
38
39 public function getIdentifier(): string
40 {
41 return 'interests_general';
42 }
43
44 public function getLabel(Language $lng): string
45 {
46 return $lng->txt('interests_general');
47 }
48
49 public function getSection(): AvailableSections
50 {
51 return AvailableSections::Interests;
52 }
53
54 public function hiddenInLists(): bool
55 {
56 return true;
57 }
58
59 public function visibleInCoursesForcedTo(): ?bool
60 {
61 return false;
62 }
63
64 public function visibleInGroupsForcedTo(): ?bool
65 {
66 return false;
67 }
68
69 public function visibleInStudyProgrammesForcedTo(): ?bool
70 {
71 return false;
72 }
73
74 public function availableInCertificatesForcedTo(): ?bool
75 {
76 return false;
77 }
78
79 public function getLegacyInput(
82 ?\ilObjUser $user = null
84 $input = new \ilTextInputGUI($this->getLabel($lng));
85 $input->setMulti(true);
86 $input->setDataSource(
87 $this->getAutocompleteUrl($this->ctrl) . '&f=' . $this->getIdentifier()
88 );
89 $input->setMaxLength(40);
90 if ($user === null) {
91 return $input;
92 }
93 $input->setValue(
94 $this->retrieveValueFromUser($user)
95 );
96 return $input;
97 }
98
99 public function addValueToUserObject(
100 \ilObjUser $user,
101 mixed $input,
102 ?\ilPropertyFormGUI $form = null
103 ): \ilObjUser {
104 $user->setGeneralInterests($input);
105 return $user;
106 }
107
108 public function retrieveValueFromUser(\ilObjUser $user): array
109 {
110 return $user->getGeneralInterests();
111 }
112}
addValueToUserObject(\ilObjUser $user, mixed $input, ?\ilPropertyFormGUI $form=null)
Definition: Interests.php:99
__construct(private readonly \ilCtrl $ctrl)
Definition: Interests.php:34
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: Interests.php:79
Class ilCtrl provides processing control methods.
This class represents a property in a property form.
setMulti(bool $a_multi, bool $a_sortable=false, bool $a_addremove=true)
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
$context
Definition: webdav.php:31