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

Class ilTermsOfServiceHelper. More...

+ Collaboration diagram for ilTermsOfServiceHelper:

Public Member Functions

 __construct (\ilDBInterface $database=null, \ilTermsOfServiceDataGatewayFactory $dataGatewayFactory=null)
 ilTermsOfServiceHelper constructor. More...
 
 deleteAcceptanceHistoryByUser (int $userId)
 
 getCurrentAcceptanceForUser (\ilObjUser $user)
 
 getById (int $id)
 
 trackAcceptance (\ilObjUser $user, \ilTermsOfServiceSignableDocument $document)
 

Static Public Member Functions

static isEnabled ()
 
static setStatus (bool $status)
 

Protected Attributes

 $database
 
 $dataGatewayFactory
 

Private Member Functions

 getEntityFactory ()
 
 getDataGatewayFactory ()
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilTermsOfServiceHelper::__construct ( \ilDBInterface  $database = null,
\ilTermsOfServiceDataGatewayFactory  $dataGatewayFactory = null 
)

ilTermsOfServiceHelper constructor.

Parameters
\ilDBInterface | null$database
\ilTermsOfServiceDataGatewayFactory | null$dataGatewayFactory

Definition at line 21 of file class.ilTermsOfServiceHelper.php.

24 {
25 global $DIC;
26
27 if (null === $database) {
28 $database = $DIC->database();
29 }
30 $this->database = $database;
31
32 if (null === $dataGatewayFactory) {
33 $dataGatewayFactory = new \ilTermsOfServiceDataGatewayFactory();
34 $dataGatewayFactory->setDatabaseAdapter($this->database);
35 }
36 $this->dataGatewayFactory = $dataGatewayFactory;
37 }
global $DIC
Definition: saml.php:7

References $database, $dataGatewayFactory, and $DIC.

Member Function Documentation

◆ deleteAcceptanceHistoryByUser()

ilTermsOfServiceHelper::deleteAcceptanceHistoryByUser ( int  $userId)
Parameters
int$userId
Exceptions

ilTermsOfServiceMissingDatabaseAdapterException

Definition at line 63 of file class.ilTermsOfServiceHelper.php.

64 {
65 $entity = $this->getEntityFactory()->getByName('ilTermsOfServiceAcceptanceEntity');
66 $databaseGateway = $this->getDataGatewayFactory()->getByName('ilTermsOfServiceAcceptanceDatabaseGateway');
67
68 $databaseGateway->deleteAcceptanceHistoryByUser($entity->withUserId($userId));
69 }

References getDataGatewayFactory(), and getEntityFactory().

+ Here is the call graph for this function:

◆ getById()

ilTermsOfServiceHelper::getById ( int  $id)
Parameters
int$id
Returns
\ilTermsOfServiceAcceptanceEntity
Exceptions

ilTermsOfServiceMissingDatabaseAdapterException

Definition at line 89 of file class.ilTermsOfServiceHelper.php.

90 {
91 $entity = $this->getEntityFactory()->getByName('ilTermsOfServiceAcceptanceEntity');
92 $databaseGateway = $this->getDataGatewayFactory()->getByName('ilTermsOfServiceAcceptanceDatabaseGateway');
93
94 return $databaseGateway->loadById($entity->withId($id));
95 }
Class ilTermsOfServiceAcceptanceEntity.
if(!array_key_exists('StateId', $_REQUEST)) $id

References $id, getDataGatewayFactory(), and getEntityFactory().

+ Here is the call graph for this function:

◆ getCurrentAcceptanceForUser()

ilTermsOfServiceHelper::getCurrentAcceptanceForUser ( \ilObjUser  $user)
Parameters
\ilObjUser$user
Returns
\ilTermsOfServiceAcceptanceEntity
Exceptions

ilTermsOfServiceMissingDatabaseAdapterException

Definition at line 76 of file class.ilTermsOfServiceHelper.php.

77 {
78 $entity = $this->getEntityFactory()->getByName('ilTermsOfServiceAcceptanceEntity');
79 $databaseGateway = $this->getDataGatewayFactory()->getByName('ilTermsOfServiceAcceptanceDatabaseGateway');
80
81 return $databaseGateway->loadCurrentAcceptanceOfUser($entity->withUserId((int) $user->getId()));
82 }
$user
Definition: migrateto20.php:57

References $user, getDataGatewayFactory(), and getEntityFactory().

+ Here is the call graph for this function:

◆ getDataGatewayFactory()

ilTermsOfServiceHelper::getDataGatewayFactory ( )
private
Returns
\ilTermsOfServiceDataGatewayFactory

Definition at line 136 of file class.ilTermsOfServiceHelper.php.

References $dataGatewayFactory.

Referenced by deleteAcceptanceHistoryByUser(), getById(), getCurrentAcceptanceForUser(), and trackAcceptance().

+ Here is the caller graph for this function:

◆ getEntityFactory()

ilTermsOfServiceHelper::getEntityFactory ( )
private
Returns
\ilTermsOfServiceEntityFactory

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

129 {
130 return new \ilTermsOfServiceEntityFactory();
131 }
Class ilTermsOfServiceEntityFactory.

Referenced by deleteAcceptanceHistoryByUser(), getById(), getCurrentAcceptanceForUser(), and trackAcceptance().

+ Here is the caller graph for this function:

◆ isEnabled()

static ilTermsOfServiceHelper::isEnabled ( )
static

◆ setStatus()

static ilTermsOfServiceHelper::setStatus ( bool  $status)
static
Parameters
bool$status

Definition at line 52 of file class.ilTermsOfServiceHelper.php.

53 {
54 global $DIC;
55
56 $DIC['ilSetting']->set('tos_status', (int) $status);
57 }

References $DIC.

Referenced by ilObjTermsOfService\saveStatus().

+ Here is the caller graph for this function:

◆ trackAcceptance()

ilTermsOfServiceHelper::trackAcceptance ( \ilObjUser  $user,
\ilTermsOfServiceSignableDocument  $document 
)
Parameters
\ilObjUser$user
\ilTermsOfServiceSignableDocument$document
Exceptions

ilTermsOfServiceMissingDatabaseAdapterException

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

103 {
104 $entity = $this->getEntityFactory()->getByName('ilTermsOfServiceAcceptanceEntity');
105 $databaseGateway = $this->getDataGatewayFactory()->getByName('ilTermsOfServiceAcceptanceDatabaseGateway');
106
107 $entity = $entity
108 ->withUserId((int) $user->getId())
109 ->withTimestamp(time())
110 ->withText((string) $document->content())
111 ->withHash(md5($document->content()))
112 ->withDocumentId((int) $document->id())
113 ->withTitle((string) $document->title());
114
115 $criteriaBag = new \ilTermsOfServiceAcceptanceHistoryCriteriaBag($document->criteria());
116 $entity = $entity->withSerializedCriteria($criteriaBag->toJson());
117
118 $databaseGateway->trackAcceptance($entity);
119
120 $user->writeAccepted();
121
122 $user->hasToAcceptTermsOfServiceInSession(false);
123 }

References $user, ilTermsOfServiceSignableDocument\content(), ilTermsOfServiceSignableDocument\criteria(), getDataGatewayFactory(), getEntityFactory(), ilTermsOfServiceSignableDocument\id(), and ilTermsOfServiceSignableDocument\title().

+ Here is the call graph for this function:

Field Documentation

◆ $database

ilTermsOfServiceHelper::$database
protected

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

Referenced by __construct().

◆ $dataGatewayFactory

ilTermsOfServiceHelper::$dataGatewayFactory
protected

Definition at line 14 of file class.ilTermsOfServiceHelper.php.

Referenced by __construct(), and getDataGatewayFactory().


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