ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 
5 include_once('./Services/Object/classes/class.ilObject2GUI.php');
6 
18 {
19  public function getType()
20  {
21  return "crsv";
22  }
23 
27  public function create()
28  {
29  global $DIC;
30 
31  $ilTabs = $DIC['ilTabs'];
32 
33  if ($this->id_type == self::WORKSPACE_NODE_ID) {
34  include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
36  $this->lng->loadLanguageModule("file");
37  ilUtil::sendFailure($this->lng->txt("personal_workspace_quota_exceeded_warning"), true);
38  $this->ctrl->redirect($this, "cancel");
39  }
40  }
41 
42  $this->lng->loadLanguageModule("crsv");
43 
44  $ilTabs->setBackTarget(
45  $this->lng->txt("back"),
46  $this->ctrl->getLinkTarget($this, "cancel")
47  );
48 
49  $table = new ilCourseVerificationTableGUI($this, "create");
50  $this->tpl->setContent($table->getHTML());
51  }
52 
56  public function save()
57  {
58  global $DIC;
59 
60  $ilUser = $DIC['ilUser'];
61 
62  $objectId = $_REQUEST["crs_id"];
63  if ($objectId) {
64  $certificateVerificationFileService = new ilCertificateVerificationFileService(
65  $DIC->language(),
66  $DIC->database(),
67  $DIC->logger()->root(),
69  );
70 
71  $userCertificateRepository = new ilUserCertificateRepository();
72 
73  $userCertificatePresentation = $userCertificateRepository->fetchActiveCertificateForPresentation(
74  (int) $ilUser->getId(),
75  (int) $objectId
76  );
77 
78  try {
79  $newObj = $certificateVerificationFileService->createFile($userCertificatePresentation);
80  } catch (\Exception $exception) {
81  ilUtil::sendFailure($this->lng->txt('error_creating_certificate_pdf'));
82  return $this->create();
83  }
84 
85  if ($newObj) {
87  $this->node_id = null;
88  $this->putObjectInTree($newObj, $parent_id);
89 
90  $this->afterSave($newObj);
91  } else {
92  ilUtil::sendFailure($this->lng->txt("msg_failed"));
93  }
94  } else {
95  ilUtil::sendFailure($this->lng->txt("select_one"));
96  }
97 
98  $this->create();
99  }
100 
101  public function deliver()
102  {
103  $file = $this->object->getFilePath();
104  if ($file) {
105  ilUtil::deliverFile($file, $this->object->getTitle() . ".pdf");
106  }
107  }
108 
115  public function render($a_return = false, $a_url = false)
116  {
117  global $DIC;
118 
119  $ilUser = $DIC['ilUser'];
120  $lng = $DIC['lng'];
121 
122  if (!$a_return) {
123  $this->deliver();
124  } else {
125  $tree = new ilWorkspaceTree($ilUser->getId());
126  $wsp_id = $tree->lookupNodeId($this->object->getId());
127 
128  $caption = $lng->txt("wsp_type_crsv") . ' "' . $this->object->getTitle() . '"';
129 
130  $valid = true;
131  if (!file_exists($this->object->getFilePath())) {
132  $valid = false;
133  $message = $lng->txt("url_not_found");
134  } elseif (!$a_url) {
135  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
137  if (!$access_handler->checkAccess("read", "", $wsp_id)) {
138  $valid = false;
139  $message = $lng->txt("permission_denied");
140  }
141  }
142 
143  if ($valid) {
144  if (!$a_url) {
145  $a_url = $this->getAccessHandler()->getGotoLink($wsp_id, $this->object->getId());
146  }
147  return '<div><a href="' . $a_url . '">' . $caption . '</a></div>';
148  } else {
149  return '<div>' . $caption . ' (' . $message . ')</div>';
150  }
151  }
152  }
153 
155  {
156  global $DIC;
157 
158  $ilErr = $DIC['ilErr'];
159 
160  include_once "Services/COPage/classes/class.ilPCVerification.php";
161  if (ilPCVerification::isInPortfolioPage($a_page, $this->object->getType(), $this->object->getId())) {
162  $this->deliver();
163  }
164 
165  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->MESSAGE);
166  }
167 
168  public static function _goto($a_target)
169  {
170  $id = explode("_", $a_target);
171 
172  $_GET["baseClass"] = "ilsharedresourceGUI";
173  $_GET["wsp_id"] = $id[0];
174  include("ilias.php");
175  exit;
176  }
177 }
New implementation of ilObjectGUI.
global $DIC
Definition: saml.php:7
List all completed course for current user.
$_GET["client_id"]
static isInPortfolioPage(ilPortfolioPage $a_page, $a_type, $a_id)
getAccessHandler()
Get access handler.
$valid
create()
List all tests in which current user participated.
if(!array_key_exists('StateId', $_REQUEST)) $id
Access handler for personal workspace.
createFile(ilUserCertificatePresentation $userCertificatePresentation)
afterSave(ilObject $a_new_object)
Post (successful) object creation hook.
Tree handler for personal workspace.
render($a_return=false, $a_url=false)
Render content.
GUI class for course verification.
catch(Exception $e) $message
static isUploadPossible($a_additional_size=null)
$ilUser
Definition: imgupload.php:18
Page for user portfolio.
downloadFromPortfolioPage(ilPortfolioPage $a_page)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
putObjectInTree(ilObject $a_obj, $a_parent_node_id=null)
Add object to tree at given position.
exit
Definition: backend.php:16
save()
create new instance and save it
if(empty($password)) $table
Definition: pwgen.php:24
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.