ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilSessionReminder Class Reference
+ Collaboration diagram for ilSessionReminder:

Public Member Functions

 __construct (private ilObjUser $user, private readonly ClockInterface $clock, private readonly ilSetting $settings)
 
 getGlobalSessionReminderLeadTime ()
 
 getEffectiveLeadTime ()
 
 getMaxPossibleLeadTime ()
 
 isActive ()
 
 setUser (ilObjUser $user)
 
 getUser ()
 
 setCurrentTime (int $current_time)
 
 getCurrentTime ()
 
 setExpirationTime (int $expiration_time)
 
 getExpirationTime ()
 
 setLeadTime (int $lead_time)
 
 getLeadTime ()
 
 setSecondsUntilExpiration (int $seconds_until_expiration)
 
 getSecondsUntilExpiration ()
 
 setSecondsUntilReminder (int $seconds_until_reminder)
 
 getSecondsUntilReminder ()
 

Static Public Member Functions

static byLoggedInUser ()
 

Data Fields

const int LEAD_TIME_DISABLED = 0
 
const int MIN_LEAD_TIME = 1
 
const int SUGGESTED_LEAD_TIME = 5
 

Private Member Functions

 buildValidLeadTime (int $lead_time)
 
 init ()
 
 calculateSecondsUntilExpiration ()
 
 calculateSecondsUntilReminder ()
 
 isEnoughTimeLeftForReminder ()
 

Private Attributes

int $lead_time = self::SUGGESTED_LEAD_TIME
 
int $expiration_time = 0
 
int $current_time = 0
 
int $seconds_until_expiration = 0
 
int $seconds_until_reminder = 0
 

Detailed Description

Definition at line 24 of file class.ilSessionReminder.php.

Constructor & Destructor Documentation

◆ __construct()

ilSessionReminder::__construct ( private ilObjUser  $user,
private readonly ClockInterface  $clock,
private readonly ilSetting  $settings 
)

Definition at line 36 of file class.ilSessionReminder.php.

40 {
41 $this->init();
42 }

References init().

+ Here is the call graph for this function:

Member Function Documentation

◆ buildValidLeadTime()

ilSessionReminder::buildValidLeadTime ( int  $lead_time)
private

Definition at line 71 of file class.ilSessionReminder.php.

71 : int
72 {
73 $min_value = self::MIN_LEAD_TIME;
74 $max_value = $this->getMaxPossibleLeadTime();
75
76 if ($lead_time !== self::LEAD_TIME_DISABLED &&
77 ($lead_time < $min_value || $lead_time > $max_value)) {
79 }
80
81 return $lead_time !== self::LEAD_TIME_DISABLED ? min(
82 max(
83 $min_value,
85 ),
86 $max_value
87 ) : self::LEAD_TIME_DISABLED;
88 }

References $lead_time, getMaxPossibleLeadTime(), LEAD_TIME_DISABLED, MIN_LEAD_TIME, and SUGGESTED_LEAD_TIME.

Referenced by getEffectiveLeadTime(), and getGlobalSessionReminderLeadTime().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ byLoggedInUser()

static ilSessionReminder::byLoggedInUser ( )
static

Definition at line 44 of file class.ilSessionReminder.php.

44 : self
45 {
46 global $DIC;
47
48 if (isset($DIC['ilUser'])) {
49 $user = $DIC->user();
50 } else {
51 $user = new ilObjUser();
52 $user->setId(0);
53 }
54
55 $reminder = new self(
56 $user,
57 (new DataFactory())->clock()->utc(),
58 $DIC->settings()
59 );
60
61 return $reminder;
62 }
User class.
global $DIC
Definition: shib_login.php:26

References $DIC.

Referenced by ILIAS\User\Settings\User\SessionReminder\__construct(), and ilGlobalPageTemplate\prepareBasicJS().

+ Here is the caller graph for this function:

◆ calculateSecondsUntilExpiration()

ilSessionReminder::calculateSecondsUntilExpiration ( )
private

Definition at line 120 of file class.ilSessionReminder.php.

120 : void
121 {
123 }
setSecondsUntilExpiration(int $seconds_until_expiration)

References getCurrentTime(), getExpirationTime(), and setSecondsUntilExpiration().

Referenced by init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateSecondsUntilReminder()

ilSessionReminder::calculateSecondsUntilReminder ( )
private

Definition at line 125 of file class.ilSessionReminder.php.

125 : void
126 {
128 }
setSecondsUntilReminder(int $seconds_until_reminder)

References getLeadTime(), getSecondsUntilExpiration(), and setSecondsUntilReminder().

Referenced by init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCurrentTime()

ilSessionReminder::getCurrentTime ( )

Definition at line 163 of file class.ilSessionReminder.php.

163 : int
164 {
165 return $this->current_time;
166 }

References $current_time.

Referenced by calculateSecondsUntilExpiration().

+ Here is the caller graph for this function:

◆ getEffectiveLeadTime()

ilSessionReminder::getEffectiveLeadTime ( )

Definition at line 90 of file class.ilSessionReminder.php.

90 : int
91 {
92 return $this->buildValidLeadTime(
94 $this->getUser()->getId(),
95 'session_reminder_lead_time'
97 );
98 }
static _lookupPref(int $a_usr_id, string $a_keyword)
buildValidLeadTime(int $lead_time)

References ilObjUser\_lookupPref(), buildValidLeadTime(), getGlobalSessionReminderLeadTime(), ILIAS\Survey\Mode\getId(), and getUser().

Referenced by init(), and isActive().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExpirationTime()

ilSessionReminder::getExpirationTime ( )

Definition at line 175 of file class.ilSessionReminder.php.

175 : int
176 {
178 }

References $expiration_time.

Referenced by calculateSecondsUntilExpiration().

+ Here is the caller graph for this function:

◆ getGlobalSessionReminderLeadTime()

ilSessionReminder::getGlobalSessionReminderLeadTime ( )

Definition at line 64 of file class.ilSessionReminder.php.

64 : int
65 {
66 return $this->buildValidLeadTime(
67 (int) $this->settings->get('session_reminder_lead_time')
68 );
69 }

References buildValidLeadTime(), and ILIAS\Repository\settings().

Referenced by getEffectiveLeadTime().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLeadTime()

ilSessionReminder::getLeadTime ( )

Definition at line 187 of file class.ilSessionReminder.php.

187 : int
188 {
189 return $this->lead_time;
190 }

References $lead_time.

Referenced by calculateSecondsUntilReminder(), and isEnoughTimeLeftForReminder().

+ Here is the caller graph for this function:

◆ getMaxPossibleLeadTime()

ilSessionReminder::getMaxPossibleLeadTime ( )

Definition at line 100 of file class.ilSessionReminder.php.

100 : int
101 {
103
104 return max(self::MIN_LEAD_TIME, ($expires / 60) - 1);
105 }
static getSessionExpireValue()
Returns the session expiration value.

References ilSession\getSessionExpireValue().

Referenced by buildValidLeadTime().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSecondsUntilExpiration()

ilSessionReminder::getSecondsUntilExpiration ( )

Definition at line 199 of file class.ilSessionReminder.php.

199 : int
200 {
202 }

References $seconds_until_expiration.

Referenced by calculateSecondsUntilReminder(), and isEnoughTimeLeftForReminder().

+ Here is the caller graph for this function:

◆ getSecondsUntilReminder()

ilSessionReminder::getSecondsUntilReminder ( )

Definition at line 211 of file class.ilSessionReminder.php.

211 : int
212 {
214 }

References $seconds_until_reminder.

◆ getUser()

ilSessionReminder::getUser ( )

Definition at line 151 of file class.ilSessionReminder.php.

151 : ilObjUser
152 {
153 return $this->user;
154 }

Referenced by getEffectiveLeadTime(), and isActive().

+ Here is the caller graph for this function:

◆ init()

ilSessionReminder::init ( )
private

Definition at line 107 of file class.ilSessionReminder.php.

107 : void
108 {
109 $this->setLeadTime(
110 $this->getEffectiveLeadTime() * 60
111 );
112
113 $this->setExpirationTime(ilSession::getIdleValue() + $this->clock->now()->getTimestamp());
114 $this->setCurrentTime($this->clock->now()->getTimestamp());
115
118 }
setCurrentTime(int $current_time)
setExpirationTime(int $expiration_time)
static getIdleValue()
Returns the idle time in seconds.

References calculateSecondsUntilExpiration(), calculateSecondsUntilReminder(), getEffectiveLeadTime(), ilSession\getIdleValue(), setCurrentTime(), setExpirationTime(), and setLeadTime().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isActive()

ilSessionReminder::isActive ( )

Definition at line 135 of file class.ilSessionReminder.php.

