ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjLTIConsumerVerificationGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
31{
32 public function getType(): string
33 {
34 return "ltiv";
35 }
36
40 public function create(): void
41 {
42 global $DIC; /* @var \ILIAS\DI\Container $DIC */
43
44 $this->lng->loadLanguageModule("ltiv");
45
46 $DIC->tabs()->setBackTarget(
47 $this->lng->txt("back"),
48 $this->ctrl->getLinkTarget($this, "cancel")
49 );
50 $table = new ilLTIConsumerVerificationTableGUI($this, "create");
51 $this->tpl->setContent($table->getHTML());
52 }
53
57 public function save(): void
58 {
59 global $DIC; /* @var \ILIAS\DI\Container $DIC */
60
61 $objId = $this->getRequestValue("lti_id");
62
63 if ($objId) {
64 $certificateVerificationFileService = new ilCertificateVerificationFileService(
65 $DIC->language(),
66 $DIC->database(),
67 $DIC->logger()->root(),
69 );
70
71 $userCertificateRepository = new ilUserCertificateRepository();
72
73 $userCertificatePresentation = $userCertificateRepository->fetchActiveCertificateForPresentation(
74 $DIC->user()->getId(),
75 (int) $objId
76 );
77
78 try {
79 $newObj = $certificateVerificationFileService->createFile($userCertificatePresentation);
80 } catch (\Exception $exception) {
81 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('error_creating_certificate_pdf'));
82 $this->create();
83 return;
84 }
85
86 if ($newObj !== null) {
88 $this->node_id = null;
89 $this->putObjectInTree($newObj, $parent_id);
90
91 $this->afterSave($newObj);
92 } else {
93 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("msg_failed"));
94 }
95 } else {
96 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("select_one"));
97 }
98
99 $this->create();
100 }
101
102 public function deliver(): void
103 {
104 $file = $this->object->getFilePath();
105
106 if ($file) {
107 ilFileDelivery::deliverFileLegacy($file, $this->object->getTitle() . ".pdf");
108 }
109 }
110
114 public function render(bool $a_return = false, bool $a_url = false): string
115 {
116 global $DIC; /* @var \ILIAS\DI\Container $DIC */
117 $message = '';
118
119 if (!$a_return) {
120 $this->deliver();
121 } else {
122 $tree = new ilWorkspaceTree($DIC->user()->getId());
123 $wsp_id = $tree->lookupNodeId($this->object->getId());
124
125 $caption = $DIC->language()->txt("wsp_type_ltiv") . ' "' . $this->object->getTitle() . '"';
126
127 $valid = true;
128 if (!file_exists($this->object->getFilePath())) {
129 $valid = false;
130 $message = $DIC->language()->txt("url_not_found");
131 } elseif (!$a_url) {
133 if (!$access_handler->checkAccess("read", "", $wsp_id)) {
134 $valid = false;
135 $message = $DIC->language()->txt("permission_denied");
136 }
137 }
138
139 if ($valid) {
140 if (!$a_url) {
141 $a_url = $this->getAccessHandler()->getGotoLink($wsp_id, $this->object->getId());
142 }
143 return '<div><a href="' . $a_url . '">' . $caption . '</a></div>';
144 } else {
145 return '<div>' . $caption . ' (' . $message . ')</div>';
146 }
147 }
148 return '';
149 }
150
151 public function downloadFromPortfolioPage(ilPortfolioPage $a_page): void
152 {
153 global $DIC;
154 if (ilPCVerification::isInPortfolioPage($a_page, $this->object->getType(), $this->object->getId())) {
155 $this->deliver();
156 }
157
158 $DIC['ilErr']->raiseError($this->lng->txt('permission_denied'), $DIC['ilErr']->MESSAGE);
159 }
160
161 public static function _goto($a_target): void
162 {
163 global $DIC;
164 $ctrl = $DIC->ctrl();
165 $id = explode("_", $a_target);
166
168 "ilsharedresourceGUI",
169 "wsp_id",
170 $id[0]
171 );
172 $ctrl->redirectByClass(ilSharedResourceGUI::class);
173 }
174
175 protected function getRequestValue(string $key): ?string
176 {
177 if ($this->request_wrapper->has($key)) {
178 return $this->request_wrapper->retrieve($key, $this->refinery->kindlyTo()->string());
179 }
180 if ($this->post_wrapper->has($key)) {
181 return $this->post_wrapper->retrieve($key, $this->refinery->kindlyTo()->string());
182 }
183 return null;
184 }
185}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
redirectByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
@inheritDoc
setParameterByClass(string $a_class, string $a_parameter, $a_value)
@inheritDoc
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
create()
List all tests in which current user participated.
render(bool $a_return=false, bool $a_url=false)
Render content.
getType()
Functions that must be overwritten.
New implementation of ilObjectGUI.
putObjectInTree(ilObject $obj, ?int $parent_node_id=null)
Add object to tree at given position.
afterSave(ilObject $new_object)
Post (successful) object creation hook.
static isInPortfolioPage(ilPortfolioPage $a_page, string $a_type, int $a_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$valid
global $DIC
Definition: shib_login.php:26
$message
Definition: xapiexit.php:31
$objId
Definition: xapitoken.php:57