ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilPCVerificationGUI Class Reference

Class ilPCVerificationGUI Handles user commands on verifications. More...

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

Public Member Functions

 __construct (ilPageObject $a_pg_obj, ?ilPCVerification $a_content_obj, string $a_hier_id='0', string $a_pc_id="")
 
 executeCommand ()
 
 insert (?ilPropertyFormGUI $a_form=null)
 
 edit (?ilPropertyFormGUI $a_form=null)
 
 create_verification ()
 
 create ()
 
 update ()
 
- Public Member Functions inherited from ilPageContentGUI
 __construct (ilPageObject $a_pg_obj, ?ilPageContent $a_content_obj, string $a_hier_id="", string $a_pc_id="0")
 
 setContentObject (ilPageContent $a_val)
 
 getContentObject ()
 
 setPage (ilPageObject $a_val)
 
 getPage ()
 
 setPageConfig (ilPageConfig $a_val)
 
 getPageConfig ()
 
 setStyleId (int $a_styleid)
 
 getStyleId ()
 
 getStyle ()
 
 getCharacteristicsOfCurrentStyle (array $a_type)
 Get characteristics of current style and call setCharacteristics, if style is given. More...
 
 setCharacteristics (array $a_chars)
 
 getCharacteristics ()
 
 getHierId ()
 
 setHierId (string $a_hier_id)
 set hierarchical id in dom object More...
 
 delete ()
 
 displayValidationError ()
 
 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 (string $a_type="")
 Get table templates. More...
 

Protected Member Functions

 initForm (bool $a_insert=false)
 
- Protected Member Functions inherited from ilPageContentGUI
 redirectToParent (string $hier_id="")
 
 getParentReturn (string $hier_id="")
 
 updateAndReturn ()
 
 setCurrentTextLang (string $lang_key)
 
 getCurrentTextLang ()
 
 setEditorToolContext ()
 
 initEditor ()
 
 getEditorScriptTag (string $form_pc_id="", string $form_cname="")
 

Protected Attributes

ilObjUser $user
 
- Protected Attributes inherited from ilPageContentGUI
ILIAS COPage Editor GUIService $editor_gui
 
ILIAS COPage InternalGUIService $gui
 
EditSessionRepository $edit_repo
 
string $pc_id = ""
 
array $chars
 
ilObjStyleSheet $style = null
 
LOMServices $lom_services
 
ilLogger $log
 
int $styleid = 0
 
EditGUIRequest $request
 
string $sub_command = ""
 
int $requested_ref_id = 0
 
ILIAS GlobalScreen ScreenContext ContextServices $tool_context
 
Style Content CharacteristicManager $char_manager
 

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 ()
 
- Data Fields inherited from ilPageContentGUI
ilPageContent $content_obj
 
ilGlobalTemplateInterface $tpl
 
ilLanguage $lng
 
ilCtrl $ctrl
 
ilPageObject $pg_obj
 
string $hier_id = ""
 
DOMDocument $dom
 
 $updated
 
string $target_script = ""
 
string $return_location = ""
 
ilPageConfig $page_config = null
 
- Static Public Attributes inherited from ilPageContentGUI
static string $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 array $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

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

Constructor & Destructor Documentation

◆ __construct()

ilPCVerificationGUI::__construct ( ilPageObject  $a_pg_obj,
?ilPCVerification  $a_content_obj,
string  $a_hier_id = '0',
string  $a_pc_id = "" 
)

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

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

36  {
37  global $DIC;
38 
39  $this->user = $DIC->user();
40  parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
41  }
global $DIC
Definition: shib_login.php:22
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ create()

ilPCVerificationGUI::create ( )

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

References Vendor\Package\$e, ILIAS\Repository\ctrl(), ilPageContentGUI\getPage(), initForm(), insert(), ILIAS\Repository\int(), ILIAS\Repository\lng(), and ILIAS\Repository\user().

Referenced by create_verification().

