ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilPCVerificationGUI Class Reference

Class ilPCVerificationGUI. More...

+ Inheritance diagram for ilPCVerificationGUI:
+ Collaboration diagram for ilPCVerificationGUI:

Public Member Functions

 __construct ($a_pg_obj, $a_content_obj, $a_hier_id=0, $a_pc_id="")
 
 executeCommand ()
 
 insert (ilPropertyFormGUI $a_form=null)
 
 edit (ilPropertyFormGUI $a_form=null)
 
 create ()
 
 update ()
 
- Public Member Functions inherited from ilPageContentGUI
 __construct ($a_pg_obj, $a_content_obj, $a_hier_id=0, $a_pc_id="")
 Constructor public. More...
 
 setContentObject ($a_val)
 Set content object. More...
 
 getContentObject ()
 Get content object. More...
 
 setPage ($a_val)
 Set page. More...
 
 getPage ()
 Get page. More...
 
 setPageConfig ($a_val)
 Set Page Config. More...
 
 getPageConfig ()
 Get Page Config. More...
 
 setStyleId ($a_styleid)
 Set Style Id. More...
 
 getStyleId ()
 Get Style Id. More...
 
 getStyle ()
 Get style object. More...
 
 getCharacteristicsOfCurrentStyle ($a_type)
 Get characteristics of current style. More...
 
 setCharacteristics ($a_chars)
 Set Characteristics. More...
 
 getCharacteristics ()
 Get characteristics. More...
 
 getHierId ()
 get hierarchical id in dom object More...
 
 setHierId ($a_hier_id)
 get hierarchical id in dom object More...
 
 getBBMenu ($a_ta_name="par_content")
 Get the bb menu incl. More...
 
 delete ()
 delete content element More...
 
 moveAfter ()
 move content element after another element More...
 
 moveBefore ()
 move content element before another element More...
 
 splitPage ()
 split page to new page at specified position More...
 
 splitPageNext ()
 split page to next page at specified position More...
 
 displayValidationError ()
 display validation errors More...
 
 cancelCreate ()
 cancel creating page content More...
 
 cancelUpdate ()
 cancel update More...
 
 cancel ()
 Cancel. More...
 
 deactivate ()
 gui function set enabled if is not enabled and vice versa More...
 
 cut ()
 Cut single element. More...
 
 copy ()
 Copy single element. More...
 
 getTemplateOptions ($a_type)
 Get table templates. More...
 

Protected Member Functions

 initForm (bool $a_insert=false)
 
- Protected Member Functions inherited from ilPageContentGUI
 redirectToParent ($hier_id="")
 Redirect to parent. More...
 
 getParentReturn ($hier_id="")
 

Protected Attributes

 $user
 
- Protected Attributes inherited from ilPageContentGUI
 $error
 
 $log
 

Private Member Functions

 getValidWorkspaceCertificateNodeByIdMap ()
 
 getValidCertificateByIdMap ()
 

Private Attributes

const SUPPORTED_TYPES = ['excv', 'tstv', 'crsv', 'cmxv', 'ltiv', 'scov']
 

Additional Inherited Members

- Static Public Member Functions inherited from ilPageContentGUI
static _getCommonBBButtons ()
 Get common bb buttons. More...
 
- Data Fields inherited from ilPageContentGUI
 $content_obj
 
 $tpl
 
 $lng
 
 $ctrl
 
 $pg_obj
 
 $hier_id
 
 $dom
 
 $updated
 
 $target_script
 
 $return_location
 
 $page_config = null
 
- Static Public Attributes inherited from ilPageContentGUI
static $style_selector_reset = "margin-top:2px; margin-bottom:2px; text-indent:0px; position:static; float:none; width: auto;"
 
- Static Protected Attributes inherited from ilPageContentGUI
static $common_bb_buttons
 

Detailed Description

Class ilPCVerificationGUI.

Handles user commands on verifications

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$I$

Definition at line 14 of file class.ilPCVerificationGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilPCVerificationGUI::__construct (   $a_pg_obj,
  $a_content_obj,
  $a_hier_id = 0,
  $a_pc_id = "" 
)

Definition at line 24 of file class.ilPCVerificationGUI.php.

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), and user().

25  {
26  global $DIC;
27 
28  $this->user = $DIC->user();
29  parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
30  }
user()
Definition: user.php:4
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ create()

ilPCVerificationGUI::create ( )
Exceptions
ilDateTimeException

Definition at line 186 of file class.ilPCVerificationGUI.php.

References Vendor\Package\$e, ilPageContentGUI\getPage(), initForm(), insert(), ilUtil\sendFailure(), ilUtil\sendInfo(), and user().

186  : void
187  {
188  $form = $this->initForm(true);
189  if ($form->checkInput()) {
190  $objectId = (int) $form->getInput('persistent_object');
191  $userId = (int) $this->user->getId();
192 
193  $certificateFileService = new ilPortfolioCertificateFileService();
194  try {
195  $certificateFileService->createCertificateFile($userId, $objectId);
196  } catch (\ILIAS\Filesystem\Exception\FileAlreadyExistsException $e) {
197  ilUtil::sendInfo($this->lng->txt('certificate_file_not_found_error'), true);
198  $this->log->warning($e->getMessage());
199  } catch (\ILIAS\Filesystem\Exception\IOException $e) {
200  ilUtil::sendInfo($this->lng->txt('certificate_file_input_output_error'), true);
201  $this->log->error($e->getMessage());
202  $this->ctrl->redirect($this, 'initForm');
203  } catch (ilException $e) {
204  ilUtil::sendFailure($this->lng->txt('error_creating_certificate_pdf'), true);
205  $this->log->error($e->getMessage());
206  $this->ctrl->redirect($this, 'initForm');
207  }
208 
209  $this->content_obj = new ilPCVerification($this->getPage());
210  $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
211  $this->content_obj->setData('crta', $objectId);
212 
213  $this->updated = $this->pg_obj->update();
214  if ($this->updated === true) {
215  $this->ctrl->returnToParent($this, 'jump' . $this->hier_id);
216  }
217 
218  $this->log->info('File could not be created');
219  }
220 
221  $this->insert($form);
222  }
Class ChatMainBarProvider .
insert(ilPropertyFormGUI $a_form=null)
user()
Definition: user.php:4
initForm(bool $a_insert=false)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
Class ilPCVerification.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Class FlySystemFileAccessTest disabled disabled disabled.
+ Here is the call graph for this function:

◆ edit()

ilPCVerificationGUI::edit ( ilPropertyFormGUI  $a_form = null)
Parameters
ilPropertyFormGUI | null$a_form
Exceptions
ilDateTimeException

Definition at line 56 of file class.ilPCVerificationGUI.php.

References ilPageContentGUI\displayValidationError(), and initForm().

Referenced by update().

56  : void
57  {
58  $this->displayValidationError();
59 
60  if (!$a_form) {
61  $a_form = $this->initForm();
62  }
63  $this->tpl->setContent($a_form->getHTML());
64  }
initForm(bool $a_insert=false)
displayValidationError()
display validation errors
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilPCVerificationGUI::executeCommand ( )

Definition at line 32 of file class.ilPCVerificationGUI.php.

33  {
34  $cmd = $this->ctrl->getCmd();
35  return $this->$cmd();
36  }

◆ getValidCertificateByIdMap()

ilPCVerificationGUI::getValidCertificateByIdMap ( )
private
Returns
array<int, ilUserCertificatePresentation>

Definition at line 90 of file class.ilPCVerificationGUI.php.

References user().

Referenced by initForm(), and update().

90  : array
91  {
92  $certificates = [];
93 
94  $repository = new ilUserCertificateRepository();
95  $activeCertificates = $repository->fetchActiveCertificates((int) $this->user->getId());
96  foreach ($activeCertificates as $certificate) {
97  $certificates[$certificate->getObjId()] = $certificate;
98  }
99 
100  return $certificates;
101  }
user()
Definition: user.php:4
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getValidWorkspaceCertificateNodeByIdMap()

ilPCVerificationGUI::getValidWorkspaceCertificateNodeByIdMap ( )
private
Returns
array<int, array>

Definition at line 69 of file class.ilPCVerificationGUI.php.

References ilTree\getNodeData(), ilTree\getRootId(), and user().

Referenced by initForm(), and update().

69  : array
70  {
71  $nodes = [];
72 
73  $tree = new ilWorkspaceTree($this->user->getId());
74  $root = $tree->getRootId();
75  if ($root) {
76  $root = $tree->getNodeData($root);
77  foreach ($tree->getSubTree($root) as $node) {
78  if (in_array($node['type'], self::SUPPORTED_TYPES)) {
79  $nodes[$node['obj_id']] = $node;
80  }
81  }
82  }
83 
84  return $nodes;
85  }
user()
Definition: user.php:4
Tree handler for personal workspace.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initForm()

ilPCVerificationGUI::initForm ( bool  $a_insert = false)
protected
Parameters
false$a_insert
Returns
ilPropertyFormGUI
Exceptions
ilDateTimeException

Definition at line 108 of file class.ilPCVerificationGUI.php.

