ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 131 of file class.ilTermsOfServiceAcceptanceDatabaseGateway.php.

References ilTermsOfServiceAcceptanceEntity\getUserId().

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

◆ loadById()

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

Definition at line 105 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().

106  {
107  $res = $this->db->queryF('
108  SELECT *
109  FROM tos_versions
110  WHERE id = %s
111  ',
112  array('integer'),
113  array($entity->getId())
114  );
115  $row = $this->db->fetchAssoc($res);
116 
117  $entity->setId($row['id']);
118  $entity->setIso2LanguageCode($row['lng']);
119  $entity->setSource($row['src']);
120  $entity->setSourceType($row['src_type']);
121  $entity->setText($row['text']);
122  $entity->setTimestamp($row['ts']);
123  $entity->setHash($row['hash']);
124 
125  return $entity;
126  }
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 74 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().

75  {
76  $this->db->setLimit(1, 0);
77  $res = $this->db->queryF('
78  SELECT tos_versions.*, tos_acceptance_track.ts accepted_ts
79  FROM tos_acceptance_track
80  INNER JOIN tos_versions ON id = tosv_id
81  WHERE usr_id = %s
82  ORDER BY tos_acceptance_track.ts DESC
83  ',
84  array('integer'),
85  array($entity->getUserId())
86  );
87  $row = $this->db->fetchAssoc($res);
88 
89  $entity->setId($row['id']);
90  $entity->setUserId($row['usr_id']);
91  $entity->setIso2LanguageCode($row['lng']);
92  $entity->setSource($row['src']);
93  $entity->setSourceType($row['src_type']);
94  $entity->setText($row['text']);
95  $entity->setTimestamp($row['accepted_ts']);
96  $entity->setHash($row['hash']);
97 
98  return $entity;
99  }
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  {
40  $row = $this->db->fetchAssoc($res);
41  $tosv_id = $row['id'];
42  }
43  else
44  {
45  $tosv_id = $this->db->nextId('tos_versions');
46  $this->db->insert(
47  'tos_versions',
48  array(
49  'id' => array('integer', $tosv_id),
50  'lng' => array('text', $entity->getIso2LanguageCode()),
51  'src' => array('text', $entity->getSource()),
52  'src_type' => array('integer', $entity->getSourceType()),
53  'text' => array('clob', $entity->getText()),
54  'hash' => array('text', $entity->getHash()),
55  'ts' => array('integer', $entity->getTimestamp())
56  )
57  );
58  }
59 
60  $this->db->insert(
61  'tos_acceptance_track',
62  array(
63  'tosv_id' => array('integer', $tosv_id),
64  'usr_id' => array('integer', $entity->getUserId()),
65  'ts' => array('integer', $entity->getTimestamp())
66  )
67  );
68  }
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: