ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 if ($this->id_type == self::WORKSPACE_NODE_ID) {
31 include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
33 $this->lng->loadLanguageModule("file");
34 ilUtil::sendFailure($this->lng->txt("personal_resources_quota_exceeded_warning"), true);
35 $this->ctrl->redirect($this, "cancel");
36 }
37 }
38
39 $this->lng->loadLanguageModule("crsv");
40
41 $ilTabs->setBackTarget(
42 $this->lng->txt("back"),
43 $this->ctrl->getLinkTarget($this, "cancel")
44 );
45
46 $table = new ilCourseVerificationTableGUI($this, "create");
47 $this->tpl->setContent($table->getHTML());
48 }
49
53 public function save()
54 {
55 global $DIC;
56
57 $ilUser = $DIC['ilUser'];
58
59 $objectId = $_REQUEST["crs_id"];
60 if ($objectId) {
61 $certificateVerificationFileService = new ilCertificateVerificationFileService(
62 $DIC->language(),
63 $DIC->database(),
64 $DIC->logger()->root(),
66 );
67
68 $userCertificateRepository = new ilUserCertificateRepository();
69
70 $userCertificatePresentation = $userCertificateRepository->fetchActiveCertificateForPresentation(
71 (int) $ilUser->getId(),
72 (int) $objectId
73 );
74
75 try {
76 $newObj = $certificateVerificationFileService->createFile($userCertificatePresentation);
77 } catch (\Exception $exception) {
78 ilUtil::sendFailure($this->lng->txt('error_creating_certificate_pdf'));
79 return $this->create();
80 }
81
82 if ($newObj) {
84 $this->node_id = null;
85 $this->putObjectInTree($newObj, $parent_id);
86
87 $this->afterSave($newObj);
88 } else {
89 ilUtil::sendFailure($this->lng->txt("msg_failed"));
90 }
91 } else {
92 ilUtil::sendFailure($this->lng->txt("select_one"));
93 }
94
95 $this->create();
96 }
97
98 public function deliver()
99 {
100 $file = $this->object->getFilePath();
101 if ($file) {
102 ilUtil::deliverFile($file, $this->object->getTitle() . ".pdf");
103 }
104 }
105
112 public function render($a_return = false, $a_url = false)
113 {
114 global $DIC;
115
116 $ilUser = $DIC['ilUser'];
117 $lng = $DIC['lng'];
118
119 if (!$a_return) {
120 $this->deliver();
121 } else {
122 $tree = new ilWorkspaceTree($ilUser->getId());
123 $wsp_id = $tree->lookupNodeId($this->object->getId());
124
125 $caption = $lng->txt("wsp_type_crsv") . ' "' . $this->object->getTitle() . '"';
126
127 $valid = true;
128 if (!file_exists($this->object->getFilePath())) {
129 $valid = false;
130 $message = $lng->txt("url_not_found");
131 } elseif (!$a_url) {
132 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
134 if (!$access_handler->checkAccess("read", "", $wsp_id)) {
135 $valid = false;
136 $message = $lng->txt("permission_denied");
137 }
138 }
139
140 if ($valid) {
141 if (!$a_url) {
142 $a_url = $this->getAccessHandler()->getGotoLink($wsp_id, $this->object->getId());
143 }
144 return '<div><a href="' . $a_url . '">' . $caption . '</a></div>';
145 } else {
146 return '<div>' . $caption . ' (' . $message . ')</div>';
147 }
148 }
149 }
150
152 {
153 global $DIC;
154
155 $ilErr = $DIC['ilErr'];
156
157 include_once "Services/COPage/classes/class.ilPCVerification.php";
158 if (ilPCVerification::isInPortfolioPage($a_page, $this->object->getType(), $this->object->getId())) {
159 $this->deliver();
160 }
161
162 $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->MESSAGE);
163 }
164
165 public static function _goto($a_target)
166 {
167 $id = explode("_", $a_target);
168
169 $_GET["baseClass"] = "ilsharedresourceGUI";
170 $_GET["wsp_id"] = $id[0];
171 include("ilias.php");
172 exit;
173 }
174}
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
List all completed course for current user.
static isUploadPossible($a_additional_size=null)
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
exit
Definition: login.php:29
$ilUser
Definition: imgupload.php:18
$message
Definition: xapiexit.php:14
$DIC
Definition: xapitoken.php:46