ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 
50  protected $seconds_until_reminder = 0;
51 
55  protected function __construct()
56  {
57  }
58 
63  public static function createInstanceWithCurrentUserSession()
64  {
68  global $DIC;
69 
70  $ilUser = $DIC['ilUser'];
71 
72  $reminder = new self();
73  $reminder->setUser($ilUser);
74  $reminder->initWithUserContext();
75 
76  return $reminder;
77  }
78 
82  protected function initWithUserContext()
83  {
84  $this->setLeadTime(max(self::MIN_LEAD_TIME, (float) $this->getUser()->getPref('session_reminder_lead_time')) * 60);
85 
89  include_once './Services/Authentication/classes/class.ilSession.php';
90  $this->setExpirationTime(ilSession::getIdleValue(true) + time());
91  $this->setCurrentTime(time());
92 
95  }
96 
101  {
102  $this->setSecondsUntilExpiration($this->getExpirationTime() - $this->getCurrentTime());
103  }
104 
109  {
111  }
112 
116  protected function isEnoughtTimeLeftForReminder()
117  {
118  return $this->getLeadTime() < $this->getSecondsUntilExpiration();
119  }
120 
124  public function isActive()
125  {
126  return
127  self::isGloballyActivated() &&
128  $this->getUser()->getId() != ANONYMOUS_USER_ID &&
129  (int) $this->getUser()->getPref('session_reminder_enabled') &&
131  }
132 
137  public static function isGloballyActivated()
138  {
142  global $DIC;
143 
144  $ilSetting = $DIC['ilSetting'];
145 
146  return
148  (int) $ilSetting->get('session_reminder_enabled', 0);
149  }
150 
155  public function setUser($user)
156  {
157  $this->user = $user;
158  return $this;
159  }
160 
164  public function getUser()
165  {
166  return $this->user;
167  }
168 
173  public function setCurrentTime($current_time)
174  {
175  $this->current_time = $current_time;
176  return $this;
177  }
178 
182  public function getCurrentTime()
183  {
184  return $this->current_time;
185  }
186 
192  {
193  $this->expiration_time = $expiration_time;
194  return $this;
195  }
196 
200  public function getExpirationTime()
201  {
202  return $this->expiration_time;
203  }
204 
209  public function setLeadTime($lead_time)
210  {
211  $this->lead_time = $lead_time;
212  return $this;
213  }
214 
218  public function getLeadTime()
219  {
220  return $this->lead_time;
221  }
222 
228  {
229  $this->seconds_until_expiration = $seconds_until_expiration;
230  return $this;
231  }
232 
236  public function getSecondsUntilExpiration()
237  {
239  }
240 
246  {
247  $this->seconds_until_reminder = $seconds_until_reminder;
248  return $this;
249  }
250 
254  public function getSecondsUntilReminder()
255  {
257  }
258 }
global $DIC
Definition: saml.php:7
setExpirationTime($expiration_time)
setSecondsUntilReminder($seconds_until_reminder)
const SESSION_HANDLING_FIXED
user()
Definition: user.php:4
$ilUser
Definition: imgupload.php:18
static getIdleValue($fixedMode=false)
Returns the idle time in seconds.
setSecondsUntilExpiration($seconds_until_expiration)
global $ilSetting
Definition: privfeed.php:17