ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\TermsOfService\Consumer Class Reference
+ Inheritance diagram for ILIAS\TermsOfService\Consumer:
+ Collaboration diagram for ILIAS\TermsOfService\Consumer:

Public Member Functions

 __construct (?Container $container=null)
 
 id ()
 
 uses (UseSlot $slot, LazyProvide $provide)
 @template A More...
 
 uses (UseSlot $slot, LazyProvide $provide)
 @template A More...
 
 id ()
 

Data Fields

const ID = 'tos'
 
const GOTO_NAME = 'agreement'
 

Private Member Functions

 userHasWithdrawn ()
 
 usersWhoDidntAgree (ilDBInterface $database)
 

Private Attributes

readonly Container $container
 

Detailed Description

Definition at line 34 of file Consumer.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\TermsOfService\Consumer::__construct ( ?Container  $container = null)

Definition at line 41 of file Consumer.php.

42 {
43 $this->container = $container ?? $GLOBALS['DIC'] ?? new Container();
44 }
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
readonly Container $container
Definition: Consumer.php:36
$GLOBALS["DIC"]
Definition: wac.php:54

References ILIAS\TermsOfService\Consumer\$container, and $GLOBALS.

Member Function Documentation

◆ id()

ILIAS\TermsOfService\Consumer::id ( )

Implements ILIAS\LegalDocuments\Consumer.

Definition at line 46 of file Consumer.php.

46 : string
47 {
48 return self::ID;
49 }

References ILIAS\TermsOfService\Consumer\ID.

◆ userHasWithdrawn()

ILIAS\TermsOfService\Consumer::userHasWithdrawn ( )
private

Definition at line 83 of file Consumer.php.

83 : void
84 {
85 $this->container['ilAppEventHandler']->raise(
86 'components/ILIAS/TermsOfService',
87 'withdraw',
88 ['event' => $this->container->user()]
89 );
90 }

◆ usersWhoDidntAgree()

ILIAS\TermsOfService\Consumer::usersWhoDidntAgree ( ilDBInterface  $database)
private

Definition at line 92 of file Consumer.php.

92 : Closure
93 {
94 return function (array $users) use ($database): array {
95 $users = $database->in('usr_id', $users, false, ilDBConstants::T_INTEGER);
96 $result = $database->query('SELECT usr_id FROM usr_data WHERE agree_date IS NULL AND ' . $users);
97
98 return array_map(intval(...), array_column($database->fetchAll($result), 'usr_id'));
99 };
100 }
fetchAll(ilDBStatement $statement, int $fetch_mode=ilDBConstants::FETCHMODE_ASSOC)
query(string $query)
Run a (read-only) Query on the database.
in(string $field, array $values, bool $negate=false, string $type="")

References ilDBInterface\fetchAll(), ilDBInterface\in(), ilDBInterface\query(), and ilDBConstants\T_INTEGER.

+ Here is the call graph for this function:

◆ uses()

ILIAS\TermsOfService\Consumer::uses ( UseSlot  $slot,
LazyProvide  $provide 
)

@template A

Parameters
UseSlot<A>$slot
Returns
UseSlot

Implements ILIAS\LegalDocuments\Consumer.

Definition at line 51 of file Consumer.php.

51 : UseSlot
52 {
53 $blocks = new Blocks($this->id(), $this->container, $provide);
54 $default = $blocks->defaultMappings();
55 $global_settings = new Settings($blocks->selectSettingsFrom($blocks->readOnlyStore($blocks->globalStore())));
56 $is_active = $global_settings->enabled()->value();
57 $build_user = fn(ilObjUser $user) => $blocks->user($global_settings, new UserSettings($user, $blocks->selectSettingsFrom(
58 $blocks->userStore($user)
59 ), $this->container->refinery()), $user);
60 $public_api = new PublicApi($is_active, $build_user);
61 $slot = $slot->hasDocuments($default->contentAsComponent(), $default->conditionDefinitions())
62 ->hasHistory()
63 ->hasPublicApi($public_api);
64
65 if (!$is_active) {
66 return $slot->hasPublicPage($blocks->notAvailable(...), self::GOTO_NAME);
67 }
68
69 $user = $build_user($this->container->user());
70 $constraint = $this->container->refinery()->custom()->constraint(...);
71
72 return $slot->canWithdraw($blocks->slot()->withdrawProcess($user, $global_settings, $this->userHasWithdrawn(...)))
73 ->hasAgreement($blocks->slot()->agreement($user), self::GOTO_NAME)
74 ->showInFooter($blocks->slot()->modifyFooter($user, self::GOTO_NAME))
75 ->showOnLoginPage($blocks->slot()->showOnLoginPage())
76 ->onSelfRegistration($blocks->slot()->selfRegistration($user, $build_user))
77 ->hasOnlineStatusFilter($blocks->slot()->onlineStatusFilter($this->usersWhoDidntAgree($this->container->database())))
78 ->hasUserManagementFields($blocks->userManagementAgreeDateField($build_user, 'tos_agree_date', 'tos'))
79 ->canReadInternalMails($blocks->slot()->canReadInternalMails($build_user))
80 ->canUseSoapApi($constraint(fn($u) => !$public_api->needsToAgree($u), 'TOS not accepted.'));
81 }
User class.
hasPublicPage(callable $public_page, ?string $goto_name=null)
hasDocuments(array $content_as_component=[], ?SelectionMap $available_conditions=null)
canWithdraw(WithdrawProcess $withdraw_process)

References ILIAS\LegalDocuments\UseSlot\canWithdraw(), ILIAS\LegalDocuments\UseSlot\hasDocuments(), and ILIAS\LegalDocuments\UseSlot\hasPublicPage().

+ Here is the call graph for this function:

Field Documentation

◆ $container

readonly Container ILIAS\TermsOfService\Consumer::$container
private

Definition at line 36 of file Consumer.php.

Referenced by ILIAS\TermsOfService\Consumer\__construct().

◆ GOTO_NAME

const ILIAS\TermsOfService\Consumer::GOTO_NAME = 'agreement'

Definition at line 39 of file Consumer.php.

◆ ID

const ILIAS\TermsOfService\Consumer::ID = 'tos'

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