ILIAS
release_5-4 Revision v5.4.26-12-gabc799a52e6
◀ ilDoc Overview
class.ilTermsOfServiceAcceptanceDatabaseGateway.php
Go to the documentation of this file.
1
<?
php
2
/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3
8
class
ilTermsOfServiceAcceptanceDatabaseGateway
implements
\ilTermsOfServiceAcceptanceDataGateway
9
{
11
protected
$db
;
12
17
public
function
__construct
(\
ilDBInterface
$db
)
18
{
19
$this->db =
$db
;
20
}
21
25
public
function
trackAcceptance
(\
ilTermsOfServiceAcceptanceEntity
$entity)
26
{
27
$res
= $this->db->queryF(
28
'SELECT id FROM tos_versions WHERE hash = %s AND doc_id = %s'
,
29
array(
'text'
,
'integer'
),
30
array($entity->
getHash
(), $entity->
getDocumentId
())
31
);
32
33
if
($this->db->numRows(
$res
)) {
34
$row
= $this->db->fetchAssoc(
$res
);
35
$versionId =
$row
[
'id'
];
36
}
else
{
37
$versionId = $this->db->nextId(
'tos_versions'
);
38
$this->db->insert(
39
'tos_versions'
,
40
[
41
'id'
=> [
'integer'
, $versionId],
42
'text'
=> [
'clob'
, $entity->
getText
()],
43
'hash'
=> [
'text'
, $entity->
getHash
()],
44
'doc_id'
=> [
'integer'
, $entity->
getDocumentId
()],
45
'title'
=> [
'text'
, $entity->
getTitle
()],
46
'ts'
=> [
'integer'
, $entity->
getTimestamp
()]
47
]
48
);
49
}
50
51
$this->db->insert(
52
'tos_acceptance_track'
,
53
[
54
'tosv_id'
=> [
'integer'
, $versionId],
55
'usr_id'
=> [
'integer'
, $entity->
getUserId
()],
56
'criteria'
=> [
'clob'
, $entity->
getSerializedCriteria
()],
57
'ts'
=> [
'integer'
, $entity->
getTimestamp
()]
58
]
59
);
60
}
61
65
public
function
loadCurrentAcceptanceOfUser
(\
ilTermsOfServiceAcceptanceEntity
$entity) : \
ilTermsOfServiceAcceptanceEntity
66
{
67
$this->db->setLimit(1, 0);
68
69
$res
= $this->db->queryF(
70
'
71
SELECT tos_versions.*,
72
tos_acceptance_track.ts accepted_ts,
73
tos_acceptance_track.criteria,
74
tos_acceptance_track.usr_id
75
FROM tos_acceptance_track
76
INNER JOIN tos_versions ON id = tosv_id
77
WHERE usr_id = %s
78
ORDER BY tos_acceptance_track.ts DESC
79
'
,
80
[
'integer'
],
81
[$entity->
getUserId
()]
82
);
83
$row
= $this->db->fetchAssoc(
$res
);
84
85
$entity = $entity
86
->
withId
((
int
)
$row
[
'id'
])
87
->withUserId((
int
) $row[
'usr_id'
])
88
->withText((
string
) $row[
'text'
])
89
->withTimestamp((
int
) $row[
'accepted_ts'
])
90
->withHash((
string
) $row[
'hash'
])
91
->withDocumentId((
int
) $row[
'doc_id'
])
92
->withTitle((
string
) $row[
'title'
])
93
->withSerializedCriteria((
string
) $row[
'criteria'
]);
94
95
return
$entity;
96
}
97
101
public
function
loadById
(\
ilTermsOfServiceAcceptanceEntity
$entity) : \
ilTermsOfServiceAcceptanceEntity
102
{
103
$res
= $this->db->queryF(
104
'
105
SELECT *
106
FROM tos_versions
107
WHERE id = %s
108
'
,
109
array(
'integer'
),
110
array($entity->
getId
())
111
);
112
$row
= $this->db->fetchAssoc(
$res
);
113
114
$entity = $entity
115
->
withId
(
$row
[
'id'
])
116
->withText(
$row
[
'text'
])
117
->withHash(
$row
[
'hash'
])
118
->withDocumentId(
$row
[
'doc_id'
])
119
->withTitle(
$row
[
'title'
]);
120
121
return
$entity;
122
}
123
127
public
function
deleteAcceptanceHistoryByUser
(\
ilTermsOfServiceAcceptanceEntity
$entity)
128
{
129
$this->db->manipulate(
130
'DELETE FROM tos_acceptance_track WHERE usr_id = '
. $this->db->quote($entity->
getUserId
(),
'integer'
)
131
);
132
}
133
}
ilTermsOfServiceAcceptanceEntity\getDocumentId
getDocumentId()
Definition:
class.ilTermsOfServiceAcceptanceEntity.php:163
ilTermsOfServiceAcceptanceEntity\getId
getId()
Definition:
class.ilTermsOfServiceAcceptanceEntity.php:121
ilTermsOfServiceAcceptanceEntity\getTimestamp
getTimestamp()
Definition:
class.ilTermsOfServiceAcceptanceEntity.php:79
ilTermsOfServiceAcceptanceEntity\getText
getText()
Definition:
class.ilTermsOfServiceAcceptanceEntity.php:58
ilTermsOfServiceAcceptanceDatabaseGateway\deleteAcceptanceHistoryByUser
deleteAcceptanceHistoryByUser(\ilTermsOfServiceAcceptanceEntity $entity)
Definition:
class.ilTermsOfServiceAcceptanceDatabaseGateway.php:127
ilTermsOfServiceAcceptanceDatabaseGateway
Class ilTermsOfServiceAcceptanceDatabaseGateway.
Definition:
class.ilTermsOfServiceAcceptanceDatabaseGateway.php:8
ilTermsOfServiceAcceptanceDatabaseGateway\loadById
loadById(\ilTermsOfServiceAcceptanceEntity $entity)
mixed
Definition:
class.ilTermsOfServiceAcceptanceDatabaseGateway.php:101
ilTermsOfServiceAcceptanceEntity\getUserId
getUserId()
Definition:
class.ilTermsOfServiceAcceptanceEntity.php:100
$res
foreach($_POST as $key=> $value) $res
Definition:
save_question_post_data.php:15
ilTermsOfServiceAcceptanceEntity\getTitle
getTitle()
Definition:
class.ilTermsOfServiceAcceptanceEntity.php:142
ilDBInterface
ilTermsOfServiceAcceptanceDatabaseGateway\trackAcceptance
trackAcceptance(\ilTermsOfServiceAcceptanceEntity $entity)
Definition:
class.ilTermsOfServiceAcceptanceDatabaseGateway.php:25
$row
$row
Definition:
migrateto20.php:360
ilTermsOfServiceAcceptanceEntity\getSerializedCriteria
getSerializedCriteria()
Definition:
class.ilTermsOfServiceAcceptanceEntity.php:184
ilTermsOfServiceAcceptanceEntity
Class ilTermsOfServiceAcceptanceEntity.
Definition:
class.ilTermsOfServiceAcceptanceEntity.php:8
ilTermsOfServiceAcceptanceDatabaseGateway\$db
$db
Definition:
class.ilTermsOfServiceAcceptanceDatabaseGateway.php:11
ilTermsOfServiceAcceptanceDatabaseGateway\__construct
__construct(\ilDBInterface $db)
ilTermsOfServiceAcceptanceDatabaseGateway constructor.
Definition:
class.ilTermsOfServiceAcceptanceDatabaseGateway.php:17
ilTermsOfServiceAcceptanceEntity\getHash
getHash()
Definition:
class.ilTermsOfServiceAcceptanceEntity.php:37
php
ilTermsOfServiceAcceptanceDatabaseGateway\loadCurrentAcceptanceOfUser
loadCurrentAcceptanceOfUser(\ilTermsOfServiceAcceptanceEntity $entity)
Definition:
class.ilTermsOfServiceAcceptanceDatabaseGateway.php:65
ilTermsOfServiceAcceptanceEntity\withId
withId(int $id)
Definition:
class.ilTermsOfServiceAcceptanceEntity.php:130
ilTermsOfServiceAcceptanceDataGateway
Interface ilTermsOfServiceAcceptanceDataGateway.
Definition:
interface.ilTermsOfServiceAcceptanceDataGateway.php:8
Services
TermsOfService
classes
History
class.ilTermsOfServiceAcceptanceDatabaseGateway.php
Generated on Thu Jan 16 2025 19:02:31 for ILIAS by
1.8.13 (using
Doxyfile
)