ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\LegalDocuments\ConsumerToolbox\User Class Reference
+ Collaboration diagram for ILIAS\LegalDocuments\ConsumerToolbox\User:

Public Member Functions

 __construct (private readonly ilObjUser $user, private readonly Settings $settings, private readonly UserSettings $user_settings, private readonly Provide $legal_documents, private readonly Clock $clock)
 
 isLoggedIn ()
 
 cannotAgree ()
 
 neverAgreed ()
 
 withdrawalRequested ()
 
 agreeDate ()
 
 didNotAcceptCurrentVersion ()
 
 needsToAcceptNewDocument ()
 
 doesntMatch (Document $document)
 
 matchingDocument ()
 
 acceptedVersion ()
 
 acceptMatchingDocument ()
 
 acceptAnyDocument ()
 
 isLDAPUser ()
 
 isExternalAccount ()
 
 format (string $format_string)
 
 raw ()
 

Private Member Functions

 authMode ()
 
 didNotAccept (Document $document)
 
 lazy (callable $create_value)
 @template A More...
 

Private Attributes

readonly Closure $matching_document
 

Detailed Description

Definition at line 35 of file User.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\LegalDocuments\ConsumerToolbox\User::__construct ( private readonly ilObjUser  $user,
private readonly Settings  $settings,
private readonly UserSettings  $user_settings,
private readonly Provide  $legal_documents,
private readonly Clock  $clock 
)

Definition at line 40 of file User.php.

46 {
47 $this->matching_document = $this->lazy(fn() => $this->legal_documents->document()->chooseDocumentFor($this->user));
48 }
lazy(callable $create_value)
@template A
Definition: User.php:177

References ILIAS\LegalDocuments\ConsumerToolbox\User\lazy().

+ Here is the call graph for this function:

Member Function Documentation

◆ acceptAnyDocument()

ILIAS\LegalDocuments\ConsumerToolbox\User::acceptAnyDocument ( )

Definition at line 126 of file User.php.

126 : void
127 {
128 $this->legal_documents->history()->acceptDocument(
129 $this->user,
130 current($this->legal_documents->document()->repository()->all())
131 );
132 }

References ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ acceptedVersion()

ILIAS\LegalDocuments\ConsumerToolbox\User::acceptedVersion ( )

Definition at line 110 of file User.php.

110 : Result
111 {
112 return $this->cannotAgree() || $this->neverAgreed() ?
113 new Error('User never agreed.') :
114 $this->legal_documents->history()->acceptedVersion($this->user);
115 }

