ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
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,
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(
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
123 ): string {
124 return $this->session_reminder->getGlobalSessionReminderLeadTime() . ' ' . $lng->txt('minutes');
125 }
126
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 (int) ($user->getPref('session_reminder_lead_time')
148 ?? $this->session_reminder->getGlobalSessionReminderLeadTime());
149 }
150}
$settings
Definition: index.php:44
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)
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.
getPref(string $keyword)
static getSessionExpireValue()
Returns the session expiration value.
ILIAS Setting Class.
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'vtt', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
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:26