ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjCmiXapiVerificationGUI.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 "cmxv";
35 }
36
40 public function create(): void
41 {
42 global $ilTabs;
43
44 $this->lng->loadLanguageModule("cmxv");
45
46 $ilTabs->setBackTarget(
47 $this->lng->txt("back"),
48 $this->ctrl->getLinkTarget($this, "cancel")
49 );
50 $table = new ilCmiXapiVerificationTableGUI($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("cmix_id");
62 if ($objId) {
63 $certificateVerificationFileService = new ilCertificateVerificationFileService(
64 $DIC->language(),
65 $DIC->database(),
66 $DIC->logger()->root(),
68 );
69
70 $userCertificateRepository = new ilUserCertificateRepository();
71
72 $userCertificatePresentation = $userCertificateRepository->fetchActiveCertificateForPresentation(
73 $DIC->user()->getId(),
74 (int) $objId
75 );
76
77 $newObj = null;
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 }
84
85 if ($newObj !== null) {
87 $this->node_id = null;
88 $this->putObjectInTree($newObj, $parent_id);
89
90 $this->afterSave($newObj);
91 } else {
92 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("msg_failed"));
93 }
94 } else {
95 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("select_one"));
96 }
97
98 $this->create();
99 }
100
101 public function deliver(): void
102 {
103 $file = $this->object->getFilePath();
104
105 if ($file) {
106 ilFileDelivery::deliverFileLegacy($file, $this->object->getTitle() . ".pdf");
107 }
108 }
109
113 public function render(bool $a_return = false, bool $a_url = false): string
114 {
115 global $ilUser, $lng;
116
117 if (!$a_return) {
118 $this->deliver();
119 return "";
120 } else {
121 $tree = new ilWorkspaceTree($ilUser->getId());
122 $wsp_id = $tree->lookupNodeId($this->object->getId());
123
124 $caption = $lng->txt("wsp_type_cmxv") . ' "' . $this->object->getTitle() . '"';
125
126 $valid = true;
127 $message = '';
128 if (!file_exists($this->object->getFilePath())) {
129 $valid = false;
130 $message = $lng->txt("url_not_found");
131 } elseif (!$a_url) {
133 if (!$access_handler->checkAccess("read", "", $wsp_id)) {
134 $valid = false;
135 $message = $lng->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 }
149
150 public function downloadFromPortfolioPage(ilPortfolioPage $a_page): void
151 {
152 global $ilErr;
153 if (ilPCVerification::isInPortfolioPage($a_page, $this->object->getType(), $this->object->getId())) {
154 $this->deliver();
155 }
156
157 $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->MESSAGE);
158 }
159
160 public static function _goto($a_target): void
161 {
162 global $DIC;
163 $ctrl = $DIC->ctrl();
164 $id = explode("_", $a_target);
165
167 "ilsharedresourceGUI",
168 "wsp_id",
169 $id[0]
170 );
171 $ctrl->redirectByClass(ilSharedResourceGUI::class);
172 }
173
179 protected function getRequestValue(string $key, mixed $default = null): mixed
180 {
181 if (isset($this->request->getQueryParams()[$key])) {
182 return $this->request->getQueryParams()[$key];
183 }
184
185 if (isset($this->request->getParsedBody()[$key])) {
186 return $this->request->getParsedBody()[$key];
187 }
188
189 return $default ?? null;
190 }
191}
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)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
save()
create new instance and save it
create()
List all tests in which current user participated.
getType()
Functions that must be overwritten.
render(bool $a_return=false, bool $a_url=false)
Render content.
getRequestValue(string $key, mixed $default=null)
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
$ilErr
Definition: raiseError.php:33
global $DIC
Definition: shib_login.php:26
$message
Definition: xapiexit.php:31
$objId
Definition: xapitoken.php:57