References $data, $type, ilSubEnabledFormPropertyGUI\addSubItem(), ilRadioOption\addSubItem(), ilDatePresentation\formatDate(), getValidCertificateByIdMap(), getValidWorkspaceCertificateNodeByIdMap(), IL_CAL_UNIX, and ilRadioOption\setValue().

Referenced by create(), edit(), insert(), and update().

109  {
110  $this->lng->loadLanguageModule('wsp');
111 
112  $form = new ilPropertyFormGUI();
113  $form->setFormAction($this->ctrl->getFormAction($this));
114 
115  $data = [];
116  if ($a_insert) {
117  $form->setTitle($this->lng->txt('cont_insert_verification'));
118  $form->addCommandButton('create_verification', $this->lng->txt('save'));
119  $form->addCommandButton('cancelCreate', $this->lng->txt('cancel'));
120  } else {
121  $form->setTitle($this->lng->txt('cont_update_verification'));
122  $form->addCommandButton('update', $this->lng->txt('save'));
123  $form->addCommandButton('cancelUpdate', $this->lng->txt('cancel'));
124  $data = $this->content_obj->getData();
125  }
126 
127  $certificateOptions = [];
128  foreach ($this->getValidCertificateByIdMap() as $certificate) {
129  $userCertificate = $certificate->getUserCertificate();
130  $dateTime = ilDatePresentation::formatDate(new ilDateTime($userCertificate->getAcquiredTimestamp(), IL_CAL_UNIX));
131 
132  $type = $this->lng->txt('wsp_type_' . $userCertificate->getObjType() . 'v');
133  if ('sahs' === $userCertificate->getObjType()) {
134  $type = $this->lng->txt('wsp_type_scov');
135  }
136  $additionalInformation = ' (' . $type . ' / ' . $dateTime . ')';
137  $certificateOptions[$userCertificate->getObjId()] = $certificate->getObjectTitle() . $additionalInformation;
138  }
139 
140  if ($a_insert || (isset($data['type']) && 'crta' === $data['type'])) {
141  $certificate = new ilSelectInputGUI($this->lng->txt('certificate'), 'persistent_object');
142  $certificate->setRequired(true);
143  $certificate->setOptions($certificateOptions);
144  $form->addItem($certificate);
145  if (isset($data['id'])) {
146  $certificate->setValue($data['id']);
147  }
148 
149  return $form;
150  }
151 
152  $certificateSource = new ilRadioGroupInputGUI($this->lng->txt('certificate_selection'), 'certificate_selection');
153 
154  $workspaceRadioButton = new ilRadioOption($this->lng->txt('certificate_workspace_option'), 'certificate_workspace_option');
155  $persistentRadioButton = new ilRadioOption($this->lng->txt('certificate_persistent_option'), 'certificate_persistent_option');
156 
157  $workspaceCertificates = new ilSelectInputGUI($this->lng->txt('cont_verification_object'), 'object');
158  $workspaceCertificates->setRequired(true);
159  $workspaceOptions = [];
160  foreach ($this->getValidWorkspaceCertificateNodeByIdMap() as $node) {
161  $workspaceOptions[$node['obj_id']] = $node['title'] . ' (' . $this->lng->txt('wsp_type_' . $node['type']) . ')';
162  }
163  asort($workspaceOptions);
164  $workspaceCertificates->setOptions($workspaceOptions);
165 
166  $certificate = new ilSelectInputGUI($this->lng->txt('cont_verification_object'), 'persistent_object');
167  $certificate->setRequired(true);
168  $certificate->setOptions($certificateOptions);
169  $persistentRadioButton->addSubItem($certificate);
170  $workspaceRadioButton->addSubItem($workspaceCertificates);
171 
172  $certificateSource->addOption($persistentRadioButton);
173  $certificateSource->addOption($workspaceRadioButton);
174 
175  $form->addItem($certificateSource);
176 
177  $certificateSource->setValue('certificate_workspace_option');
178  $workspaceCertificates->setValue($data['id']);
179 
180  return $form;
181  }
This class represents an option in a radio group.
$data
Definition: storeScorm.php:23
This class represents a property form user interface.
$type
const IL_CAL_UNIX
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
This class represents a property in a property form.
setValue($a_value)
Set Value.
addSubItem($a_item)
Add Subitem.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insert()

ilPCVerificationGUI::insert ( ilPropertyFormGUI  $a_form = null)
Parameters
ilPropertyFormGUI | null$a_form
Exceptions
ilDateTimeException

Definition at line 42 of file class.ilPCVerificationGUI.php.

References ilPageContentGUI\displayValidationError(), and initForm().

