ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilSessionReminder.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3
10{
14 const MIN_LEAD_TIME = 2;
15
20
21
25 protected $user;
26
30 protected $lead_time = 0;
31
35 protected $expiration_time = 0;
36
40 protected $current_time = 0;
41
46
51
55 protected function __construct()
56 {
57 }
58
63 public static function createInstanceWithCurrentUserSession()
64 {
68 global $ilUser;
69
70 $reminder = new self();
71 $reminder->setUser($ilUser);
72 $reminder->initWithUserContext();
73
74 return $reminder;
75 }
76
80 protected function initWithUserContext()
81 {
85 global $ilAuth;
86
87 $this->setLeadTime(max(self::MIN_LEAD_TIME, (float)$this->getUser()->getPref('session_reminder_lead_time')) * 60);
88 $this->setExpirationTime($ilAuth->sessionValidThru());
89 $this->setCurrentTime(time());
90
93 }
94
99 {
101 }
102
107 {
109 }
110
114 protected function isEnoughtTimeLeftForReminder()
115 {
116 return $this->getLeadTime() < $this->getSecondsUntilExpiration();
117 }
118
122 public function isActive()
123 {
124 return
125 self::isGloballyActivated() &&
126 $this->getUser()->getId() != ANONYMOUS_USER_ID &&
127 (int)$this->getUser()->getPref('session_reminder_enabled') &&
129 }
130
135 public static function isGloballyActivated()
136 {
140 global $ilSetting;
141
142 return
144 (int)$ilSetting->get('session_reminder_enabled', 0);
145 }
146
151 public function setUser($user)
152 {
153 $this->user = $user;
154 return $this;
155 }
156
160 public function getUser()
161 {
162 return $this->user;
163 }
164
170 {
171 $this->current_time = $current_time;
172 return $this;
173 }
174
178 public function getCurrentTime()
179 {
180 return $this->current_time;
181 }
182
188 {
189 $this->expiration_time = $expiration_time;
190 return $this;
191 }
192
196 public function getExpirationTime()
197 {
199 }
200
205 public function setLeadTime($lead_time)
206 {
207 $this->lead_time = $lead_time;
208 return $this;
209 }
210
214 public function getLeadTime()
215 {
216 return $this->lead_time;
217 }
218
224 {
225 $this->seconds_until_expiration = $seconds_until_expiration;
226 return $this;
227 }
228
233 {
235 }
236
242 {
243 $this->seconds_until_reminder = $seconds_until_reminder;
244 return $this;
245 }
246
250 public function getSecondsUntilReminder()
251 {
253 }
254}
setSecondsUntilReminder($seconds_until_reminder)
setExpirationTime($expiration_time)
setSecondsUntilExpiration($seconds_until_expiration)
const SESSION_HANDLING_FIXED
global $ilSetting
Definition: privfeed.php:40
global $ilUser
Definition: imgupload.php:15