References ILIAS\LegalDocuments\ConsumerToolbox\User\cannotAgree(), ILIAS\LegalDocuments\ConsumerToolbox\User\neverAgreed(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ acceptMatchingDocument()

ILIAS\LegalDocuments\ConsumerToolbox\User::acceptMatchingDocument ( )

Definition at line 117 of file User.php.

117 : void
118 {
119 $this->legal_documents->history()->acceptDocument(
120 $this->user,
121 $this->matchingDocument()->value()
122 );
123 $this->agreeDate()->update($this->clock->now());
124 }

References ILIAS\LegalDocuments\ConsumerToolbox\User\agreeDate(), ILIAS\LegalDocuments\ConsumerToolbox\User\matchingDocument(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ agreeDate()

ILIAS\LegalDocuments\ConsumerToolbox\User::agreeDate ( )
Returns
Setting<?DateTimeImmutable>

Definition at line 76 of file User.php.

76 : Setting
77 {
78 return $this->user_settings->agreeDate();
79 }

Referenced by ILIAS\LegalDocuments\ConsumerToolbox\User\acceptMatchingDocument(), and ILIAS\LegalDocuments\ConsumerToolbox\User\neverAgreed().

+ Here is the caller graph for this function:

◆ authMode()

ILIAS\LegalDocuments\ConsumerToolbox\User::authMode ( )
private

Definition at line 159 of file User.php.

159 : string
160 {
161 $auth_mode = $this->user->getAuthMode();
162 return $auth_mode === 'default' ?
163 $this->settings->authMode()->value() :
164 $auth_mode;
165 }

References ILIAS\Repository\settings(), and ILIAS\Repository\user().

Referenced by ILIAS\LegalDocuments\ConsumerToolbox\User\isExternalAccount(), and ILIAS\LegalDocuments\ConsumerToolbox\User\isLDAPUser().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cannotAgree()

ILIAS\LegalDocuments\ConsumerToolbox\User::cannotAgree ( )

Definition at line 55 of file User.php.

55 : bool
56 {
57 return in_array($this->user->getId(), [ANONYMOUS_USER_ID, SYSTEM_USER_ID, 0], true);
58 }
const SYSTEM_USER_ID
This file contains constants for PHPStan analyis, see: https://phpstan.org/config-reference#constants...
Definition: constants.php:26
const ANONYMOUS_USER_ID
Definition: constants.php:27

References ANONYMOUS_USER_ID, SYSTEM_USER_ID, and ILIAS\Repository\user().

Referenced by ILIAS\LegalDocuments\ConsumerToolbox\User\acceptedVersion(), and ILIAS\DataProtection\Consumer\showMatchingDocument().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ didNotAccept()

ILIAS\LegalDocuments\ConsumerToolbox\User::didNotAccept ( Document  $document)
private

Definition at line 167 of file User.php.

167 : bool
168 {
169 return !$this->legal_documents->history()->alreadyAccepted($this->user, $document);
170 }

References ILIAS\Repository\user().

Referenced by ILIAS\LegalDocuments\ConsumerToolbox\User\didNotAcceptCurrentVersion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ didNotAcceptCurrentVersion()

ILIAS\LegalDocuments\ConsumerToolbox\User::didNotAcceptCurrentVersion ( )

Definition at line 81 of file User.php.

81 : bool
82 {
83 $false = fn() => new Ok(false);
84 return $this->settings->validateOnLogin()->value() && $this->matchingDocument()->map($this->didNotAccept(...))->except($false)->value();
85 }
didNotAccept(Document $document)
Definition: User.php:167

References ILIAS\LegalDocuments\ConsumerToolbox\User\didNotAccept(), ILIAS\LegalDocuments\ConsumerToolbox\User\matchingDocument(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

◆ doesntMatch()

ILIAS\LegalDocuments\ConsumerToolbox\User::doesntMatch ( Document  $document)

Definition at line 100 of file User.php.

100 : bool
101 {
102 return !$this->legal_documents->document()->documentMatches($document, $this->user);
103 }

References ILIAS\Repository\user().

Referenced by ILIAS\LegalDocuments\ConsumerToolbox\User\needsToAcceptNewDocument().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ format()

ILIAS\LegalDocuments\ConsumerToolbox\User::format ( string  $format_string)

Definition at line 144 of file User.php.

144 : string
145 {
146 return str_ireplace('[BR]', "\n", sprintf(
147 $format_string,
148 $this->user->getFullname(),
149 $this->user->getLogin(),
150 $this->user->getExternalAccount()
151 ));
152 }

References ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ isExternalAccount()

ILIAS\LegalDocuments\ConsumerToolbox\User::isExternalAccount ( )

Definition at line 139 of file User.php.

139 : bool
140 {
141 return in_array((int) $this->authMode(), [ilAuthUtils::AUTH_PROVIDER_LTI, ilAuthUtils::AUTH_ECS], true);
142 }
const int AUTH_ECS
const int AUTH_PROVIDER_LTI

References ilAuthUtils\AUTH_ECS, ilAuthUtils\AUTH_PROVIDER_LTI, and ILIAS\LegalDocuments\ConsumerToolbox\User\authMode().

+ Here is the call graph for this function:

◆ isLDAPUser()

ILIAS\LegalDocuments\ConsumerToolbox\User::isLDAPUser ( )

Definition at line 134 of file User.php.

134 : bool
135 {
136 return $this->authMode() === (string) ilAuthUtils::AUTH_LDAP;
137 }
const int AUTH_LDAP

References ilAuthUtils\AUTH_LDAP, and ILIAS\LegalDocuments\ConsumerToolbox\User\authMode().

+ Here is the call graph for this function:

◆ isLoggedIn()

ILIAS\LegalDocuments\ConsumerToolbox\User::isLoggedIn ( )

Definition at line 50 of file User.php.

50 : bool
51 {
52 return !in_array($this->user->getId(), [ANONYMOUS_USER_ID, 0], true);
53 }

References ANONYMOUS_USER_ID, and ILIAS\Repository\user().

Referenced by ILIAS\DataProtection\Consumer\showMatchingDocument().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lazy()

ILIAS\LegalDocuments\ConsumerToolbox\User::lazy ( callable  $create_value)
private

@template A

Parameters
callable()A $create_value
Returns
Closure(): A

Definition at line 177 of file User.php.

177 : Closure
178 {
179 $proc = function () use (&$proc, $create_value) {
180 $value = $create_value();
181 $proc = fn() => $value;
182 return $value;
183 };
184 return function () use (&$proc) {
185 return $proc();
186 };
187 }

Referenced by ILIAS\LegalDocuments\ConsumerToolbox\User\__construct().

+ Here is the caller graph for this function:

◆ matchingDocument()

ILIAS\LegalDocuments\ConsumerToolbox\User::matchingDocument ( )

Definition at line 105 of file User.php.

105 : Result
106 {
107 return ($this->matching_document)();
108 }

Referenced by ILIAS\LegalDocuments\ConsumerToolbox\User\acceptMatchingDocument(), ILIAS\LegalDocuments\ConsumerToolbox\User\didNotAcceptCurrentVersion(), and ILIAS\DataProtection\Consumer\showMatchingDocument().

+ Here is the caller graph for this function:

◆ needsToAcceptNewDocument()

ILIAS\LegalDocuments\ConsumerToolbox\User::needsToAcceptNewDocument ( )

Definition at line 87 of file User.php.

87 : bool
88 {
89 if ($this->neverAgreed()) {
90 return true;
91 }
92
93 $true = fn() => new Ok(true);
94 $db = $this->legal_documents->history();
95
96 return $this->settings->validateOnLogin()->value()
97 && $db->currentDocumentOfAcceptedVersion($this->user)->map($this->doesntMatch(...))->except($true)->value();
98 }

References ILIAS\$db, ILIAS\LegalDocuments\ConsumerToolbox\User\doesntMatch(), ILIAS\LegalDocuments\ConsumerToolbox\User\neverAgreed(), ILIAS\Repository\settings(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ neverAgreed()

ILIAS\LegalDocuments\ConsumerToolbox\User::neverAgreed ( )

Definition at line 60 of file User.php.

60 : bool
61 {
62 return null === $this->agreeDate()->value();
63 }

References ILIAS\LegalDocuments\ConsumerToolbox\User\agreeDate().

Referenced by ILIAS\LegalDocuments\ConsumerToolbox\User\acceptedVersion(), and ILIAS\LegalDocuments\ConsumerToolbox\User\needsToAcceptNewDocument().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ raw()

ILIAS\LegalDocuments\ConsumerToolbox\User::raw ( )

Definition at line 154 of file User.php.

154 : ilObjUser
155 {
156 return $this->user;
157 }
User class.

◆ withdrawalRequested()

ILIAS\LegalDocuments\ConsumerToolbox\User::withdrawalRequested ( )
Returns
Setting<bool>

Definition at line 68 of file User.php.

68 : Setting
69 {
70 return $this->user_settings->withdrawalRequested();
71 }

Field Documentation

◆ $matching_document

readonly Closure ILIAS\LegalDocuments\ConsumerToolbox\User::$matching_document
private

Definition at line 38 of file User.php.


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