ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjCourseVerificationGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5include_once('./Services/Object/classes/class.ilObject2GUI.php');
6
15{
16 public function getType()
17 {
18 return "crsv";
19 }
20
24 public function create()
25 {
26 global $DIC;
27
28 $ilTabs = $DIC['ilTabs'];
29
30 $this->lng->loadLanguageModule("crsv");
31
32 $ilTabs->setBackTarget(
33 $this->lng->txt("back"),
34 $this->ctrl->getLinkTarget($this, "cancel")
35 );
36
37 $table = new ilCourseVerificationTableGUI($this, "create");
38 $this->tpl->setContent($table->getHTML());
39 }
40
44 public function save()
45 {
46 global $DIC;
47
48 $ilUser = $DIC['ilUser'];
49
50 $objectId = $_REQUEST["crs_id"];
51 if ($objectId) {
52 $certificateVerificationFileService = new ilCertificateVerificationFileService(
53 $DIC->language(),
54 $DIC->database(),
55 $DIC->logger()->root(),
57 );
58
59 $userCertificateRepository = new ilUserCertificateRepository();
60
61 $userCertificatePresentation = $userCertificateRepository->fetchActiveCertificateForPresentation(
62 (int) $ilUser->getId(),
63 (int) $objectId
64 );
65
66 try {
67 $newObj = $certificateVerificationFileService->createFile($userCertificatePresentation);
68 } catch (\Exception $exception) {
69 ilUtil::sendFailure($this->lng->txt('error_creating_certificate_pdf'));
70 return $this->create();
71 }
72
73 if ($newObj) {
75 $this->node_id = null;
76 $this->putObjectInTree($newObj, $parent_id);
77
78 $this->afterSave($newObj);
79 } else {
80 ilUtil::sendFailure($this->lng->txt("msg_failed"));
81 }
82 } else {
83 ilUtil::sendFailure($this->lng->txt("select_one"));
84 }
85
86 $this->create();
87 }
88
89 public function deliver()
90 {
91 $file = $this->object->getFilePath();
92 if ($file) {
93 ilUtil::deliverFile($file, $this->object->getTitle() . ".pdf");
94 }
95 }
96
103 public function render($a_return = false, $a_url = false)
104 {
105 global $DIC;
106
107 $ilUser = $DIC['ilUser'];
108 $lng = $DIC['lng'];
109
110 if (!$a_return) {
111 $this->deliver();
112 } else {
113 $tree = new ilWorkspaceTree($ilUser->getId());
114 $wsp_id = $tree->lookupNodeId($this->object->getId());
115
116 $caption = $lng->txt("wsp_type_crsv") . ' "' . $this->object->getTitle() . '"';
117
118 $valid = true;
119 if (!file_exists($this->object->getFilePath())) {
120 $valid = false;
121 $message = $lng->txt("url_not_found");
122 } elseif (!$a_url) {
123 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
125 if (!$access_handler->checkAccess("read", "", $wsp_id)) {
126 $valid = false;
127 $message = $lng->txt("permission_denied");
128 }
129 }
130
131 if ($valid) {
132 if (!$a_url) {
133 $a_url = $this->getAccessHandler()->getGotoLink($wsp_id, $this->object->getId());
134 }
135 return '<div><a href="' . $a_url . '">' . $caption . '</a></div>';
136 } else {
137 return '<div>' . $caption . ' (' . $message . ')</div>';
138 }
139 }
140 }
141
143 {
144 global $DIC;
145
146 $ilErr = $DIC['ilErr'];
147
148 include_once "Services/COPage/classes/class.ilPCVerification.php";
149 if (ilPCVerification::isInPortfolioPage($a_page, $this->object->getType(), $this->object->getId())) {
150 $this->deliver();
151 }
152
153 $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->MESSAGE);
154 }
155
156 public static function _goto($a_target)
157 {
158 $id = explode("_", $a_target);
159
160 $_GET["baseClass"] = "ilsharedresourceGUI";
161 $_GET["wsp_id"] = $id[0];
162 include("ilias.php");
163 exit;
164 }
165}
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
List all completed course for current user.
GUI class for course verification.
downloadFromPortfolioPage(ilPortfolioPage $a_page)
create()
List all tests in which current user participated.
render($a_return=false, $a_url=false)
Render content.
save()
create new instance and save it
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