199  : void
200  {
201  $form = $this->initForm(true);
202  if ($form->checkInput()) {
203  $objectId = (int) $form->getInput('persistent_object');
204  $userId = $this->user->getId();
205 
206  $certificateFileService = new ilPortfolioCertificateFileService();
207  try {
208  $certificateFileService->createCertificateFile($userId, $objectId);
209  } catch (\ILIAS\Filesystem\Exception\FileAlreadyExistsException $e) {
210  $this->tpl->setOnScreenMessage('info', $this->lng->txt('certificate_file_not_found_error'), true);
211  $this->log->warning($e->getMessage());
212  } catch (\ILIAS\Filesystem\Exception\IOException $e) {
213  $this->tpl->setOnScreenMessage('info', $this->lng->txt('certificate_file_input_output_error'), true);
214  $this->log->error($e->getMessage());
215  $this->ctrl->redirect($this, 'initForm');
216  } catch (ilException $e) {
217  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('error_creating_certificate_pdf'), true);
218  $this->log->error($e->getMessage());
219  $this->ctrl->redirect($this, 'initForm');
220  }
221 
222  $this->content_obj = new ilPCVerification($this->getPage());
223  $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
224  $this->content_obj->setData('crta', $objectId);
225 
226  $this->updated = $this->pg_obj->update();
227  if ($this->updated === true) {
228  $this->ctrl->returnToParent($this, 'jump' . $this->hier_id);
229  }
230 
231  $this->log->info('File could not be created');
232  }
233 
234  $this->insert($form);
235  }
Interface Observer Contains several chained tasks and infos about them.
initForm(bool $a_insert=false)
insert(?ilPropertyFormGUI $a_form=null)
Class ilPCVerification Verification content object (see ILIAS DTD)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create_verification()

ilPCVerificationGUI::create_verification ( )

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

References create().

194  : void
195  {
196  $this->create();
197  }
+ Here is the call graph for this function:

◆ edit()

ilPCVerificationGUI::edit ( ?ilPropertyFormGUI  $a_form = null)

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

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

Referenced by update().

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

◆ executeCommand()

ilPCVerificationGUI::executeCommand ( )

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

References ILIAS\Repository\ctrl().

43  : void
44  {
45  $cmd = $this->ctrl->getCmd();
46  $this->$cmd();
47  }
+ Here is the call graph for this function:

◆ getValidCertificateByIdMap()

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

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

References ILIAS\Repository\user().

Referenced by initForm(), and update().

94  : array
95  {
96  $certificates = [];
97 
98  $repository = new ilUserCertificateRepository();
99  $activeCertificates = $repository->fetchActiveCertificates($this->user->getId());
100  foreach ($activeCertificates as $certificate) {
101  $certificates[$certificate->getObjId()] = $certificate;
102  }
103 
104  return $certificates;
105  }
+ 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 72 of file class.ilPCVerificationGUI.php.

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

Referenced by initForm(), and update().

72  : array
73  {
74  $nodes = [];
75 
76  $tree = new ilWorkspaceTree($this->user->getId());
77  $root = $tree->getRootId();
78  if ($root) {
79  $root = $tree->getNodeData($root);
80  foreach ($tree->getSubTree($root) as $node) {
81  if (in_array($node['type'], self::SUPPORTED_TYPES, true)) {
82  $nodes[$node['obj_id']] = $node;
83  }
84  }
85  }
86 
87  return $nodes;
88  }
getNodeData(int $a_node_id, ?int $a_tree_pk=null)
get all information of a node.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initForm()

ilPCVerificationGUI::initForm ( bool  $a_insert = false)
protected

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

References $data, ilSubEnabledFormPropertyGUI\addSubItem(), ilRadioOption\addSubItem(), ILIAS\Repository\ctrl(), ilDatePresentation\formatDate(), getValidCertificateByIdMap(), getValidWorkspaceCertificateNodeByIdMap(), IL_CAL_UNIX, ILIAS\Repository\lng(), ilFormPropertyGUI\setRequired(), and ilRadioOption\setValue().

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

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

◆ insert()

ilPCVerificationGUI::insert ( ?ilPropertyFormGUI  $a_form = null)

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

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

Referenced by create().

