ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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
 
readonly Closure $lazy_users
 

Detailed Description

Definition at line 34 of file Consumer.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 42 of file Consumer.php.

References $GLOBALS.

43  {
44  $this->container = $container ?? $GLOBALS['DIC'];
45  }
$GLOBALS["DIC"]
Definition: wac.php:31
readonly Container $container
Definition: Consumer.php:36

Member Function Documentation

◆ id()

ILIAS\TermsOfService\Consumer::id ( )

Implements ILIAS\LegalDocuments\Consumer.

Definition at line 47 of file Consumer.php.

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

◆ userHasWithdrawn()

ILIAS\TermsOfService\Consumer::userHasWithdrawn ( )
private

Definition at line 84 of file Consumer.php.

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

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

◆ usersWhoDidntAgree()

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

Definition at line 93 of file Consumer.php.

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

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

93  : Closure
94  {
95  return function (array $users) use ($database): array {
96  $users = $database->in('usr_id', $users, false, ilDBConstants::T_INTEGER);
97  $result = $database->query('SELECT usr_id FROM usr_data WHERE agree_date IS NULL AND ' . $users);
98 
99  return array_map(intval(...), array_column($database->fetchAll($result), 'usr_id'));
100  };
101  }
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>$lens
Returns
UseSlot

Implements ILIAS\LegalDocuments\Consumer.

Definition at line 52 of file Consumer.php.

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

52  : UseSlot
53  {
54  $blocks = new Blocks($this->id(), $this->container, $provide);
55  $default = $blocks->defaultMappings();
56  $global_settings = new Settings($blocks->selectSettingsFrom($blocks->readOnlyStore($blocks->globalStore())));
57  $is_active = $global_settings->enabled()->value();
58  $build_user = fn(ilObjUser $user) => $blocks->user($global_settings, new UserSettings($user, $blocks->selectSettingsFrom(
59  $blocks->userStore($user)
60  ), $this->container->refinery()), $user);
61  $public_api = new PublicApi($is_active, $build_user);
62  $slot = $slot->hasDocuments($default->contentAsComponent(), $default->conditionDefinitions())
63  ->hasHistory()
64  ->hasPublicApi($public_api);
65 
66  if (!$is_active) {
67  return $slot->hasPublicPage($blocks->notAvailable(...), self::GOTO_NAME);
68  }
69 
70  $user = $build_user($this->container->user());
71  $constraint = $this->container->refinery()->custom()->constraint(...);
72 
73  return $slot->canWithdraw($blocks->slot()->withdrawProcess($user, $global_settings, $this->userHasWithdrawn(...)))
74  ->hasAgreement($blocks->slot()->agreement($user, $global_settings), self::GOTO_NAME)
75  ->showInFooter($blocks->slot()->modifyFooter($user, self::GOTO_NAME))
76  ->showOnLoginPage($blocks->slot()->showOnLoginPage())
77  ->onSelfRegistration($blocks->slot()->selfRegistration($user, $build_user))
78  ->hasOnlineStatusFilter($blocks->slot()->onlineStatusFilter($this->usersWhoDidntAgree($this->container->database())))
79  ->hasUserManagementFields($blocks->userManagementAgreeDateField($build_user, 'tos_agree_date', 'tos'))
80  ->canReadInternalMails($blocks->slot()->canReadInternalMails($build_user))
81  ->canUseSoapApi($constraint(fn($u) => !$public_api->needsToAgree($u), 'TOS not accepted.'));
82  }
usersWhoDidntAgree(ilDBInterface $database)
Definition: Consumer.php:93
+ 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.

◆ $lazy_users

readonly Closure ILIAS\TermsOfService\Consumer::$lazy_users
private

Definition at line 37 of file Consumer.php.

◆ GOTO_NAME

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

Definition at line 40 of file Consumer.php.

◆ ID

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

Definition at line 39 of file Consumer.php.

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


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