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

Public Member Functions

 __construct (private readonly User $user, private readonly UI $ui, private readonly Routing $routing, private readonly Closure $with_request)
 
 showAgreement (string $gui, string $cmd)
 
 showAgreementForm (string $gui, string $cmd)
 
 needsToAgree ()
 
 showAgreement (string $gui, string $cmd)
 
 showAgreementForm (string $gui, string $cmd)
 
 needsToAgree ()
 

Private Member Functions

 showDocument ()
 
 agreementForm (string $gui, string $cmd)
 
 logoutLink ()
 

Detailed Description

Definition at line 37 of file Agreement.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\LegalDocuments\ConsumerToolbox\ConsumerSlots\Agreement::__construct ( private readonly User  $user,
private readonly UI  $ui,
private readonly Routing  $routing,
private readonly Closure  $with_request 
)
Parameters
Closure(Form,Closure(array)void): Form $with_request

Definition at line 42 of file Agreement.php.

47 {
48 }

Member Function Documentation

◆ agreementForm()

ILIAS\LegalDocuments\ConsumerToolbox\ConsumerSlots\Agreement::agreementForm ( string  $gui,
string  $cmd 
)
private

Definition at line 95 of file Agreement.php.

95 : Component
96 {
97 $url = $this->routing->ctrl()->getFormActionByClass($gui, $cmd);
98 $form = $this->ui->create()->input()->container()->form()->standard($url, [
99 'accept?' => $this->ui->create()->input()->field()->radio($this->ui->txt('accept_usr_agreement'))
100 ->withOption('yes', $this->ui->txt('accept_usr_agreement_btn'))
101 ->withOption('no', $this->ui->txt('deny_usr_agreement_btn'))
102 ]);
103
104 return ($this->with_request)($form, function (array $data) {
105 $accept = $data['accept?'] ?? '';
106 if ($accept === 'no') {
107 $this->routing->ctrl()->redirectToURL($this->routing->logoutUrl());
108 } elseif ($accept === 'yes') {
109 $this->user->acceptMatchingDocument();
110 $this->routing->redirectToOriginalTarget();
111 }
112 });
113 }
$accept
Definition: ltiservices.php:66
$url
Definition: shib_logout.php:68

References $accept, $data, $url, ILIAS\Repository\ui(), and ILIAS\Repository\user().

Referenced by ILIAS\LegalDocuments\ConsumerToolbox\ConsumerSlots\Agreement\showAgreementForm().

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

◆ logoutLink()

ILIAS\LegalDocuments\ConsumerToolbox\ConsumerSlots\Agreement::logoutLink ( )
private

Definition at line 115 of file Agreement.php.

115 : Component
116 {
117 return $this->ui->create()->button()->standard($this->ui->txt('logout'), $this->routing->logoutUrl());
118 }

References ILIAS\Repository\ui().

+ Here is the call graph for this function:

◆ needsToAgree()

ILIAS\LegalDocuments\ConsumerToolbox\ConsumerSlots\Agreement::needsToAgree ( )

Implements ILIAS\LegalDocuments\ConsumerSlots\Agreement.

Definition at line 78 of file Agreement.php.

78 : bool
79 {
80 return !$this->user->cannotAgree()
81 && $this->user->needsToAcceptNewDocument();
82 }

References ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ showAgreement()

ILIAS\LegalDocuments\ConsumerToolbox\ConsumerSlots\Agreement::showAgreement ( string  $gui,
string  $cmd 
)

Implements ILIAS\LegalDocuments\ConsumerSlots\Agreement.

Definition at line 50 of file Agreement.php.

50 : PageFragment
51 {
52 $title = 'accept_usr_agreement_anonymous';
53 $info = 'accept_usr_agreement_anonymous_intro';
54 if ($this->user->isLoggedIn()) {
55 $title = 'usr_agreement';
56 $info = 'usr_agreement_footer_intro';
57 }
58 return (new PageContent($this->ui->txt($title), [$this->showDocument()]))->withOnScreenMessage('info', $this->ui->txt($info));
59 }
$info
Definition: entry_point.php:21

References $info, ILIAS\Repository\ui(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ showAgreementForm()

ILIAS\LegalDocuments\ConsumerToolbox\ConsumerSlots\Agreement::showAgreementForm ( string  $gui,
string  $cmd 
)

Implements ILIAS\LegalDocuments\ConsumerSlots\Agreement.

Definition at line 61 of file Agreement.php.

61 : PageFragment
62 {
63 $form = $this->user->matchingDocument()->isOk() ?
64 $this->agreementForm($gui, $cmd) :
65 $this->ui->create()->divider()->horizontal();
66
67 $content = (new PageContent($this->ui->txt('accept_usr_agreement'), [
68 $this->showDocument(),
69 $form,
70 $this->logoutLink(),
71 ]));
72
73 return $this->user->matchingDocument()->isOk() ?
74 $content->withOnScreenMessage('info', $this->ui->txt('accept_usr_agreement_intro')) :
75 $content;
76 }

References ILIAS\LegalDocuments\ConsumerToolbox\ConsumerSlots\Agreement\agreementForm(), ILIAS\Repository\ui(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ showDocument()

ILIAS\LegalDocuments\ConsumerToolbox\ConsumerSlots\Agreement::showDocument ( )
private

Definition at line 84 of file Agreement.php.

84 : Component
85 {
86 return $this->user
87 ->matchingDocument()
88 ->map(fn(Document $document) => $this->ui->create()->legacy()->content($document->content()->value()))
89 ->except(fn() => new Ok($this->ui->create()->legacy()->content(sprintf(
90 $this->ui->txt('no_agreement_description'),
92 ))))->value();
93 }
static prepareFormOutput($a_str, bool $a_strip=false)
static getMailsToAddress()
Get mailto: emails.

References ILIAS\LegalDocuments\Value\Document\content(), ilSystemSupportContacts\getMailsToAddress(), ilLegacyFormElementsUtil\prepareFormOutput(), ILIAS\Repository\ui(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

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