ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilTermsOfServiceAcceptanceDatabaseGateway Class Reference
+ Inheritance diagram for ilTermsOfServiceAcceptanceDatabaseGateway:
+ Collaboration diagram for ilTermsOfServiceAcceptanceDatabaseGateway:

Public Member Functions

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

Protected Attributes

 $db
 

Detailed Description

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilTermsOfServiceAcceptanceDatabaseGateway::__construct ( ilDBInterface  $db)

Member Function Documentation

◆ deleteAcceptanceHistoryByUser()

ilTermsOfServiceAcceptanceDatabaseGateway::deleteAcceptanceHistoryByUser ( ilTermsOfServiceAcceptanceEntity  $entity)
Parameters
ilTermsOfServiceAcceptanceEntity$entity

Implements ilTermsOfServiceAcceptanceDataGateway.

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

References ilTermsOfServiceAcceptanceEntity\getUserId().

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

◆ loadById()

ilTermsOfServiceAcceptanceDatabaseGateway::loadById ( ilTermsOfServiceAcceptanceEntity  $entity)
Parameters
ilTermsOfServiceAcceptanceEntity$entity
Returns
ilTermsOfServiceAcceptanceEntity

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

References $res, $row, array, ilTermsOfServiceAcceptanceEntity\getId(), ilTermsOfServiceAcceptanceEntity\setHash(), ilTermsOfServiceAcceptanceEntity\setId(), ilTermsOfServiceAcceptanceEntity\setIso2LanguageCode(), ilTermsOfServiceAcceptanceEntity\setSource(), ilTermsOfServiceAcceptanceEntity\setSourceType(), ilTermsOfServiceAcceptanceEntity\setText(), and ilTermsOfServiceAcceptanceEntity\setTimestamp().

104  {
105  $res = $this->db->queryF(
106  '
107  SELECT *
108  FROM tos_versions
109  WHERE id = %s
110  ',
111  array('integer'),
112  array($entity->getId())
113  );
114  $row = $this->db->fetchAssoc($res);
115 
116  $entity->setId($row['id']);
117  $entity->setIso2LanguageCode($row['lng']);
118  $entity->setSource($row['src']);
119  $entity->setSourceType($row['src_type']);
120  $entity->setText($row['text']);
121  $entity->setTimestamp($row['ts']);
122  $entity->setHash($row['hash']);
123 
124  return $entity;
125  }
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ loadCurrentAcceptanceOfUser()

ilTermsOfServiceAcceptanceDatabaseGateway::loadCurrentAcceptanceOfUser ( ilTermsOfServiceAcceptanceEntity  $entity)
Parameters
ilTermsOfServiceAcceptanceEntity$entity
Returns
ilTermsOfServiceAcceptanceEntity

Implements ilTermsOfServiceAcceptanceDataGateway.

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

References $res, $row, array, ilTermsOfServiceAcceptanceEntity\getUserId(), ilTermsOfServiceAcceptanceEntity\setHash(), ilTermsOfServiceAcceptanceEntity\setId(), ilTermsOfServiceAcceptanceEntity\setIso2LanguageCode(), ilTermsOfServiceAcceptanceEntity\setSource(), ilTermsOfServiceAcceptanceEntity\setSourceType(), ilTermsOfServiceAcceptanceEntity\setText(), ilTermsOfServiceAcceptanceEntity\setTimestamp(), and ilTermsOfServiceAcceptanceEntity\setUserId().

72  {
73  $this->db->setLimit(1, 0);
74  $res = $this->db->queryF(
75  '
76  SELECT tos_versions.*, tos_acceptance_track.ts accepted_ts
77  FROM tos_acceptance_track
78  INNER JOIN tos_versions ON id = tosv_id
79  WHERE usr_id = %s
80  ORDER BY tos_acceptance_track.ts DESC
81  ',
82  array('integer'),
83  array($entity->getUserId())
84  );
85  $row = $this->db->fetchAssoc($res);
86 
87  $entity->setId($row['id']);
88  $entity->setUserId($row['usr_id']);
89  $entity->setIso2LanguageCode($row['lng']);
90  $entity->setSource($row['src']);
91  $entity->setSourceType($row['src_type']);
92  $entity->setText($row['text']);
93  $entity->setTimestamp($row['accepted_ts']);
94  $entity->setHash($row['hash']);
95 
96  return $entity;
97  }
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ trackAcceptance()

ilTermsOfServiceAcceptanceDatabaseGateway::trackAcceptance ( ilTermsOfServiceAcceptanceEntity  $entity)
Parameters
ilTermsOfServiceAcceptanceEntity$entity

Implements ilTermsOfServiceAcceptanceDataGateway.

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

References $query, $res, $row, array, ilTermsOfServiceAcceptanceEntity\getHash(), ilTermsOfServiceAcceptanceEntity\getIso2LanguageCode(), ilTermsOfServiceAcceptanceEntity\getSource(), ilTermsOfServiceAcceptanceEntity\getSourceType(), ilTermsOfServiceAcceptanceEntity\getText(), ilTermsOfServiceAcceptanceEntity\getTimestamp(), and ilTermsOfServiceAcceptanceEntity\getUserId().

30  {
31  $query = 'SELECT id FROM tos_versions WHERE hash = %s AND lng = %s';
32  $res = $this->db->queryF(
33  $query,
34  array('text', 'text'),
35  array($entity->getHash(), $entity->getIso2LanguageCode())
36  );
37 
38  if ($this->db->numRows($res)) {
39  $row = $this->db->fetchAssoc($res);
40  $tosv_id = $row['id'];
41  } else {
42  $tosv_id = $this->db->nextId('tos_versions');
43  $this->db->insert(
44  'tos_versions',
45  array(
46  'id' => array('integer', $tosv_id),
47  'lng' => array('text', $entity->getIso2LanguageCode()),
48  'src' => array('text', $entity->getSource()),
49  'src_type' => array('integer', $entity->getSourceType()),
50  'text' => array('clob', $entity->getText()),
51  'hash' => array('text', $entity->getHash()),
52  'ts' => array('integer', $entity->getTimestamp())
53  )
54  );
55  }
56 
57  $this->db->insert(
58  'tos_acceptance_track',
59  array(
60  'tosv_id' => array('integer', $tosv_id),
61  'usr_id' => array('integer', $entity->getUserId()),
62  'ts' => array('integer', $entity->getTimestamp())
63  )
64  );
65  }
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilTermsOfServiceAcceptanceDatabaseGateway::$db
protected

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

Referenced by __construct().


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