ILIAS  release_8 Revision v8.24
ilMemberExportGUI Class Reference
+ Collaboration diagram for ilMemberExportGUI:

Public Member Functions

 __construct (int $a_ref_id)
 Constructor @access public. More...
 
 executeCommand ()
 
 initCSV (ilPropertyFormGUI $a_form=null)
 
 initExcel (ilPropertyFormGUI $a_form=null)
 
 show ()
 
 export ()
 Export, create member export file and store it in data directory. More...
 
 exportExcel ()
 
 deliverData ()
 
 showFileList ()
 Show file list of available export files. More...
 
 downloadExportFile ()
 Download export file. More...
 
 confirmDeleteExportFile ()
 Confirm deletion of export files. More...
 
 deleteExportFile ()
 Delete member export files. More...
 

Protected Member Functions

 initSettingsForm (bool $a_is_excel=false)
 
 handleIncoming ()
 
 initFileIdsFromPost ()
 
 initFileSystemStorage ()
 

Protected Attributes

GlobalHttpState $http
 
Factory $refinery
 
ilCtrl $ctrl
 
ilGlobalTemplateInterface $tpl
 
ilLanguage $lng
 
ilToolbarGUI $toolbar
 
ilMemberExport $export = null
 
ilExportFieldsInfo $fields_info = null
 
ilFileSystemAbstractionStorage $fss_export = null
 
ilUserFormSettings $exportSettings
 

Private Attributes

int $ref_id
 
int $obj_id
 
string $type
 

Detailed Description

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

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

Constructor & Destructor Documentation

◆ __construct()

ilMemberExportGUI::__construct ( int  $a_ref_id)

Constructor @access public.

Parameters

Definition at line 52 of file class.ilMemberExportGUI.php.

53 {
54 global $DIC;
55
56 $this->http = $DIC->http();
57 $this->refinery = $DIC->refinery();
58
59 $this->ctrl = $DIC->ctrl();
60 $this->tpl = $DIC->ui()->mainTemplate();
61 $this->toolbar = $DIC->toolbar();
62 $this->lng = $DIC->language();
63 $this->lng->loadLanguageModule('ps');
64 $this->ref_id = $a_ref_id;
65 $this->obj_id = ilObject::_lookupObjId($this->ref_id);
66 $this->type = ilObject::_lookupType($this->obj_id);
67
68 $this->fields_info = ilExportFieldsInfo::_getInstanceByType(ilObject::_lookupType($this->obj_id));
69 $this->initFileSystemStorage();
70 }
static _getInstanceByType(string $a_type)
Get Singleton Instance.
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)
global $DIC
Definition: feed.php:28
static http()
Fetches the global http state from ILIAS.

References $DIC, ilExportFieldsInfo\_getInstanceByType(), ilObject\_lookupObjId(), ilObject\_lookupType(), ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), initFileSystemStorage(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ILIAS\Repository\toolbar().

+ Here is the call graph for this function:

Member Function Documentation

◆ confirmDeleteExportFile()

ilMemberExportGUI::confirmDeleteExportFile ( )

Confirm deletion of export files.

Definition at line 382 of file class.ilMemberExportGUI.php.

382 : void
383 {
384 $file_ids = $this->initFileIdsFromPost();
385 if (!count($file_ids)) {
386 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('ps_select_one'), true);
387 $this->ctrl->redirect($this, 'show');
388 }
389 $confirmation_gui = new ilConfirmationGUI();
390 $confirmation_gui->setFormAction($this->ctrl->getFormAction($this));
391 $confirmation_gui->setHeaderText($this->lng->txt('info_delete_sure') /* .' '.$this->lng->txt('ps_delete_export_files') */);
392 $confirmation_gui->setCancel($this->lng->txt('cancel'), 'show');
393 $confirmation_gui->setConfirm($this->lng->txt('delete'), 'deleteExportFile');
394 foreach ($this->fss_export->getMemberExportFiles() as $file) {
395 if (!in_array(md5($file['name']), $file_ids)) {
396 continue;
397 }
398 $confirmation_gui->addItem(
399 "id[]",
400 md5($file['name']),
401 strtoupper($file['type']) . ' - ' .
403 );
404 }
405 $this->tpl->setContent($confirmation_gui->getHTML());
406 }
const IL_CAL_UNIX
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling

References ILIAS\Repository\ctrl(), ilDatePresentation\formatDate(), IL_CAL_UNIX, initFileIdsFromPost(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ deleteExportFile()

ilMemberExportGUI::deleteExportFile ( )

Delete member export files.

Definition at line 411 of file class.ilMemberExportGUI.php.

411 : void
412 {
413 $file_ids = $this->initFileIdsFromPost();
414 if (!count($file_ids)) {
415 $this->ctrl->redirect($this, 'show');
416 }
417 foreach ($this->fss_export->getMemberExportFiles() as $file) {
418 if (!in_array(md5($file['name']), $file_ids)) {
419 continue;
420 }
421
422 $path = $file['timest'] . '_participant_export_' .
423 $file['type'] . '_' . $this->obj_id . '.' . $file['type'];
424 if ($this->fss_export->hasMemberExportFile($path)) {
425 $this->fss_export->deleteMemberExportFile($path);
426 continue;
427 }
428
429 if ($file['type'] !== "xls") {
430 continue;
431 }
432 //try xlsx if type is xls and file can't be found
433 $path = $file['timest'] . '_participant_export_xls_' . $this->obj_id . '.xlsx';
434 if ($this->fss_export->hasMemberExportFile($path)) {
435 $this->fss_export->deleteMemberExportFile($path);
436 }
437 }
438
439 $this->tpl->setOnScreenMessage('success', $this->lng->txt('ps_files_deleted'), true);
440 $this->ctrl->redirect($this, 'show');
441 }
$path
Definition: ltiservices.php:32

References $path, ILIAS\Repository\ctrl(), initFileIdsFromPost(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ deliverData()

ilMemberExportGUI::deliverData ( )

Definition at line 272 of file class.ilMemberExportGUI.php.

272 : void
273 {
274 foreach ($this->fss_export->getMemberExportFiles() as $file) {
275 $member_export_filename = (string) ilSession::get('member_export_filename');
276 if ($file['name'] === $member_export_filename) {
277 $content = $this->fss_export->getMemberExportFile($member_export_filename);
279 $content,
280 date('Y_m_d_H-i', $file['timest']) .
281 '_member_export_' .
282 $this->obj_id .
283 '.csv',
284 'text/csv'
285 );
286 }
287 }
288 }
static get(string $a_var)
static deliverData(string $a_data, string $a_filename, string $mime="application/octet-stream")

References ilUtil\deliverData(), and ilSession\get().

+ Here is the call graph for this function:

◆ downloadExportFile()

ilMemberExportGUI::downloadExportFile ( )

Download export file.

Definition at line 302 of file class.ilMemberExportGUI.php.

302 : void
303 {
304 $fl = '';
305 if ($this->http->wrapper()->query()->has('fl')) {
306 $fl = $this->http->wrapper()->query()->retrieve(
307 'fl',
308 $this->refinery->kindlyTo()->string()
309 );
310 }
311
312 $hash = trim($fl);
313 if (!$hash) {
314 $this->ctrl->redirect($this, 'show');
315 }
316
317 foreach ($this->fss_export->getMemberExportFiles() as $file) {
318 if (md5($file['name']) === $hash) {
319 $contents = $this->fss_export->getMemberExportFile($file['timest'] . '_participant_export_' .
320 $file['type'] . '_' . $this->obj_id . '.' . $file['type']);
321
322 // newer export files could be .xlsx
323 if ($file['type'] === 'xls' && !$contents) {
324 $contents = $this->fss_export->getMemberExportFile($file['timest'] . '_participant_export_' .
325 $file['type'] . '_' . $this->obj_id . '.xlsx');
326 $file['type'] = 'xlsx';
327 }
328
329 switch ($file['type']) {
330 case 'xlsx':
332 $contents,
333 date('Y_m_d_H-i' . $file['timest']) . '_member_export_' . $this->obj_id . '.xlsx',
334 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
335 );
336
337 // no break
338 case 'xls':
340 $contents,
341 date('Y_m_d_H-i' . $file['timest']) . '_member_export_' . $this->obj_id . '.xls',
342 'application/vnd.ms-excel'
343 );
344
345 // no break
346 default:
347 case 'csv':
349 $contents,
350 date('Y_m_d_H-i' . $file['timest']) .
351 '_member_export_' .
352 $this->obj_id .
353 '.csv',
354 'text/csv'
355 );
356 break;
357 }
358 }
359 }
360 }

References ILIAS\Repository\ctrl(), ilUtil\deliverData(), ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ executeCommand()

ilMemberExportGUI::executeCommand ( )

Definition at line 72 of file class.ilMemberExportGUI.php.

72 : void
73 {
74 if (!ilPrivacySettings::getInstance()->checkExportAccess($this->ref_id)) {
75 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
76 $this->ctrl->returnToParent($this);
77 }
78
79 $next_class = $this->ctrl->getNextClass($this);
80 $cmd = $this->ctrl->getCmd();
81
82 switch ($next_class) {
83 default:
84 if (!$cmd) {
85 $cmd = 'show';
86 }
87 $this->$cmd();
88 break;
89 }
90 }

References ILIAS\Repository\ctrl(), ilPrivacySettings\getInstance(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ export()

ilMemberExportGUI::export ( )

Export, create member export file and store it in data directory.

Definition at line 245 of file class.ilMemberExportGUI.php.

245 : void
246 {
247 $this->handleIncoming();
248
249 $this->export = new ilMemberExport($this->ref_id);
250 $this->export->create();
251
252 $filename = time() . '_participant_export_csv_' . $this->obj_id . '.csv';
253 $this->fss_export->addMemberExportFile($this->export->getCSVString(), $filename);
254 $this->ctrl->redirect($this, 'show');
255 }
$filename
Definition: buildRTE.php:78
export()
Export, create member export file and store it in data directory.
Class for generation of member export files.

References $filename, ILIAS\Repository\ctrl(), export(), and handleIncoming().

Referenced by export(), and exportExcel().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportExcel()

ilMemberExportGUI::exportExcel ( )

Definition at line 257 of file class.ilMemberExportGUI.php.

257 : void
258 {
259 $this->handleIncoming();
260
261 $filename = time() . '_participant_export_xls_' . $this->obj_id;
262 $this->fss_export->initMemberExportDirectory();
263 $filepath = $this->fss_export->getMemberExportDirectory() . DIRECTORY_SEPARATOR . $filename;
264
265 $this->export = new ilMemberExport($this->ref_id, ilMemberExport::EXPORT_EXCEL);
266 $this->export->setFilename($filepath);
267 $this->export->create();
268
269 $this->ctrl->redirect($this, 'show');
270 }

References $filename, $obj_id, ILIAS\Repository\ctrl(), export(), ilMemberExport\EXPORT_EXCEL, and handleIncoming().

+ Here is the call graph for this function:

◆ handleIncoming()

ilMemberExportGUI::handleIncoming ( )
protected

Definition at line 218 of file class.ilMemberExportGUI.php.

218 : void
219 {
220 $settings = [];
221 $incoming = [];
222 if ($this->http->wrapper()->post()->has('export_members')) {
223 $incoming = $this->http->wrapper()->post()->retrieve(
224 'export_members',
225 $this->refinery->kindlyTo()->dictOf(
226 $this->refinery->kindlyTo()->string()
227 )
228 );
229 }
230 if (count($incoming)) {
231 foreach ($incoming as $id) {
232 $settings[$id] = true;
233 }
234 }
235
236 // Save (form) settings
237 $this->exportSettings = new ilUserFormSettings('memexp');
238 $this->exportSettings->set($settings);
239 $this->exportSettings->store();
240 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200

References $id, ILIAS\LTI\ToolProvider\$settings, ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by export(), and exportExcel().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initCSV()

ilMemberExportGUI::initCSV ( ilPropertyFormGUI  $a_form = null)

Definition at line 188 of file class.ilMemberExportGUI.php.

188 : void
189 {
190 if (!$a_form) {
191 $a_form = $this->initSettingsForm();
192 }
193 $this->tpl->setContent($a_form->getHTML());
194 }
initSettingsForm(bool $a_is_excel=false)

References initSettingsForm().

+ Here is the call graph for this function:

◆ initExcel()

ilMemberExportGUI::initExcel ( ilPropertyFormGUI  $a_form = null)

Definition at line 196 of file class.ilMemberExportGUI.php.

196 : void
197 {
198 if (!$a_form) {
199 $a_form = $this->initSettingsForm(true);
200 }
201 $this->tpl->setContent($a_form->getHTML());
202 }

References initSettingsForm().

+ Here is the call graph for this function:

◆ initFileIdsFromPost()

ilMemberExportGUI::initFileIdsFromPost ( )
protected
Returns
string[]

Definition at line 365 of file class.ilMemberExportGUI.php.

365 : array
366 {
367 $ids = [];
368 if ($this->http->wrapper()->post()->has('id')) {
369 $ids = $this->http->wrapper()->post()->retrieve(
370 'id',
371 $this->refinery->kindlyTo()->listOf(
372 $this->refinery->kindlyTo()->string()
373 )
374 );
375 }
376 return $ids;
377 }

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by confirmDeleteExportFile(), and deleteExportFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initFileSystemStorage()

ilMemberExportGUI::initFileSystemStorage ( )
protected

Definition at line 443 of file class.ilMemberExportGUI.php.

443 : void
444 {
445 if ($this->type === 'crs') {
446 $this->fss_export = new ilFSStorageCourse($this->obj_id);
447 }
448 if ($this->type === 'grp') {
449 $this->fss_export = new ilFSStorageGroup($this->obj_id);
450 }
451 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

Referenced by __construct().

+ Here is the caller graph for this function:

◆ initSettingsForm()

ilMemberExportGUI::initSettingsForm ( bool  $a_is_excel = false)
protected

Definition at line 92 of file class.ilMemberExportGUI.php.

93 {
94 // Check user selection
95 $this->exportSettings = new ilUserFormSettings('memexp');
96
97 $form = new ilPropertyFormGUI();
98 $form->setFormAction($this->ctrl->getFormAction($this));
99 $form->setTitle($this->lng->txt('ps_export_settings'));
100
101 if ($a_is_excel) {
102 $form->addCommandButton('exportExcel', $this->lng->txt('ps_export_excel'));
103 } else {
104 $form->addCommandButton('export', $this->lng->txt('ps_perform_export'));
105 }
106 $form->addCommandButton('show', $this->lng->txt('cancel'));
107
108 // roles
109 $roles = new ilCheckboxGroupInputGUI($this->lng->txt('ps_user_selection'), 'export_members');
110 $roles->addOption(new ilCheckboxOption($this->lng->txt('ps_export_admin'), 'admin'));
111 if ($this->type === 'crs') {
112 $roles->addOption(new ilCheckboxOption($this->lng->txt('ps_export_tutor'), 'tutor'));
113 }
114 $roles->addOption(new ilCheckboxOption($this->lng->txt('ps_export_member'), 'member'));
115 $roles->addOption(new ilCheckboxOption($this->lng->txt('ps_export_sub'), 'subscribers'));
116 $roles->addOption(new ilCheckboxOption($this->lng->txt('ps_export_wait'), 'waiting_list'));
117 $form->addItem($roles);
118 $current_roles = array();
119 foreach (array('admin', 'tutor', 'member', 'subscribers', 'waiting_list') as $role) {
120 if ($this->exportSettings->enabled($role)) {
121 $current_roles[] = $role;
122 }
123 }
124 $roles->setValue($current_roles);
125
126 // user data
127 $current_udata = array();
128 $udata = new ilCheckboxGroupInputGUI($this->lng->txt('ps_export_user_data'), 'export_members');
129 $form->addItem($udata);
130
131 // standard fields
132 $this->fields_info->sortExportFields();
133 foreach ($this->fields_info->getFieldsInfo() as $field => $exportable) {
134 if (!$exportable) {
135 continue;
136 }
137 $udata->addOption(new ilCheckboxOption($this->lng->txt($field), $field));
138 if ($this->exportSettings->enabled($field)) {
139 $current_udata[] = $field;
140 }
141 }
142
143 // udf
144 foreach (ilUserDefinedFields::_getInstance()->getExportableFields($this->obj_id) as $field_id => $udf_data) {
145 $field = 'udf_' . $field_id;
146 $udata->addOption(new ilCheckboxOption($udf_data['field_name'], $field));
147 if ($this->exportSettings->enabled($field)) {
148 $current_udata[] = $field;
149 }
150 }
151
152 $udata->setValue($current_udata);
153
154 // course custom data
155 $cdf_fields = ilCourseDefinedFieldDefinition::_getFields($this->obj_id);
156 if (count($cdf_fields)) {
157 $cdf = new ilCheckboxGroupInputGUI($this->lng->txt('ps_' . $this->type . '_user_fields'), 'export_members');
158 $form->addItem($cdf);
159
160 $current_cdf = array();
161 foreach ($cdf_fields as $field_obj) {
162 $field = 'cdf_' . $field_obj->getId();
163 $cdf->addOption(new ilCheckboxOption($field_obj->getName(), $field));
164 if ($this->exportSettings->enabled($field)) {
165 $current_cdf[] = $field;
166 }
167 }
168
169 $cdf->setValue($current_cdf);
170 }
171
172 // consultation hours
173 if (ilBookingEntry::hasObjectBookingEntries($this->obj_id, $GLOBALS['DIC']['ilUser']->getId())) {
174 $this->lng->loadLanguageModule('dateplaner');
175 $chours = new ilCheckboxInputGUI($this->lng->txt('cal_ch_field_ch'), 'export_members[]');
176 $chours->setValue('consultation_hour');
177 $chours->setChecked($this->exportSettings->enabled('consultation_hour'));
178 $form->addItem($chours);
179 }
180
181 $grp_membr = new ilCheckboxInputGUI($this->lng->txt('crs_members_groups'), 'export_members[]');
182 $grp_membr->setValue('group_memberships');
183 $grp_membr->setChecked($this->exportSettings->enabled('group_memberships'));
184 $form->addItem($grp_membr);
185 return $form;
186 }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
static hasObjectBookingEntries(int $a_obj_id, int $a_usr_id)
Check if object has assigned consultation hour appointments.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a checkbox property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getFields(int $a_container_id, $a_sort=self::IL_CDF_SORT_NAME)
Get all fields of a container.
This class represents a property form user interface.

References $GLOBALS, ilCourseDefinedFieldDefinition\_getFields(), ilUserDefinedFields\_getInstance(), ILIAS\Repository\ctrl(), ILIAS\Survey\Mode\getId(), ilBookingEntry\hasObjectBookingEntries(), and ILIAS\Repository\lng().

Referenced by initCSV(), and initExcel().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ show()

ilMemberExportGUI::show ( )

Definition at line 204 of file class.ilMemberExportGUI.php.

204 : void
205 {
206 $this->toolbar->addButton(
207 $this->lng->txt('ps_perform_export'),
208 $this->ctrl->getLinkTarget($this, "initCSV")
209 );
210 $this->toolbar->addButton(
211 $this->lng->txt('ps_export_excel'),
212 $this->ctrl->getLinkTarget($this, "initExcel")
213 );
214
215 $this->showFileList();
216 }
showFileList()
Show file list of available export files.

References ILIAS\Repository\lng(), showFileList(), and ILIAS\Repository\toolbar().

+ Here is the call graph for this function:

◆ showFileList()

ilMemberExportGUI::showFileList ( )

Show file list of available export files.

Definition at line 293 of file class.ilMemberExportGUI.php.

293 : void
294 {
295 $tbl = new ilMemberExportFileTableGUI($this, 'show', $this->fss_export);
296 $this->tpl->setContent($tbl->getHTML());
297 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

Referenced by show().

+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilCtrl ilMemberExportGUI::$ctrl
protected

Definition at line 37 of file class.ilMemberExportGUI.php.

◆ $export

ilMemberExport ilMemberExportGUI::$export = null
protected

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

◆ $exportSettings

ilUserFormSettings ilMemberExportGUI::$exportSettings
protected

Definition at line 45 of file class.ilMemberExportGUI.php.

◆ $fields_info

ilExportFieldsInfo ilMemberExportGUI::$fields_info = null
protected

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

◆ $fss_export

ilFileSystemAbstractionStorage ilMemberExportGUI::$fss_export = null
protected

Definition at line 44 of file class.ilMemberExportGUI.php.

◆ $http

GlobalHttpState ilMemberExportGUI::$http
protected

Definition at line 34 of file class.ilMemberExportGUI.php.

◆ $lng

ilLanguage ilMemberExportGUI::$lng
protected

Definition at line 39 of file class.ilMemberExportGUI.php.

◆ $obj_id

int ilMemberExportGUI::$obj_id
private

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

Referenced by exportExcel().

◆ $ref_id

int ilMemberExportGUI::$ref_id
private

Definition at line 30 of file class.ilMemberExportGUI.php.

◆ $refinery

Factory ilMemberExportGUI::$refinery
protected

Definition at line 35 of file class.ilMemberExportGUI.php.

◆ $toolbar

ilToolbarGUI ilMemberExportGUI::$toolbar
protected

Definition at line 40 of file class.ilMemberExportGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilMemberExportGUI::$tpl
protected

Definition at line 38 of file class.ilMemberExportGUI.php.

◆ $type

string ilMemberExportGUI::$type
private

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


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