ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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)
 A More...
 

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.

References $GLOBALS.

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

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  }

◆ userHasWithdrawn()

ILIAS\TermsOfService\Consumer::userHasWithdrawn ( )
private

Definition at line 83 of file Consumer.php.

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

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

◆ usersWhoDidntAgree()

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

Definition at line 92 of file Consumer.php.

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

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

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="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ uses()

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

A

Parameters
UseSlot<A>$slot
Returns
UseSlot

Implements ILIAS\LegalDocuments\Consumer.

Definition at line 51 of file Consumer.php.

References ILIAS\LegalDocuments\UseSlot\canWithdraw(), ILIAS\LegalDocuments\UseSlot\hasDocuments(), ILIAS\LegalDocuments\UseSlot\hasPublicPage(), ILIAS\TermsOfService\Consumer\userHasWithdrawn(), and ILIAS\TermsOfService\Consumer\usersWhoDidntAgree().

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  }
usersWhoDidntAgree(ilDBInterface $database)
Definition: Consumer.php:92
+ 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.

◆ GOTO_NAME

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

Definition at line 39 of file Consumer.php.

◆ ID

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

Definition at line 38 of file Consumer.php.

Referenced by ILIAS\TermsOfService\test\ConsumerTest\testId().


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