ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilTermsOfServiceAcceptanceDatabaseGateway Class Reference
+ Inheritance diagram for ilTermsOfServiceAcceptanceDatabaseGateway:
+ Collaboration diagram for ilTermsOfServiceAcceptanceDatabaseGateway:

Public Member Functions

 __construct (ilDB $db)
 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

ilTermsOfServiceAcceptanceDatabaseGateway::__construct ( ilDB  $db)
Parameters
ilDB$db

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

References $db.

{
$this->db = $db;
}

Member Function Documentation

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

Implements ilTermsOfServiceAcceptanceDataGateway.

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

References ilTermsOfServiceAcceptanceEntity\getUserId().

{
$this->db->manipulate('DELETE FROM tos_acceptance_track WHERE usr_id = ' . $this->db->quote($entity->getUserId(), 'integer'));
}

+ Here is the call graph for this function:

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

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

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

{
$res = $this->db->queryF('
SELECT *
FROM tos_versions
WHERE id = %s
',
array('integer'),
array($entity->getId())
);
$row = $this->db->fetchAssoc($res);
$entity->setId($row['id']);
$entity->setIso2LanguageCode($row['lng']);
$entity->setSource($row['src']);
$entity->setSourceType($row['src_type']);
$entity->setText($row['text']);
$entity->setTimestamp($row['ts']);
$entity->setHash($row['hash']);
return $entity;
}

+ Here is the call graph for this function:

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

Implements ilTermsOfServiceAcceptanceDataGateway.

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

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

{
$this->db->setLimit(1, 0);
$res = $this->db->queryF('
SELECT tos_versions.*, tos_acceptance_track.ts accepted_ts
FROM tos_acceptance_track
INNER JOIN tos_versions ON id = tosv_id
WHERE usr_id = %s
ORDER BY tos_acceptance_track.ts DESC
',
array('integer'),
array($entity->getUserId())
);
$row = $this->db->fetchAssoc($res);
$entity->setId($row['id']);
$entity->setUserId($row['usr_id']);
$entity->setIso2LanguageCode($row['lng']);
$entity->setSource($row['src']);
$entity->setSourceType($row['src_type']);
$entity->setText($row['text']);
$entity->setTimestamp($row['accepted_ts']);
$entity->setHash($row['hash']);
return $entity;
}

+ Here is the call graph for this function:

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

Implements ilTermsOfServiceAcceptanceDataGateway.

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

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

{
$query = 'SELECT id FROM tos_versions WHERE hash = %s AND lng = %s';
$res = $this->db->queryF(
array('text', 'text'),
array($entity->getHash(), $entity->getIso2LanguageCode())
);
if($this->db->numRows($res))
{
$row = $this->db->fetchAssoc($res);
$tosv_id = $row['id'];
}
else
{
$tosv_id = $this->db->nextId('tos_versions');
$this->db->insert(
'tos_versions',
array(
'id' => array('integer', $tosv_id),
'lng' => array('text', $entity->getIso2LanguageCode()),
'src' => array('text', $entity->getSource()),
'src_type' => array('integer', $entity->getSourceType()),
'text' => array('clob', $entity->getText()),
'hash' => array('text', $entity->getHash()),
'ts' => array('integer', $entity->getTimestamp())
)
);
}
$this->db->insert(
'tos_acceptance_track',
array(
'tosv_id' => array('integer', $tosv_id),
'usr_id' => array('integer', $entity->getUserId()),
'ts' => array('integer', $entity->getTimestamp())
)
);
}

+ Here is the call graph for this function:

Field Documentation

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: