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.

References $database, $dataGatewayFactory, and $DIC.

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

Member Function Documentation

◆ deleteAcceptanceHistoryByUser()

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

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

References getDataGatewayFactory(), and getEntityFactory().

64  {
65  $entity = $this->getEntityFactory()->getByName('ilTermsOfServiceAcceptanceEntity');
66  $databaseGateway = $this->getDataGatewayFactory()->getByName('ilTermsOfServiceAcceptanceDatabaseGateway');
67 
68  $databaseGateway->deleteAcceptanceHistoryByUser($entity->withUserId($userId));
69  }
+ Here is the call graph for this function:

◆ getById()

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

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

References getDataGatewayFactory(), and getEntityFactory().

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

◆ getCurrentAcceptanceForUser()

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

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

References getDataGatewayFactory(), getEntityFactory(), and ilObject\getId().

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
Class ilTermsOfServiceAcceptanceEntity.
+ Here is the call graph for this function:

◆ getDataGatewayFactory()

ilTermsOfServiceHelper::getDataGatewayFactory ( )
private
Returns

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

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

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

129  {
130  return new \ilTermsOfServiceEntityFactory();
131  }
Class ilTermsOfServiceEntityFactory.
+ Here is the caller graph for this function:

◆ isEnabled()

static ilTermsOfServiceHelper::isEnabled ( )
static
Returns
bool

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

References $DIC.

Referenced by ilAccountRegistrationGUI\__initForm(), ilObjUser\_writeHistory(), ilAwarenessUserCollector\collectUsers(), ilObjUser\hasToAcceptTermsOfService(), ilObjUser\hasToAcceptTermsOfServiceInSession(), ilAccountRegistrationGUI\saveForm(), ilStartUpGUI\showTermsOfService(), ilStartUpGUI\showTermsOfServiceLink(), and ilPersonalProfileGUI\showUserAgreement().

42  : bool
43  {
44  global $DIC;
45 
46  return (bool) $DIC['ilSetting']->get('tos_status', false);
47  }
global $DIC
Definition: saml.php:7
+ Here is the caller graph for this function:

◆ setStatus()

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

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

References $DIC.

Referenced by ilObjTermsOfService\saveStatus().

53  {
54  global $DIC;
55 
56  $DIC['ilSetting']->set('tos_status', (int) $status);
57  }
global $DIC
Definition: saml.php:7
+ Here is the caller graph for this function:

◆ trackAcceptance()

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

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

References ilTermsOfServiceSignableDocument\content(), ilTermsOfServiceSignableDocument\criteria(), getDataGatewayFactory(), getEntityFactory(), ilObject\getId(), ilObjUser\hasToAcceptTermsOfServiceInSession(), ilTermsOfServiceSignableDocument\id(), ilTermsOfServiceSignableDocument\title(), and ilObjUser\writeAccepted().

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  }
$user
Definition: migrateto20.php:57
+ 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: