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

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)
 

Private Member Functions

 buildOptions ()
 

Detailed Description

Definition at line 31 of file TimeFormat.php.

Member Function Documentation

◆ buildOptions()

ILIAS\Calendar\UserSettings\TimeFormat::buildOptions ( )
private

Definition at line 126 of file TimeFormat.php.

126 : array
127 {
128 return [
131 ];
132 }

References ilCalendarSettings\TIME_FORMAT_12, and ilCalendarSettings\TIME_FORMAT_24.

◆ getDefaultValueForDisplay()

ILIAS\Calendar\UserSettings\TimeFormat::getDefaultValueForDisplay ( Language  $lng,
\ilSetting  $settings 
)

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 95 of file TimeFormat.php.

98 : string {
99 return $this->buildOptions()[\ilCalendarSettings::_getInstance()->getDefaultTimeFormat()];
100 }

◆ getIdentifier()

ILIAS\Calendar\UserSettings\TimeFormat::getIdentifier ( )

Implements ILIAS\User\Property.

Definition at line 33 of file TimeFormat.php.

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

◆ getInput()

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

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 58 of file TimeFormat.php.

64 : Input {
65 $lng->loadLanguageModule('dateplaner');
66 return $field_factory->select(
67 $lng->txt('cal_user_time_format'),
68 $this->buildOptions(),
69 $lng->txt('cal_time_format_info')
70 )->withRequired(true)
71 ->withValue(
72 $user !== null
73 ? $this->retrieveValueFromUser($user)
74 : \ilCalendarSettings::_getInstance()->getDefaultTimeZone()
75 );
76 }
global $lng
Definition: privfeed.php:31

◆ getLabel()

ILIAS\Calendar\UserSettings\TimeFormat::getLabel ( Language  $lng)

Implements ILIAS\User\Property.

Definition at line 43 of file TimeFormat.php.

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

References $lng.

◆ getLegacyInput()

ILIAS\Calendar\UserSettings\TimeFormat::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 78 of file TimeFormat.php.

83 $lng->loadLanguageModule('dateplaner');
84 $input = new \ilSelectInputGUI($lng->txt('cal_user_time_format'));
85 $input->setOptions($this->buildOptions());
86 $input->setInfo($lng->txt('cal_time_format_info'));
87 $input->setValue(
88 $user !== null
89 ? $this->retrieveValueFromUser($user)
90 : \ilCalendarSettings::_getInstance()->getDefaultTimeFormat()
91 );
92 return $input;
93 }
This class represents a property in a property form.

◆ getSection()

ILIAS\Calendar\UserSettings\TimeFormat::getSection ( )

Implements ILIAS\User\Property.

Definition at line 53 of file TimeFormat.php.

54 {
55 return AvailableSections::DateTime;
56 }

◆ getSettingsPage()

ILIAS\Calendar\UserSettings\TimeFormat::getSettingsPage ( )

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 48 of file TimeFormat.php.

49 {
50 return AvailablePages::MainSettings;
51 }

◆ hasUserPersonalizedSetting()

ILIAS\Calendar\UserSettings\TimeFormat::hasUserPersonalizedSetting ( \ilSetting  $settings,
\ilObjUser  $user 
)

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 102 of file TimeFormat.php.

105 : bool {
106 return $this->retrieveValueFromUser($user) !== \ilCalendarSettings::_getInstance()->getDefaultTimeFormat();
107 }

◆ isAvailable()

ILIAS\Calendar\UserSettings\TimeFormat::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 TimeFormat.php.

38 : bool
39 {
40 return true;
41 }

◆ persistUserInput()

ILIAS\Calendar\UserSettings\TimeFormat::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 109 of file TimeFormat.php.

112 : \ilObjUser {
113 $calendar_settings = \ilCalendarUserSettings::_getInstance($user->getId());
114 $calendar_settings->setTimeFormat(
115 $input !== null ? (int) $input : \ilCalendarSettings::_getInstance()->getDefaultTimeFormat()
116 );
117 $calendar_settings->save();
118 return $user;
119 }
User class.

◆ retrieveValueFromUser()

ILIAS\Calendar\UserSettings\TimeFormat::retrieveValueFromUser ( \ilObjUser  $user)

Implements ILIAS\User\Property.

Definition at line 121 of file TimeFormat.php.

121 : int
122 {
123 return (int) $user->getTimeFormat();
124 }

References ilObjUser\getTimeFormat().

+ Here is the call graph for this function:

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