ILIAS
release_5-4 Revision v5.4.26-12-gabc799a52e6
◀ ilDoc Overview
class.ilCalendarAuthenticationToken.php
Go to the documentation of this file.
1
<?
php
2
/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4
12
class
ilCalendarAuthenticationToken
13
{
14
const
SELECTION_NONE
= 0;
15
const
SELECTION_PD
= 1;
16
const
SELECTION_CATEGORY
= 2;
17
const
SELECTION_CALENDAR
= 3;
18
19
private
$user
= null;
20
21
private
$token
=
''
;
22
private
$selection_type
= 0;
23
private
$calendar
= 0;
24
25
private
$ical
= null;
26
private
$ical_ctime
= null;
27
34
public
function
__construct
($a_user_id, $a_token =
''
)
35
{
36
$this->
user
= $a_user_id;
37
$this->token = $a_token;
38
39
$this->
read
();
40
}
41
42
public
static
function
lookupAuthToken
($a_user_id, $a_selection, $a_calendar = 0)
43
{
44
global
$DIC
;
45
46
$ilDB
= $DIC[
'ilDB'
];
47
48
$query
=
"SELECT * FROM cal_auth_token "
.
49
"WHERE user_id = "
.
$ilDB
->quote($a_user_id,
'integer'
) .
' '
.
50
"AND selection = "
.
$ilDB
->quote($a_selection,
'integer'
) .
' '
.
51
"AND calendar = "
.
$ilDB
->quote($a_calendar,
'integer'
);
52
$res
=
$ilDB
->query(
$query
);
53
while
(
$row
=
$res
->fetchRow(
ilDBConstants::FETCHMODE_OBJECT
)) {
54
return
$row
->hash;
55
}
56
return
false
;
57
}
58
64
public
static
function
lookupUser
($a_token)
65
{
66
global
$DIC
;
67
68
$ilDB
= $DIC[
'ilDB'
];
69
70
$query
=
"SELECT * FROM cal_auth_token "
.
71
"WHERE hash = "
.
$ilDB
->quote($a_token,
'text'
);
72
$res
=
$ilDB
->query(
$query
);
73
while
(
$row
=
$res
->fetchRow(
ilDBConstants::FETCHMODE_OBJECT
)) {
74
return
$row
->user_id;
75
}
76
return
0;
77
}
78
83
public
function
getSelectionType
()
84
{
85
return
$this->selection_type
;
86
}
87
88
93
public
function
getUserId
()
94
{
95
return
$this->user
;
96
}
97
103
public
function
setSelectionType
(
$a_type
)
104
{
105
$this->selection_type =
$a_type
;
106
}
107
113
public
function
setCalendar
($a_cal)
114
{
115
$this->calendar = $a_cal;
116
}
117
118
public
function
getCalendar
()
119
{
120
return
$this->calendar
;
121
}
122
123
public
function
setIcal
(
$ical
)
124
{
125
$this->ical =
$ical
;
126
}
127
132
public
function
getIcal
()
133
{
134
return
$this->ical
;
135
}
136
137
142
public
function
getToken
()
143
{
144
return
$this->token
;
145
}
146
151
public
function
storeIcal
()
152
{
153
global
$DIC
;
154
155
$ilDB
= $DIC[
'ilDB'
];
156
157
$ilDB
->update(
158
'cal_auth_token'
,
159
array(
160
'ical'
=> array(
'clob'
,$this->
getIcal
()),
161
'c_time'
=> array(
'integer'
,time())
162
),
163
array(
164
'user_id'
=> array(
'integer'
,$this->
getUserId
()),
165
'hash'
=> array(
'text'
,$this->
getToken
())
166
)
167
);
168
}
169
174
public
function
isIcalExpired
()
175
{
176
return
true
;
177
178
include_once
'./Services/Calendar/classes/class.ilCalendarSettings.php'
;
179
180
if
(!
ilCalendarSettings::_getInstance
()->isSynchronisationCacheEnabled()) {
181
return
true
;
182
}
183
if
(!
ilCalendarSettings::_getInstance
()->getSynchronisationCacheMinutes()) {
184
return
true
;
185
}
186
return
time() > ($this->ical_ctime + 60 *
ilCalendarSettings::_getInstance
()->getSynchronisationCacheMinutes());
187
}
188
193
public
function
add
()
194
{
195
global
$DIC
;
196
197
$ilDB
= $DIC[
'ilDB'
];
198
199
$this->
createToken
();
200
201
$query
=
"INSERT INTO cal_auth_token (user_id,hash,selection,calendar) "
.
202
"VALUES ( "
.
203
$ilDB
->quote($this->
getUserId
(),
'integer'
) .
', '
.
204
$ilDB
->quote($this->
getToken
(),
'text'
) .
', '
.
205
$ilDB
->quote($this->
getSelectionType
(),
'integer'
) .
', '
.
206
$ilDB
->quote($this->
getCalendar
(),
'integer'
) .
' '
.
207
')'
;
208
$ilDB
->manipulate(
$query
);
209
210
return
$this->
getToken
();
211
}
212
217
protected
function
createToken
()
218
{
219
$random = new \ilRandom();
220
$this->token = md5($this->
getUserId
() . $this->
getSelectionType
() . $random->int());
221
}
222
227
protected
function
read
()
228
{
229
global
$DIC
;
230
231
$ilDB
= $DIC[
'ilDB'
];
232
233
if
(!$this->
getToken
()) {
234
$query
=
"SELECT * FROM cal_auth_token "
.
235
"WHERE user_id = "
.
$ilDB
->quote($this->
getUserId
(),
'integer'
);
236
}
else
{
237
$query
=
'SELECT * FROM cal_auth_token '
.
238
'WHERE user_id = '
.
$ilDB
->quote($this->
getUserId
(),
'integer'
) .
' '
.
239
'AND hash = '
.
$ilDB
->quote($this->
getToken
(),
'text'
);
240
}
241
242
$res
=
$ilDB
->query(
$query
);
243
while
(
$row
=
$res
->fetchRow(
ilDBConstants::FETCHMODE_OBJECT
)) {
244
$this->token =
$row
->hash;
245
$this->selection_type =
$row
->selection;
246
$this->calendar =
$row
->calendar;
247
$this->ical =
$row
->ical;
248
$this->ical_ctime =
$row
->c_time;
249
}
250
return
true
;
251
}
252
}
ilCalendarAuthenticationToken\createToken
createToken()
Create a new token.
Definition:
class.ilCalendarAuthenticationToken.php:217
ilCalendarAuthenticationToken\setCalendar
setCalendar($a_cal)
set calendar id
Definition:
class.ilCalendarAuthenticationToken.php:113
ilCalendarSettings\_getInstance
static _getInstance()
get singleton instance
Definition:
class.ilCalendarSettings.php:116
ilCalendarAuthenticationToken\setIcal
setIcal($ical)
Definition:
class.ilCalendarAuthenticationToken.php:123
ilCalendarAuthenticationToken\$selection_type
$selection_type
Definition:
class.ilCalendarAuthenticationToken.php:22
ilCalendarAuthenticationToken\isIcalExpired
isIcalExpired()
Check if cache is disabled or expired.
Definition:
class.ilCalendarAuthenticationToken.php:174
$DIC
global $DIC
Definition:
saml.php:7
ilCalendarAuthenticationToken\$ical
$ical
Definition:
class.ilCalendarAuthenticationToken.php:25
ilCalendarAuthenticationToken\SELECTION_CATEGORY
const SELECTION_CATEGORY
Definition:
class.ilCalendarAuthenticationToken.php:16
ilCalendarAuthenticationToken\$user
$user
Definition:
class.ilCalendarAuthenticationToken.php:19
ilCalendarAuthenticationToken\$token
$token
Definition:
class.ilCalendarAuthenticationToken.php:21
ilCalendarAuthenticationToken\add
add()
Add token.
Definition:
class.ilCalendarAuthenticationToken.php:193
user
user()
Definition:
user.php:4
ilCalendarAuthenticationToken\SELECTION_CALENDAR
const SELECTION_CALENDAR
Definition:
class.ilCalendarAuthenticationToken.php:17
$a_type
$a_type
Definition:
workflow.php:92
ilCalendarAuthenticationToken\$ical_ctime
$ical_ctime
Definition:
class.ilCalendarAuthenticationToken.php:26
ilCalendarAuthenticationToken\getToken
getToken()
get token
Definition:
class.ilCalendarAuthenticationToken.php:142
$res
foreach($_POST as $key=> $value) $res
Definition:
save_question_post_data.php:15
$query
$query
Definition:
proxy_ylocal.php:13
ilCalendarAuthenticationToken\getIcal
getIcal()
get stored ical
Definition:
class.ilCalendarAuthenticationToken.php:132
ilCalendarAuthenticationToken\getSelectionType
getSelectionType()
get selection type for key
Definition:
class.ilCalendarAuthenticationToken.php:83
$row
$row
Definition:
migrateto20.php:360
ilCalendarAuthenticationToken\read
read()
Read key.
Definition:
class.ilCalendarAuthenticationToken.php:227
ilCalendarAuthenticationToken\getCalendar
getCalendar()
Definition:
class.ilCalendarAuthenticationToken.php:118
ilCalendarAuthenticationToken\$calendar
$calendar
Definition:
class.ilCalendarAuthenticationToken.php:23
ilCalendarAuthenticationToken\lookupUser
static lookupUser($a_token)
Lookup user by hash.
Definition:
class.ilCalendarAuthenticationToken.php:64
ilCalendarAuthenticationToken\SELECTION_NONE
const SELECTION_NONE
Definition:
class.ilCalendarAuthenticationToken.php:14
ilCalendarAuthenticationToken\getUserId
getUserId()
Get current user.
Definition:
class.ilCalendarAuthenticationToken.php:93
ilCalendarAuthenticationToken\lookupAuthToken
static lookupAuthToken($a_user_id, $a_selection, $a_calendar=0)
Definition:
class.ilCalendarAuthenticationToken.php:42
$ilDB
global $ilDB
Definition:
storeScorm2004.php:16
ilCalendarAuthenticationToken
Handles calendar authentication tokens for external calendar subscriptions.
Definition:
class.ilCalendarAuthenticationToken.php:12
php
ilDBConstants\FETCHMODE_OBJECT
const FETCHMODE_OBJECT
Definition:
class.ilDBConstants.php:13
ilCalendarAuthenticationToken\storeIcal
storeIcal()
store ical
Definition:
class.ilCalendarAuthenticationToken.php:151
ilCalendarAuthenticationToken\setSelectionType
setSelectionType($a_type)
set selection type
Definition:
class.ilCalendarAuthenticationToken.php:103
ilCalendarAuthenticationToken\__construct
__construct($a_user_id, $a_token='')
Constructor.
Definition:
class.ilCalendarAuthenticationToken.php:34
ilCalendarAuthenticationToken\SELECTION_PD
const SELECTION_PD
Definition:
class.ilCalendarAuthenticationToken.php:15
Services
Calendar
classes
class.ilCalendarAuthenticationToken.php
Generated on Thu Jan 16 2025 19:02:17 for ILIAS by
1.8.13 (using
Doxyfile
)