ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjCmiXapiVerificationGUI.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 "cmxv";
20 }
21
25 public function create()
26 {
27 global $ilTabs;
28
29 $this->lng->loadLanguageModule("cmxv");
30
31 $ilTabs->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 ilCmiXapiVerificationTableGUI($this, "create");
38 $this->tpl->setContent($table->getHTML());
39 }
40
44 public function save() : void
45 {
46 global $DIC; /* @var \ILIAS\DI\Container $DIC */
47
48 $objId = $_REQUEST["cmix_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 $this->create();
69 return;
70 }
71
72 if ($newObj) {
74 $this->node_id = null;
75 $this->putObjectInTree($newObj, $parent_id);
76
77 $this->afterSave($newObj);
78 } else {
79 ilUtil::sendFailure($this->lng->txt("msg_failed"));
80 }
81 } else {
82 ilUtil::sendFailure($this->lng->txt("select_one"));
83 }
84
85 $this->create();
86 }
87
88 public function deliver()
89 {
90 $file = $this->object->getFilePath();
91
92 if ($file) {
93 ilUtil::deliverFile($file, $this->object->getTitle() . ".pdf");
94 }
95 }
96
102 public function render($a_return = false, $a_url = false)
103 {
104 global $ilUser, $lng;
105
106 if (!$a_return) {
107 $this->deliver();
108 } else {
109 $tree = new ilWorkspaceTree($ilUser->getId());
110 $wsp_id = $tree->lookupNodeId($this->object->getId());
111
112 $caption = $lng->txt("wsp_type_cmxv") . ' "' . $this->object->getTitle() . '"';
113
114 $valid = true;
115 if (!file_exists($this->object->getFilePath())) {
116 $valid = false;
117 $message = $lng->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 = $lng->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 $ilErr;
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 $ilErr->raiseError($this->lng->txt('permission_denied'), $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.
save()
create new instance and save it
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
$ilUser
Definition: imgupload.php:18
exit
Definition: login.php:29
$message
Definition: xapiexit.php:14
$objId
Definition: xapitoken.php:39