ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilTermsOfServiceAcceptanceDatabaseGateway Class Reference

Class ilTermsOfServiceAcceptanceDatabaseGateway. More...

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

Public Member Functions

 __construct (\ilDBInterface $db)
 ilTermsOfServiceAcceptanceDatabaseGateway constructor. More...
 
 trackAcceptance (\ilTermsOfServiceAcceptanceEntity $entity)
 
Parameters
\ilTermsOfServiceAcceptanceEntity$entity
More...
 
 loadCurrentAcceptanceOfUser (\ilTermsOfServiceAcceptanceEntity $entity)
 
Parameters
\ilTermsOfServiceAcceptanceEntity$entity
Returns
More...
 
 loadById (\ilTermsOfServiceAcceptanceEntity $entity)
 
Parameters
\ilTermsOfServiceAcceptanceEntity$entity
Returns
mixed
More...
 
 deleteAcceptanceHistoryByUser (\ilTermsOfServiceAcceptanceEntity $entity)
 
Parameters
\ilTermsOfServiceAcceptanceEntity$entity
More...
 

Protected Attributes

 $db
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilTermsOfServiceAcceptanceDatabaseGateway::__construct ( \ilDBInterface  $db)

ilTermsOfServiceAcceptanceDatabaseGateway constructor.

Parameters
\ilDBInterface$db

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

References $db.

Member Function Documentation

◆ deleteAcceptanceHistoryByUser()

ilTermsOfServiceAcceptanceDatabaseGateway::deleteAcceptanceHistoryByUser ( \ilTermsOfServiceAcceptanceEntity  $entity)

Parameters
\ilTermsOfServiceAcceptanceEntity$entity

Implements ilTermsOfServiceAcceptanceDataGateway.

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

References ilTermsOfServiceAcceptanceEntity\getUserId().

128  {
129  $this->db->manipulate(
130  'DELETE FROM tos_acceptance_track WHERE usr_id = ' . $this->db->quote($entity->getUserId(), 'integer')
131  );
132  }
+ Here is the call graph for this function:

◆ loadById()

ilTermsOfServiceAcceptanceDatabaseGateway::loadById ( \ilTermsOfServiceAcceptanceEntity  $entity)

Parameters
\ilTermsOfServiceAcceptanceEntity$entity
Returns
mixed

Implements ilTermsOfServiceAcceptanceDataGateway.

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

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

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  }
foreach($_POST as $key=> $value) $res
$row
Class ilTermsOfServiceAcceptanceEntity.
+ Here is the call graph for this function:

◆ loadCurrentAcceptanceOfUser()

ilTermsOfServiceAcceptanceDatabaseGateway::loadCurrentAcceptanceOfUser ( \ilTermsOfServiceAcceptanceEntity  $entity)

Parameters
\ilTermsOfServiceAcceptanceEntity$entity
Returns

Implements ilTermsOfServiceAcceptanceDataGateway.

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

References $res, $row, ilTermsOfServiceAcceptanceEntity\getUserId(), and ilTermsOfServiceAcceptanceEntity\withId().

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  }
foreach($_POST as $key=> $value) $res
$row
Class ilTermsOfServiceAcceptanceEntity.
+ Here is the call graph for this function:

◆ trackAcceptance()

ilTermsOfServiceAcceptanceDatabaseGateway::trackAcceptance ( \ilTermsOfServiceAcceptanceEntity  $entity)

Parameters
\ilTermsOfServiceAcceptanceEntity$entity

Implements ilTermsOfServiceAcceptanceDataGateway.

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

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

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  }
foreach($_POST as $key=> $value) $res
$row
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilTermsOfServiceAcceptanceDatabaseGateway::$db
protected

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

Referenced by __construct().


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