49  : void
50  {
51  $this->displayValidationError();
52 
53  if (!$a_form) {
54  $a_form = $this->initForm(true);
55  }
56  $this->tpl->setContent($a_form->getHTML());
57  }
initForm(bool $a_insert=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

ilPCVerificationGUI::update ( )
Exceptions
JsonException
ilDateTimeException

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

References Vendor\Package\$e, ILIAS\Repository\ctrl(), edit(), getValidCertificateByIdMap(), getValidWorkspaceCertificateNodeByIdMap(), initForm(), ILIAS\Repository\int(), ILIAS\Repository\lng(), and ILIAS\Repository\user().

241  : void
242  {
243  $form = $this->initForm();
244  if ($form->checkInput()) {
245  $option = 'certificate_persistent_option';
246  if ($form->getItemByPostVar('certificate_selection')) {
247  $option = $form->getInput('certificate_selection');
248  }
249 
250  $oldContentData = $this->content_obj->getData();
251 
252  if ('certificate_workspace_option' === $option) {
253  $objectId = (int) $form->getInput('object');
254  $validWorkSpaceCertificates = $this->getValidWorkspaceCertificateNodeByIdMap();
255 
256  if (isset($validWorkSpaceCertificates[$objectId])) {
257  $this->content_obj->setData($validWorkSpaceCertificates[$objectId]['type'], $objectId);
258  }
259  } elseif ('certificate_persistent_option' === $option) {
260  try {
261  $objectId = (int) $form->getInput('persistent_object');
262  $validCertificates = $this->getValidCertificateByIdMap();
263 
264  if (isset($validCertificates[$objectId])) {
265  $certificateFileService = new ilPortfolioCertificateFileService();
266  $certificateFileService->createCertificateFile(
267  $this->user->getId(),
268  $objectId
269  );
270  $this->content_obj->setData('crta', $objectId);
271  }
272  } catch (\ILIAS\Filesystem\Exception\FileNotFoundException | \ILIAS\Filesystem\Exception\FileAlreadyExistsException $e) {
273  $this->tpl->setOnScreenMessage('info', $this->lng->txt('certificate_file_not_found_error'), true);
274  $this->log->warning($e->getMessage());
275  } catch (\ILIAS\Filesystem\Exception\IOException $e) {
276  $this->tpl->setOnScreenMessage('info', $this->lng->txt('certificate_file_input_output_error'), true);
277  $this->log->warning($e->getMessage());
278  } catch (ilException $e) {
279  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('error_creating_certificate_pdf'), true);
280  $this->log->error($e->getMessage());
281  $this->ctrl->redirect($this, 'initForm');
282  }
283  }
284 
285  if ('crta' === $oldContentData['type']) {
286  try {
287  $certificateFileService = new ilPortfolioCertificateFileService();
288  $certificateFileService->deleteCertificateFile(
289  $this->user->getId(),
290  (int) $oldContentData['id']
291  );
292  } catch (\ILIAS\Filesystem\Exception\FileNotFoundException $e) {
293  $this->tpl->setOnScreenMessage('info', $this->lng->txt('certificate_file_not_found_error'));
294  $this->log->warning($e->getMessage());
295  } catch (\ILIAS\Filesystem\Exception\IOException $e) {
296  $this->tpl->setOnScreenMessage('info', $this->lng->txt('certificate_file_input_output_error'));
297  $this->log->warning($e->getMessage());
298  }
299  }
300 
301  $this->updated = $this->pg_obj->update();
302  if ($this->updated === true) {
303  $this->ctrl->returnToParent($this, 'jump' . $this->hier_id);
304  }
305  }
306 
307  $this->pg_obj->addHierIDs();
308  $this->edit($form);
309  }
Interface Observer Contains several chained tasks and infos about them.
initForm(bool $a_insert=false)
edit(?ilPropertyFormGUI $a_form=null)
+ Here is the call graph for this function:

Field Documentation

◆ $user

ilObjUser ilPCVerificationGUI::$user
protected

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

◆ SUPPORTED_TYPES

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

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


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