Referenced by create().

42  : void
43  {
44  $this->displayValidationError();
45 
46  if (!$a_form) {
47  $a_form = $this->initForm(true);
48  }
49  $this->tpl->setContent($a_form->getHTML());
50  }
initForm(bool $a_insert=false)
displayValidationError()
display validation errors
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

ilPCVerificationGUI::update ( )
Exceptions
ilDateTimeException

Definition at line 227 of file class.ilPCVerificationGUI.php.

References Vendor\Package\$e, edit(), getValidCertificateByIdMap(), getValidWorkspaceCertificateNodeByIdMap(), initForm(), ilUtil\sendFailure(), ilUtil\sendInfo(), and user().

227  : void
228  {
229  $form = $this->initForm();
230  if ($form->checkInput()) {
231  $option = 'certificate_persistent_option';
232  if ($form->getItemByPostVar('certificate_selection')) {
233  $option = $form->getInput('certificate_selection');
234  }
235 
236  $oldContentData = $this->content_obj->getData();
237 
238  if ('certificate_workspace_option' === $option) {
239  $objectId = (int) $form->getInput('object');
240  $validWorkSpaceCertificates = $this->getValidWorkspaceCertificateNodeByIdMap();
241 
242  if (isset($validWorkSpaceCertificates[$objectId])) {
243  $this->content_obj->setData($validWorkSpaceCertificates[$objectId]['type'], $objectId);
244  }
245  } elseif ('certificate_persistent_option' === $option) {
246  try {
247  $objectId = (int) $form->getInput('persistent_object');
248  $validCertificates = $this->getValidCertificateByIdMap();
249 
250  if (isset($validCertificates[$objectId])) {
251  $certificateFileService = new ilPortfolioCertificateFileService();
252  $certificateFileService->createCertificateFile(
253  (int) $this->user->getId(),
254  $objectId
255  );
256  $this->content_obj->setData('crta', $objectId);
257  }
258  } catch (\ILIAS\Filesystem\Exception\FileNotFoundException $e) {
259  ilUtil::sendInfo($this->lng->txt('certificate_file_not_found_error'), true);
260  $this->log->warning($e->getMessage());
261  } catch (\ILIAS\Filesystem\Exception\FileAlreadyExistsException $e) {
262  ilUtil::sendInfo($this->lng->txt('certificate_file_not_found_error'), true);
263  $this->log->warning($e->getMessage());
264  } catch (\ILIAS\Filesystem\Exception\IOException $e) {
265  ilUtil::sendInfo($this->lng->txt('certificate_file_input_output_error'), true);
266  $this->log->warning($e->getMessage());
267  } catch (ilException $e) {
268  ilUtil::sendFailure($this->lng->txt('error_creating_certificate_pdf'), true);
269  $this->log->error($e->getMessage());
270  $this->ctrl->redirect($this, 'initForm');
271  }
272  }
273 
274  if ('crta' === $oldContentData['type']) {
275  try {
276  $certificateFileService = new ilPortfolioCertificateFileService();
277  $certificateFileService->deleteCertificateFile(
278  (int) $this->user->getId(),
279  (int) $oldContentData['id']
280  );
281  } catch (\ILIAS\Filesystem\Exception\FileNotFoundException $e) {
282  ilUtil::sendInfo($this->lng->txt('certificate_file_not_found_error'));
283  $this->log->warning($e->getMessage());
284  } catch (\ILIAS\Filesystem\Exception\IOException $e) {
285  ilUtil::sendInfo($this->lng->txt('certificate_file_input_output_error'));
286  $this->log->warning($e->getMessage());
287  }
288  }
289 
290  $this->updated = $this->pg_obj->update();
291  if ($this->updated === true) {
292  $this->ctrl->returnToParent($this, 'jump' . $this->hier_id);
293  }
294  }
295 
296  $this->pg_obj->addHierIDs();
297  $this->edit($form);
298  }
Class ChatMainBarProvider .
user()
Definition: user.php:4
initForm(bool $a_insert=false)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
edit(ilPropertyFormGUI $a_form=null)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Class FlySystemFileAccessTest disabled disabled disabled.
+ Here is the call graph for this function:

Field Documentation

◆ $user

ilPCVerificationGUI::$user
protected

Definition at line 19 of file class.ilPCVerificationGUI.php.

◆ SUPPORTED_TYPES

const ilPCVerificationGUI::SUPPORTED_TYPES = ['excv', 'tstv', 'crsv', 'cmxv', 'ltiv', 'scov']
private

Definition at line 16 of file class.ilPCVerificationGUI.php.


The documentation for this class was generated from the following file: