ILIAS  release_8 Revision v8.24
ilTermsOfServiceAcceptanceDatabaseGateway Class Reference

Class ilTermsOfServiceAcceptanceDatabaseGateway. More...

+ Inheritance diagram for ilTermsOfServiceAcceptanceDatabaseGateway:
+ Collaboration diagram for ilTermsOfServiceAcceptanceDatabaseGateway:

Public Member Functions

 __construct (ilDBInterface $db)
 
 trackAcceptance (ilTermsOfServiceAcceptanceEntity $entity)
 
 loadCurrentAcceptanceOfUser (ilTermsOfServiceAcceptanceEntity $entity)
 
 loadById (ilTermsOfServiceAcceptanceEntity $entity)
 
 deleteAcceptanceHistoryByUser (ilTermsOfServiceAcceptanceEntity $entity)
 
 trackAcceptance (ilTermsOfServiceAcceptanceEntity $entity)
 
 loadCurrentAcceptanceOfUser (ilTermsOfServiceAcceptanceEntity $entity)
 
 loadById (ilTermsOfServiceAcceptanceEntity $entity)
 
 deleteAcceptanceHistoryByUser (ilTermsOfServiceAcceptanceEntity $entity)
 

Protected Attributes

ilDBInterface $db
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilTermsOfServiceAcceptanceDatabaseGateway::__construct ( ilDBInterface  $db)

Member Function Documentation

◆ deleteAcceptanceHistoryByUser()

ilTermsOfServiceAcceptanceDatabaseGateway::deleteAcceptanceHistoryByUser ( ilTermsOfServiceAcceptanceEntity  $entity)

Implements ilTermsOfServiceAcceptanceDataGateway.

Definition at line 132 of file class.ilTermsOfServiceAcceptanceDatabaseGateway.php.

132 : void
133 {
134 $this->db->manipulate(
135 'DELETE FROM tos_acceptance_track WHERE usr_id = ' . $this->db->quote($entity->getUserId(), 'integer')
136 );
137 }

References ilTermsOfServiceAcceptanceEntity\getUserId().

+ Here is the call graph for this function:

◆ loadById()

ilTermsOfServiceAcceptanceDatabaseGateway::loadById ( ilTermsOfServiceAcceptanceEntity  $entity)

Implements ilTermsOfServiceAcceptanceDataGateway.

Definition at line 109 of file class.ilTermsOfServiceAcceptanceDatabaseGateway.php.

110 {
111 $res = $this->db->queryF(
112 '
113 SELECT *
114 FROM tos_versions
115 WHERE id = %s
116 ',
117 ['integer'],
118 [$entity->getId()]
119 );
120 $row = $this->db->fetchAssoc($res);
121
122 $entity = $entity
123 ->withId($row['id'])
124 ->withText($row['text'])
125 ->withHash($row['hash'])
126 ->withDocumentId($row['doc_id'])
127 ->withTitle($row['title']);
128
129 return $entity;
130 }
$res
Definition: ltiservices.php:69

References $res, ilTermsOfServiceAcceptanceEntity\getId(), and ilTermsOfServiceAcceptanceEntity\withId().

+ Here is the call graph for this function:

◆ loadCurrentAcceptanceOfUser()

ilTermsOfServiceAcceptanceDatabaseGateway::loadCurrentAcceptanceOfUser ( ilTermsOfServiceAcceptanceEntity  $entity)

Implements ilTermsOfServiceAcceptanceDataGateway.

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

74 $this->db->setLimit(1, 0);
75
76 $res = $this->db->queryF(
77 '
78 SELECT tos_versions.*,
79 tos_acceptance_track.ts accepted_ts,
80 tos_acceptance_track.criteria,
81 tos_acceptance_track.usr_id
82 FROM tos_acceptance_track
83 INNER JOIN tos_versions ON id = tosv_id
84 WHERE usr_id = %s
85 ORDER BY tos_acceptance_track.ts DESC
86 ',
87 ['integer'],
88 [$entity->getUserId()]
89 );
90 $row = $this->db->fetchAssoc($res);
91
92 if ($row === null) {
93 return $entity;
94 }
95
96 $entity = $entity
97 ->withId((int) $row['id'])
98 ->withUserId((int) $row['usr_id'])
99 ->withText((string) $row['text'])
100 ->withTimestamp((int) $row['accepted_ts'])
101 ->withHash((string) $row['hash'])
102 ->withDocumentId((int) $row['doc_id'])
103 ->withTitle((string) $row['title'])
104 ->withSerializedCriteria((string) $row['criteria']);
105
106 return $entity;
107 }

◆ trackAcceptance()

ilTermsOfServiceAcceptanceDatabaseGateway::trackAcceptance ( ilTermsOfServiceAcceptanceEntity  $entity)

Implements ilTermsOfServiceAcceptanceDataGateway.

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

34 : void
35 {
36 $res = $this->db->queryF(
37 'SELECT id FROM tos_versions WHERE hash = %s AND doc_id = %s',
38 ['text', 'integer'],
39 [$entity->getHash(), $entity->getDocumentId()]
40 );
41
42 if ($this->db->numRows($res)) {
43 $row = $this->db->fetchAssoc($res);
44 $versionId = $row['id'];
45 } else {
46 $versionId = $this->db->nextId('tos_versions');
47 $this->db->insert(
48 'tos_versions',
49 [
50 'id' => ['integer', $versionId],
51 'text' => ['clob', $entity->getText()],
52 'hash' => ['text', $entity->getHash()],
53 'doc_id' => ['integer', $entity->getDocumentId()],
54 'title' => ['text', $entity->getTitle()],
55 'ts' => ['integer', $entity->getTimestamp()]
56 ]
57 );
58 }
59
60 $this->db->insert(
61 'tos_acceptance_track',
62 [
63 'tosv_id' => ['integer', $versionId],
64 'usr_id' => ['integer', $entity->getUserId()],
65 'criteria' => ['clob', $entity->getSerializedCriteria()],
66 'ts' => ['integer', $entity->getTimestamp()]
67 ]
68 );
69 }

References $res, ilTermsOfServiceAcceptanceEntity\getDocumentId(), ilTermsOfServiceAcceptanceEntity\getHash(), ilTermsOfServiceAcceptanceEntity\getSerializedCriteria(), ilTermsOfServiceAcceptanceEntity\getText(), ilTermsOfServiceAcceptanceEntity\getTimestamp(), ilTermsOfServiceAcceptanceEntity\getTitle(), and ilTermsOfServiceAcceptanceEntity\getUserId().

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ilTermsOfServiceAcceptanceDatabaseGateway::$db
protected

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

Referenced by __construct().


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