ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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
ilTermsOfServiceAcceptanceEntity
More...
 
 loadById (ilTermsOfServiceAcceptanceEntity $entity)
 
Parameters
ilTermsOfServiceAcceptanceEntity$entity
Returns
ilTermsOfServiceAcceptanceEntity
More...
 
 deleteAcceptanceHistoryByUser (ilTermsOfServiceAcceptanceEntity $entity)
 
Parameters
ilTermsOfServiceAcceptanceEntity$entity
More...
 

Protected Attributes

 $db
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilTermsOfServiceAcceptanceDatabaseGateway::__construct ( ilDBInterface  $db)

Member Function Documentation

◆ deleteAcceptanceHistoryByUser()

ilTermsOfServiceAcceptanceDatabaseGateway::deleteAcceptanceHistoryByUser ( ilTermsOfServiceAcceptanceEntity  $entity)

Parameters
ilTermsOfServiceAcceptanceEntity$entity

Implements ilTermsOfServiceAcceptanceDataGateway.

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

References ilTermsOfServiceAcceptanceEntity\getUserId().

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

◆ loadById()

ilTermsOfServiceAcceptanceDatabaseGateway::loadById ( ilTermsOfServiceAcceptanceEntity  $entity)

Parameters
ilTermsOfServiceAcceptanceEntity$entity
Returns
ilTermsOfServiceAcceptanceEntity

Implements ilTermsOfServiceAcceptanceDataGateway.

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

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

103  {
104  $res = $this->db->queryF(
105  '
106  SELECT *
107  FROM tos_versions
108  WHERE id = %s
109  ',
110  ['integer'],
111  [$entity->getId()]
112  );
113  $row = $this->db->fetchAssoc($res);
114 
115  $entity = $entity
116  ->withId($row['id'])
117  ->withText($row['text'])
118  ->withHash($row['hash'])
119  ->withDocumentId($row['doc_id'])
120  ->withTitle($row['title']);
121 
122  return $entity;
123  }
foreach($_POST as $key=> $value) $res
Class ilTermsOfServiceAcceptanceEntity.
+ Here is the call graph for this function:

◆ loadCurrentAcceptanceOfUser()

ilTermsOfServiceAcceptanceDatabaseGateway::loadCurrentAcceptanceOfUser ( ilTermsOfServiceAcceptanceEntity  $entity)

Parameters
ilTermsOfServiceAcceptanceEntity$entity
Returns
ilTermsOfServiceAcceptanceEntity

Implements ilTermsOfServiceAcceptanceDataGateway.

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

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

68  $this->db->setLimit(1, 0);
69 
70  $res = $this->db->queryF(
71  '
72  SELECT tos_versions.*,
73  tos_acceptance_track.ts accepted_ts,
74  tos_acceptance_track.criteria,
75  tos_acceptance_track.usr_id
76  FROM tos_acceptance_track
77  INNER JOIN tos_versions ON id = tosv_id
78  WHERE usr_id = %s
79  ORDER BY tos_acceptance_track.ts DESC
80  ',
81  ['integer'],
82  [$entity->getUserId()]
83  );
84  $row = $this->db->fetchAssoc($res);
85 
86  $entity = $entity
87  ->withId((int) $row['id'])
88  ->withUserId((int) $row['usr_id'])
89  ->withText((string) $row['text'])
90  ->withTimestamp((int) $row['accepted_ts'])
91  ->withHash((string) $row['hash'])
92  ->withDocumentId((int) $row['doc_id'])
93  ->withTitle((string) $row['title'])
94  ->withSerializedCriteria((string) $row['criteria']);
95 
96  return $entity;
97  }
foreach($_POST as $key=> $value) $res
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, ilTermsOfServiceAcceptanceEntity\getDocumentId(), ilTermsOfServiceAcceptanceEntity\getHash(), ilTermsOfServiceAcceptanceEntity\getSerializedCriteria(), ilTermsOfServiceAcceptanceEntity\getText(), ilTermsOfServiceAcceptanceEntity\getTimestamp(), ilTermsOfServiceAcceptanceEntity\getTitle(), and ilTermsOfServiceAcceptanceEntity\getUserId().

25  : void
26  {
27  $res = $this->db->queryF(
28  'SELECT id FROM tos_versions WHERE hash = %s AND doc_id = %s',
29  ['text', 'integer'],
30  [$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
+ 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: