ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\User\Settings\User\LastVisited Class Reference
+ Inheritance diagram for ILIAS\User\Settings\User\LastVisited:
+ Collaboration diagram for ILIAS\User\Settings\User\LastVisited:

Public Member Functions

 __construct ()
 
 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 Attributes

readonly ilNavigationHistory $navigation_history
 

Detailed Description

Definition at line 31 of file LastVisited.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\User\Settings\User\LastVisited::__construct ( )

Definition at line 35 of file LastVisited.php.

36 {
37 global $DIC;
38 $this->navigation_history = $DIC['ilNavigationHistory'] ?? null;
39 }
global $DIC
Definition: shib_login.php:26

References $DIC.

Member Function Documentation

◆ getDefaultValueForDisplay()

ILIAS\User\Settings\User\LastVisited::getDefaultValueForDisplay ( Language  $lng,
\ilSetting  $settings 
)

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 108 of file LastVisited.php.

111 : string {
112 return $lng->txt('user_lv_keep_entries');
113 }
global $lng
Definition: privfeed.php:31

◆ getIdentifier()

ILIAS\User\Settings\User\LastVisited::getIdentifier ( )

Implements ILIAS\User\Property.

Definition at line 41 of file LastVisited.php.

41 : string
42 {
43 return 'last_visited';
44 }

Referenced by ILIAS\User\Settings\User\LastVisited\getLabel().

+ Here is the caller graph for this function:

◆ getInput()

ILIAS\User\Settings\User\LastVisited::getInput ( FieldFactory  $field_factory,
Language  $lng,
Refinery  $refinery,
\ilSetting  $settings,
?\ilObjUser  $user = null 
)

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 66 of file LastVisited.php.

72 : Input {
73 return $field_factory->select(
74 $lng->txt('user_store_last_visited'),
75 [
76 0 => $lng->txt('user_lv_keep_entries'),
77 1 => $lng->txt('user_lv_keep_only_for_session'),
78 2 => $lng->txt('user_lv_do_not_store')
79 ]
80 )->withRequired(true)
81 ->withValue(
82 $user !== null
83 ? $this->retrieveValueFromUser($user)
84 : 0
85 );
86 }

◆ getLabel()

ILIAS\User\Settings\User\LastVisited::getLabel ( Language  $lng)

Implements ILIAS\User\Property.

Definition at line 51 of file LastVisited.php.

51 : string
52 {
53 return $lng->txt($this->getIdentifier());
54 }

References $lng, and ILIAS\User\Settings\User\LastVisited\getIdentifier().

+ Here is the call graph for this function:

◆ getLegacyInput()

ILIAS\User\Settings\User\LastVisited::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 88 of file LastVisited.php.

93 $input = new \ilSelectInputGUI($lng->txt('user_store_last_visited'));
94 $options = [
95 0 => $lng->txt('user_lv_keep_entries'),
96 1 => $lng->txt('user_lv_keep_only_for_session'),
97 2 => $lng->txt('user_lv_do_not_store')
98 ];
99 $input->setOptions($options);
100 $input->setValue(
101 $user !== null
102 ? $this->retrieveValueFromUser($user)
103 : 0
104 );
105 return $input;
106 }
This class represents a property in a property form.

◆ getSection()

ILIAS\User\Settings\User\LastVisited::getSection ( )

◆ getSettingsPage()

ILIAS\User\Settings\User\LastVisited::getSettingsPage ( )

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 56 of file LastVisited.php.

57 {
58 return AvailablePages::MainSettings;
59 }

◆ hasUserPersonalizedSetting()

ILIAS\User\Settings\User\LastVisited::hasUserPersonalizedSetting ( \ilSetting  $settings,
\ilObjUser  $user 
)

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 115 of file LastVisited.php.

118 : bool {
119 return $this->retrieveValueFromUser($user) !== 0;
120 }

◆ isAvailable()

ILIAS\User\Settings\User\LastVisited::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 46 of file LastVisited.php.

46 : bool
47 {
48 return true;
49 }

◆ persistUserInput()

ILIAS\User\Settings\User\LastVisited::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 122 of file LastVisited.php.

125 : \ilObjUser {
126 $user->setPref('store_last_visited', $input ?? '0');
127 if ((int) $input > 0) {
128 $this->navigation_history->deleteDBEntries();
129 if ($input === '2') {
130 $this->navigation_history->deleteSessionEntries();
131 }
132 }
133 return $user;
134 }
User class.
setPref(string $a_keyword, ?string $a_value)

◆ retrieveValueFromUser()

ILIAS\User\Settings\User\LastVisited::retrieveValueFromUser ( \ilObjUser  $user)

Implements ILIAS\User\Property.

Definition at line 136 of file LastVisited.php.

136 : int
137 {
138 return (int) ($user->getPref('store_last_visited') ?? 0);
139 }

References ilObjUser\getPref().

+ Here is the call graph for this function:

Field Documentation

◆ $navigation_history

readonly ilNavigationHistory ILIAS\User\Settings\User\LastVisited::$navigation_history
private

Definition at line 33 of file LastVisited.php.


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