135 : bool
136 {
137 return
138 !$this->getUser()->isAnonymous() &&
139 $this->getUser()->getId() > 0 &&
140 $this->getEffectiveLeadTime() !== self::LEAD_TIME_DISABLED &&
142 }

References getEffectiveLeadTime(), getUser(), and isEnoughTimeLeftForReminder().

+ Here is the call graph for this function:

◆ isEnoughTimeLeftForReminder()

ilSessionReminder::isEnoughTimeLeftForReminder ( )
private

Definition at line 130 of file class.ilSessionReminder.php.

130 : bool
131 {
132 return $this->getLeadTime() < $this->getSecondsUntilExpiration();
133 }

References getLeadTime(), and getSecondsUntilExpiration().

Referenced by isActive().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCurrentTime()

ilSessionReminder::setCurrentTime ( int  $current_time)

Definition at line 156 of file class.ilSessionReminder.php.

156 : self
157 {
158 $this->current_time = $current_time;
159
160 return $this;
161 }

References $current_time.

Referenced by init().

+ Here is the caller graph for this function:

◆ setExpirationTime()

ilSessionReminder::setExpirationTime ( int  $expiration_time)

Definition at line 168 of file class.ilSessionReminder.php.

168 : self
169 {
170 $this->expiration_time = $expiration_time;
171
172 return $this;
173 }

References $expiration_time.

Referenced by init().

+ Here is the caller graph for this function:

◆ setLeadTime()

ilSessionReminder::setLeadTime ( int  $lead_time)

Definition at line 180 of file class.ilSessionReminder.php.

180 : self
181 {
182 $this->lead_time = $lead_time;
183
184 return $this;
185 }

References $lead_time.

Referenced by init().

+ Here is the caller graph for this function:

◆ setSecondsUntilExpiration()

ilSessionReminder::setSecondsUntilExpiration ( int  $seconds_until_expiration)

Definition at line 192 of file class.ilSessionReminder.php.

192 : self
193 {
194 $this->seconds_until_expiration = $seconds_until_expiration;
195
196 return $this;
197 }

References $seconds_until_expiration.

Referenced by calculateSecondsUntilExpiration().

+ Here is the caller graph for this function:

◆ setSecondsUntilReminder()

ilSessionReminder::setSecondsUntilReminder ( int  $seconds_until_reminder)

Definition at line 204 of file class.ilSessionReminder.php.

204 : self
205 {
206 $this->seconds_until_reminder = $seconds_until_reminder;
207
208 return $this;
209 }

References $seconds_until_reminder.

Referenced by calculateSecondsUntilReminder().

+ Here is the caller graph for this function:

◆ setUser()

ilSessionReminder::setUser ( ilObjUser  $user)

Definition at line 144 of file class.ilSessionReminder.php.

144 : self
145 {
146 $this->user = $user;
147
148 return $this;
149 }

References ILIAS\Repository\user().

+ Here is the call graph for this function:

Field Documentation

◆ $current_time

int ilSessionReminder::$current_time = 0
private

Definition at line 32 of file class.ilSessionReminder.php.

Referenced by getCurrentTime(), and setCurrentTime().

◆ $expiration_time

int ilSessionReminder::$expiration_time = 0
private

Definition at line 31 of file class.ilSessionReminder.php.

Referenced by getExpirationTime(), and setExpirationTime().

◆ $lead_time

int ilSessionReminder::$lead_time = self::SUGGESTED_LEAD_TIME
private

Definition at line 30 of file class.ilSessionReminder.php.

Referenced by buildValidLeadTime(), getLeadTime(), and setLeadTime().

◆ $seconds_until_expiration

int ilSessionReminder::$seconds_until_expiration = 0
private

◆ $seconds_until_reminder

int ilSessionReminder::$seconds_until_reminder = 0
private

Definition at line 34 of file class.ilSessionReminder.php.

Referenced by getSecondsUntilReminder(), and setSecondsUntilReminder().

◆ LEAD_TIME_DISABLED

const int ilSessionReminder::LEAD_TIME_DISABLED = 0

◆ MIN_LEAD_TIME

const int ilSessionReminder::MIN_LEAD_TIME = 1

Definition at line 27 of file class.ilSessionReminder.php.

Referenced by buildValidLeadTime().

◆ SUGGESTED_LEAD_TIME

const int ilSessionReminder::SUGGESTED_LEAD_TIME = 5

Definition at line 28 of file class.ilSessionReminder.php.

Referenced by buildValidLeadTime().


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