ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilObjLTIConsumerVerificationGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5
16{
17 public function getType()
18 {
19 return "ltiv";
20 }
21
25 public function create()
26 {
27 global $ilTabs;
28
29 if ($this->id_type == self::WORKSPACE_NODE_ID) {
30 include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
32 $this->lng->loadLanguageModule("file");
33 ilUtil::sendFailure($this->lng->txt("personal_workspace_quota_exceeded_warning"), true);
34 $this->ctrl->redirect($this, "cancel");
35 }
36 }
37
38 $this->lng->loadLanguageModule("ltiv");
39
40 $ilTabs->setBackTarget(
41 $this->lng->txt("back"),
42 $this->ctrl->getLinkTarget($this, "cancel")
43 );
44
45 include_once "Modules/Course/classes/Verification/class.ilCourseVerificationTableGUI.php";
46 $table = new ilLTIConsumerVerificationTableGUI($this, "create");
47 $this->tpl->setContent($table->getHTML());
48 }
49
53 public function save()
54 {
55 global $DIC; /* @var \ILIAS\DI\Container $DIC */
56
57 $objId = $_REQUEST["lti_id"];
58 if ($objId) {
59 $certificateVerificationFileService = new ilCertificateVerificationFileService(
60 $DIC->language(),
61 $DIC->database(),
62 $DIC->logger()->root(),
64 );
65
66 $userCertificateRepository = new ilUserCertificateRepository();
67
68 $userCertificatePresentation = $userCertificateRepository->fetchActiveCertificateForPresentation(
69 (int) $DIC->user()->getId(),
70 (int) $objId
71 );
72
73 try {
74 $newObj = $certificateVerificationFileService->createFile($userCertificatePresentation);
75 } catch (\Exception $exception) {
76 ilUtil::sendFailure($this->lng->txt('error_creating_certificate_pdf'));
77 return $this->create();
78 }
79
80 if ($newObj) {
82 $this->node_id = null;
83 $this->putObjectInTree($newObj, $parent_id);
84
85 $this->afterSave($newObj);
86 } else {
87 ilUtil::sendFailure($this->lng->txt("msg_failed"));
88 }
89 } else {
90 ilUtil::sendFailure($this->lng->txt("select_one"));
91 }
92
93 $this->create();
94 }
95
96 public function deliver()
97 {
98 $file = $this->object->getFilePath();
99
100 if ($file) {
101 ilUtil::deliverFile($file, $this->object->getTitle() . ".pdf");
102 }
103 }
104
111 public function render($a_return = false, $a_url = false)
112 {
113 global $ilUser, $lng;
114
115 if (!$a_return) {
116 $this->deliver();
117 } else {
118 $tree = new ilWorkspaceTree($ilUser->getId());
119 $wsp_id = $tree->lookupNodeId($this->object->getId());
120
121 $caption = $lng->txt("wsp_type_ltiv") . ' "' . $this->object->getTitle() . '"';
122
123 $valid = true;
124 if (!file_exists($this->object->getFilePath())) {
125 $valid = false;
126 $message = $lng->txt("url_not_found");
127 } elseif (!$a_url) {
128 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
130 if (!$access_handler->checkAccess("read", "", $wsp_id)) {
131 $valid = false;
132 $message = $lng->txt("permission_denied");
133 }
134 }
135
136 if ($valid) {
137 if (!$a_url) {
138 $a_url = $this->getAccessHandler()->getGotoLink($wsp_id, $this->object->getId());
139 }
140 return '<div><a href="' . $a_url . '">' . $caption . '</a></div>';
141 } else {
142 return '<div>' . $caption . ' (' . $message . ')</div>';
143 }
144 }
145 }
146
148 {
149 global $ilErr;
150
151 include_once "Services/COPage/classes/class.ilPCVerification.php";
152 if (ilPCVerification::isInPortfolioPage($a_page, $this->object->getType(), $this->object->getId())) {
153 $this->deliver();
154 }
155
156 $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->MESSAGE);
157 }
158
159 public static function _goto($a_target)
160 {
161 $id = explode("_", $a_target);
162
163 $_GET["baseClass"] = "ilsharedresourceGUI";
164 $_GET["wsp_id"] = $id[0];
165 include("ilias.php");
166 exit;
167 }
168}
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
static isUploadPossible($a_additional_size=null)
render($a_return=false, $a_url=false)
Render content.
create()
List all tests in which current user participated.
getType()
Functions that must be overwritten.
New implementation of ilObjectGUI.
getAccessHandler()
Get access handler.
putObjectInTree(ilObject $a_obj, $a_parent_node_id=null)
Add object to tree at given position.
afterSave(ilObject $a_new_object)
Post (successful) object creation hook.
static isInPortfolioPage(ilPortfolioPage $a_page, $a_type, $a_id)
Page for user portfolio.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
Access handler for personal workspace.
Tree handler for personal workspace.
$valid
exit
Definition: login.php:29
$ilUser
Definition: imgupload.php:18
$message
Definition: xapiexit.php:14
$DIC
Definition: xapitoken.php:46
$objId
Definition: xapitoken.php:41