ILIAS  release_7 Revision v7.30-3-g800a261c036
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 $DIC; /* @var \ILIAS\DI\Container $DIC */
28
29 $this->lng->loadLanguageModule("ltiv");
30
31 $DIC->tabs()->setBackTarget(
32 $this->lng->txt("back"),
33 $this->ctrl->getLinkTarget($this, "cancel")
34 );
35
36 include_once "Modules/Course/classes/Verification/class.ilCourseVerificationTableGUI.php";
37 $table = new ilLTIConsumerVerificationTableGUI($this, "create");
38 $this->tpl->setContent($table->getHTML());
39 }
40
44 public function save()
45 {
46 global $DIC; /* @var \ILIAS\DI\Container $DIC */
47
48 $objId = $_REQUEST["lti_id"];
49 if ($objId) {
50 $certificateVerificationFileService = new ilCertificateVerificationFileService(
51 $DIC->language(),
52 $DIC->database(),
53 $DIC->logger()->root(),
55 );
56
57 $userCertificateRepository = new ilUserCertificateRepository();
58
59 $userCertificatePresentation = $userCertificateRepository->fetchActiveCertificateForPresentation(
60 (int) $DIC->user()->getId(),
61 (int) $objId
62 );
63
64 try {
65 $newObj = $certificateVerificationFileService->createFile($userCertificatePresentation);
66 } catch (\Exception $exception) {
67 ilUtil::sendFailure($this->lng->txt('error_creating_certificate_pdf'));
68 return $this->create();
69 }
70
71 if ($newObj) {
73 $this->node_id = null;
74 $this->putObjectInTree($newObj, $parent_id);
75
76 $this->afterSave($newObj);
77 } else {
78 ilUtil::sendFailure($this->lng->txt("msg_failed"));
79 }
80 } else {
81 ilUtil::sendFailure($this->lng->txt("select_one"));
82 }
83
84 $this->create();
85 }
86
87 public function deliver()
88 {
89 $file = $this->object->getFilePath();
90
91 if ($file) {
92 ilUtil::deliverFile($file, $this->object->getTitle() . ".pdf");
93 }
94 }
95
102 public function render($a_return = false, $a_url = false)
103 {
104 global $DIC; /* @var \ILIAS\DI\Container $DIC */
105
106 if (!$a_return) {
107 $this->deliver();
108 } else {
109 $tree = new ilWorkspaceTree($DIC->user()->getId());
110 $wsp_id = $tree->lookupNodeId($this->object->getId());
111
112 $caption = $DIC->language()->txt("wsp_type_ltiv") . ' "' . $this->object->getTitle() . '"';
113
114 $valid = true;
115 if (!file_exists($this->object->getFilePath())) {
116 $valid = false;
117 $message = $DIC->language()->txt("url_not_found");
118 } elseif (!$a_url) {
119 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
121 if (!$access_handler->checkAccess("read", "", $wsp_id)) {
122 $valid = false;
123 $message = $DIC->language()->txt("permission_denied");
124 }
125 }
126
127 if ($valid) {
128 if (!$a_url) {
129 $a_url = $this->getAccessHandler()->getGotoLink($wsp_id, $this->object->getId());
130 }
131 return '<div><a href="' . $a_url . '">' . $caption . '</a></div>';
132 } else {
133 return '<div>' . $caption . ' (' . $message . ')</div>';
134 }
135 }
136 }
137
139 {
140 global $DIC; /* @var \ILIAS\DI\Container $DIC */
141
142 include_once "Services/COPage/classes/class.ilPCVerification.php";
143 if (ilPCVerification::isInPortfolioPage($a_page, $this->object->getType(), $this->object->getId())) {
144 $this->deliver();
145 }
146
147 $DIC['ilErr']->raiseError($this->lng->txt('permission_denied'), $DIC['ilErr']->MESSAGE);
148 }
149
150 public static function _goto($a_target)
151 {
152 $id = explode("_", $a_target);
153
154 $_GET["baseClass"] = "ilsharedresourceGUI";
155 $_GET["wsp_id"] = $id[0];
156 include("ilias.php");
157 exit;
158 }
159}
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
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
global $DIC
Definition: goto.php:24
exit
Definition: login.php:29
$message
Definition: xapiexit.php:14
$objId
Definition: xapitoken.php:39