19 declare(strict_types=1);
40 if (null === $dataGatewayFactory) {
46 if (null === $termsOfServiceEvaluation) {
47 $termsOfServiceEvaluation = $DIC[
'tos.document.evaluator'];
51 if (null === $criterionTypeFactory) {
52 $criterionTypeFactory = $DIC[
'tos.criteria.type.factory'];
64 return (
new self())->tos->getStatus();
69 return $this->tos->getStatus();
78 $entity = $this->
getEntityFactory()->getByName(
'ilTermsOfServiceAcceptanceEntity');
79 $databaseGateway = $this->
getDataGatewayFactory()->getByName(
'ilTermsOfServiceAcceptanceDatabaseGateway');
81 $databaseGateway->deleteAcceptanceHistoryByUser($entity->withUserId($userId));
91 $entity = $this->
getEntityFactory()->getByName(
'ilTermsOfServiceAcceptanceEntity');
92 $databaseGateway = $this->
getDataGatewayFactory()->getByName(
'ilTermsOfServiceAcceptanceDatabaseGateway');
94 return $databaseGateway->loadCurrentAcceptanceOfUser($entity->withUserId($user->
getId()));
104 $entity = $this->
getEntityFactory()->getByName(
'ilTermsOfServiceAcceptanceEntity');
105 $databaseGateway = $this->
getDataGatewayFactory()->getByName(
'ilTermsOfServiceAcceptanceDatabaseGateway');
107 return $databaseGateway->loadById($entity->withId($id));
118 $entity = $this->
getEntityFactory()->getByName(
'ilTermsOfServiceAcceptanceEntity');
119 $databaseGateway = $this->
getDataGatewayFactory()->getByName(
'ilTermsOfServiceAcceptanceDatabaseGateway');
122 ->withUserId($user->
getId())
123 ->withTimestamp(time())
124 ->withText($document->
content())
125 ->withHash(md5($document->
content()))
126 ->withDocumentId($document->
id())
127 ->withTitle($document->
title());
130 $entity = $entity->withSerializedCriteria($criteriaBag->toJson());
132 $databaseGateway->trackAcceptance($entity);
147 $excluded_roles = [];
148 if (defined(
'ANONYMOUS_USER_ID')) {
151 if (defined(
'SYSTEM_USER_ID')) {
157 !in_array($user->
getId(), $excluded_roles,
true) &&
165 $logger->
debug(sprintf(
166 'Checking reevaluation of Terms of Service for user "%s" (id: %s) ...',
172 $logger->
debug(
'Terms of Service disabled, resigning not required ...');
177 $logger->
debug(
'User is not included for Terms of Service acceptance, resigning not required ...');
181 if (!$this->tos->shouldReevaluateOnLogin()) {
182 $logger->
debug(
'Reevaluation of documents is not enabled, resigning not required ...');
187 $logger->
debug(
'Terms of Service currently not accepted by user, resigning not required ...');
191 $evaluator = $this->termsOfServiceEvaluation->withContextUser($user);
192 if (!$evaluator->hasDocument()) {
193 $logger->
debug(
'No signable Terms of Service document found, resigning not required ...');
198 if (!($entity->getId() > 0)) {
199 $logger->
debug(
'No signed Terms of Service document found, resigning not required ...');
208 if ($evaluator->evaluateDocument($historizedDocument)) {
209 $logger->
debug(
'Current user values do still match historized criteria, resigning not required ...');
213 $logger->
debug(
'Current user values do not match historized criteria, resigning required ...');
Class ilTermsOfServiceEntityFactory.
deleteAcceptanceHistoryByUser(int $userId)
setAgreeDate(?string $a_str)
const SYSTEM_USER_ID
This file contains constants for PHPStan analyis, see: https://phpstan.org/config-reference#constants...
ilTermsOfServiceCriterionTypeFactoryInterface $criterionTypeFactory
debug(string $a_message, array $a_context=array())
isIncludedUser(ilObjUser $user)
ilTermsOfServiceDocumentEvaluation $termsOfServiceEvaluation
hasToResignAcceptance(ilObjUser $user, ilLogger $logger)
Interface ilTermsOfServiceDocumentEvaluation.
Class ilTermsOfServiceHistorizedDocument.
ilTermsOfServiceDataGatewayFactory $dataGatewayFactory
writeAccepted()
write accept date of user agreement
Class ilTermsOfServiceDataGatewayFactory.
Class ilTermsOfServiceAcceptanceHistoryCriteriaBag.
resetAcceptance(ilObjUser $user)
getCurrentAcceptanceForUser(ilObjUser $user)
trackAcceptance(ilObjUser $user, ilTermsOfServiceSignableDocument $document)
Class ilTermsOfServiceHelper.
hasToAcceptTermsOfServiceInSession(?bool $status=null)
Class ilTermsOfServiceAcceptanceEntity.
Interface ilTermsOfServiceSignableDocument.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
setDatabaseAdapter(?ilDBInterface $db)
__construct(?ilTermsOfServiceDataGatewayFactory $dataGatewayFactory=null, ?ilTermsOfServiceDocumentEvaluation $termsOfServiceEvaluation=null, ?ilTermsOfServiceCriterionTypeFactoryInterface $criterionTypeFactory=null, ?ilObjTermsOfService $tos=null)
Class ilObjTermsOfService.
Interface ilTermsOfServiceCriterionTypeFactoryInterface.