ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\DataProtection\Consumer Class Reference
+ Inheritance diagram for ILIAS\DataProtection\Consumer:
+ Collaboration diagram for ILIAS\DataProtection\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 = 'dpro'
 
const GOTO_NAME = 'data_protection'
 

Private Member Functions

 showMatchingDocument (User $user, UI $ui, Provide $legal_documents)
 
 userHasWithdrawn ()
 
 usersWhoDidntAgree (ilDBInterface $database)
 

Private Attributes

readonly Container $container
 

Detailed Description

Definition at line 42 of file Consumer.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 49 of file Consumer.php.

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

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

Member Function Documentation

◆ id()

ILIAS\DataProtection\Consumer::id ( )

Implements ILIAS\LegalDocuments\Consumer.

Definition at line 54 of file Consumer.php.

54 : string
55 {
56 return self::ID;
57 }

References ILIAS\DataProtection\Consumer\ID.

◆ showMatchingDocument()

ILIAS\DataProtection\Consumer::showMatchingDocument ( User  $user,
UI  $ui,
Provide  $legal_documents 
)
private

Definition at line 101 of file Consumer.php.

101 : Closure
102 {
103 return function (Closure $footer) use ($user, $ui, $legal_documents) {
104 $in_footer = fn($v) => $footer('usr_agreement', $ui->txt('usr_agreement'), $v);
105 if (!$user->isLoggedIn()) {
106 return $in_footer(new URI(ilLink::_getLink(null, 'usr', [], self::GOTO_NAME)));
107 }
108 if ($user->cannotAgree()) {
109 return $footer;
110 }
111
112 $render = fn(Document $document): Closure => $in_footer($ui->create()->modal()->roundtrip(
113 $document->content()->title(),
114 [$legal_documents->document()->contentAsComponent($document->content())]
115 ));
116
117 return $user->matchingDocument()
118 ->map($render)
119 ->except(fn() => new Ok($footer))->value();
120 };
121 }
modal(string $title="", string $cancel_label="")

References ILIAS\LegalDocuments\ConsumerToolbox\User\cannotAgree(), ILIAS\LegalDocuments\Value\Document\content(), ILIAS\LegalDocuments\ConsumerToolbox\UI\create(), ILIAS\LegalDocuments\Provide\document(), ILIAS\LegalDocuments\ConsumerToolbox\User\isLoggedIn(), ILIAS\LegalDocuments\ConsumerToolbox\User\matchingDocument(), and ILIAS\LegalDocuments\ConsumerToolbox\UI\txt().

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

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

◆ userHasWithdrawn()

ILIAS\DataProtection\Consumer::userHasWithdrawn ( )
private

Definition at line 123 of file Consumer.php.

123 : void
124 {
125 $this->container['ilAppEventHandler']->raise(
126 'components/ILIAS/DataProtection',
127 'withdraw',
128 ['event' => $this->container->user()]
129 );
130 }

◆ usersWhoDidntAgree()

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

Definition at line 132 of file Consumer.php.

132 : Closure
133 {
134 return function (array $users) use ($database): array {
135 $users = $database->in('usr_id', $users, false, ilDBConstants::T_INTEGER);
136 $result = $database->query(
137 'SELECT usr_id FROM usr_pref WHERE keyword = "dpro_agree_date" AND (value IS NULL OR value = "false" OR value = "") AND ' . $users
138 );
139
140 return array_map(intval(...), array_column($database->fetchAll($result), 'usr_id'));
141 };
142 }
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\DataProtection\Consumer::uses ( UseSlot  $slot,
LazyProvide  $provide 
)

@template A

Parameters
UseSlot<A>$slot
Returns
UseSlot

Implements ILIAS\LegalDocuments\Consumer.

Definition at line 59 of file Consumer.php.

59 : UseSlot
60 {
61 $blocks = new Blocks($this->id(), $this->container, $provide);
62 $default = $blocks->defaultMappings();
63 $global_settings = new Settings($blocks->selectSettingsFrom($blocks->readOnlyStore($blocks->globalStore())));
64 $is_active = $global_settings->enabled()->value();
65 $build_user = fn(ilObjUser $user) => $blocks->user($global_settings, new UserSettings(
66 $blocks->selectSettingsFrom($blocks->userStore($user))
67 ), $user);
68 $public_api = new PublicApi($is_active, $build_user);
69 $slot = $slot->hasDocuments($default->contentAsComponent(), $default->conditionDefinitions())
70 ->hasHistory()
71 ->hasPublicApi($public_api);
72
73 if (!$is_active) {
74 return $slot->hasPublicPage($blocks->notAvailable(...), self::GOTO_NAME);
75 }
76
77 $user = $build_user($this->container->user());
78
79 $slot = $slot->showOnLoginPage($blocks->slot()->showOnLoginPage());
80
81 $agreement = $blocks->slot()->agreement($user);
82 $constraint = $this->container->refinery()->custom()->constraint(...);
83
84 if ($global_settings->noAcceptance()->value()) {
85 $slot = $slot->showInFooter($this->showMatchingDocument($user, $blocks->ui(), $provide))
86 ->hasPublicPage($agreement->showAgreement(...), self::GOTO_NAME);
87 } else {
88 $slot = $slot->canWithdraw($blocks->slot()->withdrawProcess($user, $global_settings, $this->userHasWithdrawn(...)))
89 ->hasAgreement($agreement, self::GOTO_NAME)
90 ->showInFooter($blocks->slot()->modifyFooter($user, self::GOTO_NAME))
91 ->onSelfRegistration($blocks->slot()->selfRegistration($user, $build_user))
92 ->hasOnlineStatusFilter($blocks->slot()->onlineStatusFilter($this->usersWhoDidntAgree($this->container->database())))
93 ->hasUserManagementFields($blocks->userManagementAgreeDateField($build_user, 'dpro_agree_date', 'dpro'))
94 ->canReadInternalMails($blocks->slot()->canReadInternalMails($build_user))
95 ->canUseSoapApi($constraint(fn($u) => !$public_api->needsToAgree($u), 'Data Protection not agreed.'));
96 }
97
98 return $slot;
99 }
showMatchingDocument(User $user, UI $ui, Provide $legal_documents)
Definition: Consumer.php:101
User class.
showInFooter(callable $show)
hasPublicPage(callable $public_page, ?string $goto_name=null)
hasDocuments(array $content_as_component=[], ?SelectionMap $available_conditions=null)
canWithdraw(WithdrawProcess $withdraw_process)
showOnLoginPage(callable $show)

References ILIAS\LegalDocuments\UseSlot\canWithdraw(), ILIAS\LegalDocuments\UseSlot\hasDocuments(), ILIAS\LegalDocuments\UseSlot\hasPublicPage(), ILIAS\LegalDocuments\UseSlot\showInFooter(), ILIAS\DataProtection\Consumer\showMatchingDocument(), and ILIAS\LegalDocuments\UseSlot\showOnLoginPage().

+ Here is the call graph for this function:

Field Documentation

◆ $container

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

Definition at line 47 of file Consumer.php.

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

◆ GOTO_NAME

const ILIAS\DataProtection\Consumer::GOTO_NAME = 'data_protection'

Definition at line 45 of file Consumer.php.

◆ ID

const ILIAS\DataProtection\Consumer::ID = 'dpro'

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