ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
SessionReminder.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
29use ILIAS\Refinery\Factory as Refinery;
30
32{
33 private readonly \ilSessionReminder $session_reminder;
34
35 public function __construct()
36 {
37 $this->session_reminder = \ilSessionReminder::byLoggedInUser();
38 }
39
40 public function getIdentifier(): string
41 {
42 return 'session_reminder';
43 }
44
45 public function isAvailable(): bool
46 {
47 return true;
48 }
49
50 public function getLabel(Language $lng): string
51 {
52 return $lng->txt($this->getIdentifier());
53 }
54
56 {
57 return AvailablePages::MainSettings;
58 }
59
60 public function getSection(): AvailableSections
61 {
63 }
64
65 public function getInput(
66 FieldFactory $field_factory,
69 \ilSetting $settings,
70 ?\ilObjUser $user = null
71 ): Input {
72 return $field_factory->numeric(
73 $lng->txt('session_reminder_input'),
74 sprintf(
75 $lng->txt('session_reminder_lead_time_info'),
76 \ilSessionReminder::LEAD_TIME_DISABLED,
77 \ilSessionReminder::SUGGESTED_LEAD_TIME,
78 \ilDatePresentation::secondsToString(\ilSession::getSessionExpireValue(), true)
79 )
81 $refinery->int()->isGreaterThanOrEqual(
82 \ilSessionReminder::LEAD_TIME_DISABLED
83 )
85 $refinery->int()->isLessThanOrEqual(
86 $this->session_reminder->getMaxPossibleLeadTime()
87 )
88 )->withValue(
89 $user !== null
90 ? $this->retrieveValueFromUser($user)
91 : $this->session_reminder->getGlobalSessionReminderLeadTime()
92 );
93 }
94
95 public function getLegacyInput(
97 \ilSetting $settings,
98 ?\ilObjUser $user = null
100 $input = new \ilNumberInputGUI($lng->txt('session_reminder_input'));
101 $input->setInfo(
102 sprintf(
103 $lng->txt('session_reminder_lead_time_info'),
107 )
108 );
109 $input->setSize(3);
110 $input->setMinValue(\ilSessionReminder::LEAD_TIME_DISABLED);
111 $input->setMaxValue($this->session_reminder->getMaxPossibleLeadTime());
112 $input->setValue(
113 $user !== null
114 ? (string) $this->retrieveValueFromUser($user)
115 : (string) $this->session_reminder->getGlobalSessionReminderLeadTime()
116 );
117 return $input;
118 }
119
122 \ilSetting $settings
123 ): string {
124 return $this->session_reminder->getGlobalSessionReminderLeadTime() . ' ' . $lng->txt('minutes');
125 }
126
128 \ilSetting $settings,
129 \ilObjUser $user
130 ): bool {
131 return $this->retrieveValueFromUser($user) !== $this->session_reminder->getGlobalSessionReminderLeadTime();
132 }
133
134 public function persistUserInput(
135 \ilObjUser $user,
136 mixed $input
137 ): \ilObjUser {
138 $user->setPref(
139 'session_reminder_lead_time',
140 $input !== null ? (string) $input : (string) $this->session_reminder->getGlobalSessionReminderLeadTime()
141 );
142 return $user;
143 }
144
145 public function retrieveValueFromUser(\ilObjUser $user): int
146 {
147 return $this->session_reminder->getEffectiveLeadTime();
148 }
149}
Builds data types.
Definition: Factory.php:36
persistUserInput(\ilObjUser $user, mixed $input)
getInput(FieldFactory $field_factory, Language $lng, Refinery $refinery, \ilSetting $settings, ?\ilObjUser $user=null)
isAvailable()
If this function returns false the setting will not be shown, even if it's PropertyAttributes would a...
hasUserPersonalizedSetting(\ilSetting $settings, \ilObjUser $user)
readonly ilSessionReminder $session_reminder
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,...
getDefaultValueForDisplay(Language $lng, \ilSetting $settings)
return true
Class for date presentation.
static secondsToString(int $seconds, bool $force_with_seconds=false, ?ilLanguage $a_lng=null)
converts seconds to string: Long: 7 days 4 hour(s) ...
This class represents a property in a property form.
This class represents a number property in a property form.
User class.
static getSessionExpireValue()
Returns the session expiration value.
ILIAS Setting Class.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This is what a factory for input fields looks like.
Definition: Factory.php:31
This describes commonalities between all inputs.
Definition: Input.php:47
withAdditionalTransformation(Transformation $trafo)
@inheritDoc
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:61
global $lng
Definition: privfeed.php:31