ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Contact\UserSettings\AllowContactRequest Class Reference
+ Inheritance diagram for ILIAS\Contact\UserSettings\AllowContactRequest:
+ Collaboration diagram for ILIAS\Contact\UserSettings\AllowContactRequest:

Public Member Functions

 getIdentifier ()
 
 isAvailable ()
 If this function returns false the setting will not be shown, even if it's PropertyAttributes would allow it to be. More...
 
 getLabel (Language $lng)
 
 getSettingsPage ()
 
 getSection ()
 
 getInput (FieldFactory $field_factory, Language $lng, Refinery $refinery, \ilSetting $settings, ?\ilObjUser $user=null)
 
 getLegacyInput (Language $lng, \ilSetting $settings, ?\ilObjUser $user=null)
 You don't need to add a post_var to the input as the User will handle this for you, thus you can also not rely on the post_var anywhere else, as it will be changed. More...
 
 getDefaultValueForDisplay (Language $lng, \ilSetting $settings)
 
 hasUserPersonalizedSetting (\ilSetting $settings, \ilObjUser $user)
 
 persistUserInput (\ilObjUser $user, mixed $input)
 
 retrieveValueFromUser (\ilObjUser $user)
 
 isAvailable ()
 If this function returns false the setting will not be shown, even if it's PropertyAttributes would allow it to be. More...
 
 getSettingsPage ()
 
 getDefaultValueForDisplay (Language $lng, \ilSetting $settings)
 
 hasUserPersonalizedSetting (\ilSetting $settings, \ilObjUser $user)
 
 getInput (FieldFactory $field_factory, Language $lng, Refinery $refinery, \ilSetting $settings, ?\ilObjUser $user=null)
 
 getLegacyInput (Language $lng, \ilSetting $settings, ?\ilObjUser $user=null)
 You don't need to add a post_var to the input as the User will handle this for you, thus you can also not rely on the post_var anywhere else, as it will be changed. More...
 
 persistUserInput (\ilObjUser $user, mixed $input)
 
 getIdentifier ()
 
 getLabel (Language $lng)
 
 getSection ()
 
 retrieveValueFromUser (\ilObjUser $user)
 

Detailed Description

Definition at line 31 of file AllowContactRequest.php.

Member Function Documentation

◆ getDefaultValueForDisplay()

ILIAS\Contact\UserSettings\AllowContactRequest::getDefaultValueForDisplay ( Language  $lng,
\ilSetting  $settings 
)

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 91 of file AllowContactRequest.php.

94 : string {
95 return $settings->get('bs_allow_to_contact_me') === 'y'
96 ? $lng->txt('buddy_allow_to_contact_me_yes')
97 : $lng->txt('buddy_allow_to_contact_me_no');
98 }
global $lng
Definition: privfeed.php:31

◆ getIdentifier()

ILIAS\Contact\UserSettings\AllowContactRequest::getIdentifier ( )

Implements ILIAS\User\Property.

Definition at line 33 of file AllowContactRequest.php.

33 : string
34 {
35 return 'allow_contact_request';
36 }

◆ getInput()

ILIAS\Contact\UserSettings\AllowContactRequest::getInput ( FieldFactory  $field_factory,
Language  $lng,
Refinery  $refinery,
\ilSetting  $settings,
?\ilObjUser  $user = null 
)

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 58 of file AllowContactRequest.php.

64 : Input {
65 $lng->loadLanguageModule('buddysystem');
66 return $field_factory->checkbox(
67 $lng->txt('buddy_allow_to_contact_me'),
68 $lng->txt('buddy_allow_to_contact_me_info')
69 )->withValue(
70 $user !== null
71 ? $user->getPref('bs_allow_to_contact_me') === 'y'
72 : $settings->get('bs_allow_to_contact_me') === 'y'
73 );
74 }

◆ getLabel()

ILIAS\Contact\UserSettings\AllowContactRequest::getLabel ( Language  $lng)

Implements ILIAS\User\Property.

Definition at line 43 of file AllowContactRequest.php.

43 : string
44 {
45 return $lng->txt('buddy_allow_to_contact_me');
46 }

References $lng.

◆ getLegacyInput()

ILIAS\Contact\UserSettings\AllowContactRequest::getLegacyInput ( Language  $lng,
\ilSetting  $settings,
?\ilObjUser  $user = null 
)

You don't need to add a post_var to the input as the User will handle this for you, thus you can also not rely on the post_var anywhere else, as it will be changed.

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 76 of file AllowContactRequest.php.

81 $lng->loadLanguageModule('buddysystem');
82 $input = new \ilCheckboxInputGUI($lng->txt('buddy_allow_to_contact_me'));
83 $input->setChecked(
84 $user !== null
85 ? $user->getPref('bs_allow_to_contact_me') === 'y'
86 : $settings->get('bs_allow_to_contact_me') === 'y'
87 );
88 return $input;
89 }
This class represents a property in a property form.

◆ getSection()

ILIAS\Contact\UserSettings\AllowContactRequest::getSection ( )

Implements ILIAS\User\Property.

Definition at line 53 of file AllowContactRequest.php.

54 {
55 return AvailableSections::Main;
56 }

◆ getSettingsPage()

ILIAS\Contact\UserSettings\AllowContactRequest::getSettingsPage ( )

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 48 of file AllowContactRequest.php.

49 {
50 return AvailablePages::PrivacySettings;
51 }

◆ hasUserPersonalizedSetting()

ILIAS\Contact\UserSettings\AllowContactRequest::hasUserPersonalizedSetting ( \ilSetting  $settings,
\ilObjUser  $user 
)

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 100 of file AllowContactRequest.php.

103 : bool {
104 return $this->retrieveValueFromUser($user) !== $settings->get('bs_allow_to_contact_me');
105 }

◆ isAvailable()

ILIAS\Contact\UserSettings\AllowContactRequest::isAvailable ( )

If this function returns false the setting will not be shown, even if it's PropertyAttributes would allow it to be.

This is meant e.g. to check if the chat server is configured or the badges enabled. Settings that are not available will also not be available on the table to define their PropertyAttributes

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 38 of file AllowContactRequest.php.

38 : bool
39 {
40 return \ilBuddySystem::getInstance()->isEnabled();
41 }

◆ persistUserInput()

ILIAS\Contact\UserSettings\AllowContactRequest::persistUserInput ( \ilObjUser  $user,
mixed  $input 
)
Parameters
mixed$inputNull will be handed in, if the user wants to use the system default. If you are able to set the preference on the user without saving it, you can rely on the User-object being saved after the call to this function. If your input has different structures depending on its provenience (KS-Input, Legacy-Input, ...), the function needs to be able to handle them all.

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 107 of file AllowContactRequest.php.

110 : \ilObjUser {
111 if ($input === null) {
112 $user->deletePref('bs_allow_to_contact_me');
113 return $user;
114 }
115 $user->setPref('bs_allow_to_contact_me', $input ? 'y' : 'n');
116 return $user;
117 }
User class.
deletePref(string $keyword)

References ilObjUser\deletePref().

+ Here is the call graph for this function:

◆ retrieveValueFromUser()

ILIAS\Contact\UserSettings\AllowContactRequest::retrieveValueFromUser ( \ilObjUser  $user)

Implements ILIAS\User\Property.

Definition at line 119 of file AllowContactRequest.php.

119 : ?bool
120 {
121 $value = $user->getPref('bs_allow_to_contact_me');
122 return $value !== null ? $value === 'y' : null;
123 }

References ilObjUser\getPref().

+ Here is the call graph for this function:

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