ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilMemberExportGUI Class Reference
+ Inheritance diagram for ilMemberExportGUI:
+ 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
 
Profile $profile
 
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 30 of file class.ilMemberExportGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilMemberExportGUI::__construct ( int  $a_ref_id)

Constructor @access public.

Parameters

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

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

References $DIC, ilExportFieldsInfo\_getInstanceByType(), ilObject\_lookupObjId(), ilObject\_lookupType(), ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), initFileSystemStorage(), ILIAS\Repository\lng(), ILIAS\Repository\profile(), 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 386 of file class.ilMemberExportGUI.php.

386 : void
387 {
388 $file_ids = $this->initFileIdsFromPost();
389 if (!count($file_ids)) {
390 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('ps_select_one'), true);
391 $this->ctrl->redirect($this, 'show');
392 }
393 $confirmation_gui = new ilConfirmationGUI();
394 $confirmation_gui->setFormAction($this->ctrl->getFormAction($this));
395 $confirmation_gui->setHeaderText($this->lng->txt('info_delete_sure') /* .' '.$this->lng->txt('ps_delete_export_files') */);
396 $confirmation_gui->setCancel($this->lng->txt('cancel'), 'show');
397 $confirmation_gui->setConfirm($this->lng->txt('delete'), 'deleteExportFile');
398 foreach ($this->fss_export->getMemberExportFiles() as $file) {
399 if (!in_array(md5($file['name']), $file_ids)) {
400 continue;
401 }
402 $confirmation_gui->addItem(
403 "id[]",
404 md5($file['name']),
405 strtoupper($file['type']) . ' - ' .
407 );
408 }
409 $this->tpl->setContent($confirmation_gui->getHTML());
410 }
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, ?ilObjUser $user=null,)
@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.

Reimplemented in ilPRGMembersExportGUI.

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

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

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

+ Here is the call graph for this function:

◆ deliverData()

ilMemberExportGUI::deliverData ( )

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

276 : void
277 {
278 foreach ($this->fss_export->getMemberExportFiles() as $file) {
279 $member_export_filename = (string) ilSession::get('member_export_filename');
280 if ($file['name'] === $member_export_filename) {
281 $content = $this->fss_export->getMemberExportFile($member_export_filename);
283 $content,
284 date('Y_m_d_H-i', $file['timest']) .
285 '_member_export_' .
286 $this->obj_id .
287 '.csv',
288 'text/csv'
289 );
290 }
291 }
292 }
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.

Reimplemented in ilPRGMembersExportGUI.

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

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

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 76 of file class.ilMemberExportGUI.php.

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

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.

Reimplemented in ilPRGMembersExportGUI.

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

249 : void
250 {
251 $this->handleIncoming();
252
253 $this->export = new ilMemberExport($this->ref_id);
254 $this->export->create();
255
256 $filename = time() . '_participant_export_csv_' . $this->obj_id . '.csv';
257 $this->fss_export->addMemberExportFile($this->export->getCSVString(), $filename);
258 $this->ctrl->redirect($this, 'show');
259 }
$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 ( )

Reimplemented in ilPRGMembersExportGUI.

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

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

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

Reimplemented in ilPRGMembersExportGUI.

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

222 : void
223 {
224 $settings = [];
225 $incoming = [];
226 if ($this->http->wrapper()->post()->has('export_members')) {
227 $incoming = $this->http->wrapper()->post()->retrieve(
228 'export_members',
229 $this->refinery->kindlyTo()->dictOf(
230 $this->refinery->kindlyTo()->string()
231 )
232 );
233 }
234 if (count($incoming)) {
235 foreach ($incoming as $id) {
236 $settings[$id] = true;
237 }
238 }
239
240 // Save (form) settings
241 $this->exportSettings = new ilUserFormSettings('memexp');
242 $this->exportSettings->set($settings);
243 $this->exportSettings->store();
244 }
$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...

References $id, 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 192 of file class.ilMemberExportGUI.php.

192 : void
193 {
194 if (!$a_form) {
195 $a_form = $this->initSettingsForm();
196 }
197 $this->tpl->setContent($a_form->getHTML());
198 }
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 200 of file class.ilMemberExportGUI.php.

200 : void
201 {
202 if (!$a_form) {
203 $a_form = $this->initSettingsForm(true);
204 }
205 $this->tpl->setContent($a_form->getHTML());
206 }

References initSettingsForm().

+ Here is the call graph for this function:

◆ initFileIdsFromPost()

ilMemberExportGUI::initFileIdsFromPost ( )
protected
Returns
string[]

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

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

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

Referenced by confirmDeleteExportFile(), deleteExportFile(), and ilPRGMembersExportGUI\deleteExportFile().

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

◆ initFileSystemStorage()

ilMemberExportGUI::initFileSystemStorage ( )
protected

Reimplemented in ilPRGMembersExportGUI.

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

447 : void
448 {
449 if ($this->type === 'crs') {
450 $this->fss_export = new ilFSStorageCourse($this->obj_id);
451 }
452 if ($this->type === 'grp') {
453 $this->fss_export = new ilFSStorageGroup($this->obj_id);
454 }
455 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ initSettingsForm()

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

Reimplemented in ilPRGMembersExportGUI.

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

97 {
98 // Check user selection
99 $this->exportSettings = new ilUserFormSettings('memexp');
100
101 $form = new ilPropertyFormGUI();
102 $form->setFormAction($this->ctrl->getFormAction($this));
103 $form->setTitle($this->lng->txt('ps_export_settings'));
104
105 if ($a_is_excel) {
106 $form->addCommandButton('exportExcel', $this->lng->txt('ps_export_excel'));
107 } else {
108 $form->addCommandButton('export', $this->lng->txt('ps_perform_export'));
109 }
110 $form->addCommandButton('show', $this->lng->txt('cancel'));
111
112 // roles
113 $roles = new ilCheckboxGroupInputGUI($this->lng->txt('ps_user_selection'), 'export_members');
114 $roles->addOption(new ilCheckboxOption($this->lng->txt('ps_export_admin'), 'admin'));
115 if ($this->type === 'crs') {
116 $roles->addOption(new ilCheckboxOption($this->lng->txt('ps_export_tutor'), 'tutor'));
117 }
118 $roles->addOption(new ilCheckboxOption($this->lng->txt('ps_export_member'), 'member'));
119 $roles->addOption(new ilCheckboxOption($this->lng->txt('ps_export_sub'), 'subscribers'));
120 $roles->addOption(new ilCheckboxOption($this->lng->txt('ps_export_wait'), 'waiting_list'));
121 $form->addItem($roles);
122 $current_roles = array();
123 foreach (array('admin', 'tutor', 'member', 'subscribers', 'waiting_list') as $role) {
124 if ($this->exportSettings->enabled($role)) {
125 $current_roles[] = $role;
126 }
127 }
128 $roles->setValue($current_roles);
129
130 // user data
131 $current_udata = array();
132 $udata = new ilCheckboxGroupInputGUI($this->lng->txt('ps_export_user_data'), 'export_members');
133 $form->addItem($udata);
134
135 // standard fields
136 $this->fields_info->sortExportFields();
137 foreach ($this->fields_info->getFieldsInfo() as $field => $exportable) {
138 if (!$exportable) {
139 continue;
140 }
141 $udata->addOption(new ilCheckboxOption($this->lng->txt($field), $field));
142 if ($this->exportSettings->enabled($field)) {
143 $current_udata[] = $field;
144 }
145 }
146
147 // udf
148 foreach ($this->profile->getVisibleUserDefinedFields(Context::buildFromObjectType($this->type)) as $field) {
149 $field_id = 'udf_' . $field->getIdentifier();
150 $udata->addOption(new ilCheckboxOption($field->getLabel($this->lng), $field_id));
151 if ($this->exportSettings->enabled($field_id)) {
152 $current_udata[] = $field_id;
153 }
154 }
155
156 $udata->setValue($current_udata);
157
158 // course custom data
159 $cdf_fields = ilCourseDefinedFieldDefinition::_getFields($this->obj_id);
160 if (count($cdf_fields)) {
161 $cdf = new ilCheckboxGroupInputGUI($this->lng->txt('ps_' . $this->type . '_user_fields'), 'export_members');
162 $form->addItem($cdf);
163
164 $current_cdf = array();
165 foreach ($cdf_fields as $field_obj) {
166 $field = 'cdf_' . $field_obj->getId();
167 $cdf->addOption(new ilCheckboxOption($field_obj->getName(), $field));
168 if ($this->exportSettings->enabled($field)) {
169 $current_cdf[] = $field;
170 }
171 }
172
173 $cdf->setValue($current_cdf);
174 }
175
176 // consultation hours
177 if (ilBookingEntry::hasObjectBookingEntries($this->obj_id, $GLOBALS['DIC']['ilUser']->getId())) {
178 $this->lng->loadLanguageModule('dateplaner');
179 $chours = new ilCheckboxInputGUI($this->lng->txt('cal_ch_field_ch'), 'export_members[]');
180 $chours->setValue('consultation_hour');
181 $chours->setChecked($this->exportSettings->enabled('consultation_hour'));
182 $form->addItem($chours);
183 }
184
185 $grp_membr = new ilCheckboxInputGUI($this->lng->txt('crs_members_groups'), 'export_members[]');
186 $grp_membr->setValue('group_memberships');
187 $grp_membr->setChecked($this->exportSettings->enabled('group_memberships'));
188 $form->addItem($grp_membr);
189 return $form;
190 }
static hasObjectBookingEntries(int $a_obj_id, int $a_usr_id)
Check if object has assigned consultation hour appointments.
This class represents a property in a property form.
This class represents a checkbox property in a property form.
This class represents an option in a checkbox group.
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.
$GLOBALS["DIC"]
Definition: wac.php:54

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

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 208 of file class.ilMemberExportGUI.php.

208 : void
209 {
210 $this->toolbar->addButton(
211 $this->lng->txt('ps_perform_export'),
212 $this->ctrl->getLinkTarget($this, "initCSV")
213 );
214 $this->toolbar->addButton(
215 $this->lng->txt('ps_export_excel'),
216 $this->ctrl->getLinkTarget($this, "initExcel")
217 );
218
219 $this->showFileList();
220 }
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 297 of file class.ilMemberExportGUI.php.

297 : void
298 {
299 $tbl = new ilMemberExportFileTableGUI($this, 'show', $this->fss_export);
300 $this->tpl->setContent($tbl->getHTML());
301 }
Table presentation of membership export files.

Referenced by show().

+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilCtrl ilMemberExportGUI::$ctrl
protected

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

◆ $export

ilMemberExport ilMemberExportGUI::$export = null
protected

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

Referenced by ilPRGMembersExportGUI\exportAssignments().

◆ $exportSettings

ilUserFormSettings ilMemberExportGUI::$exportSettings
protected

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

◆ $fields_info

ilExportFieldsInfo ilMemberExportGUI::$fields_info = null
protected

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

◆ $fss_export

ilFileSystemAbstractionStorage ilMemberExportGUI::$fss_export = null
protected

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

◆ $http

GlobalHttpState ilMemberExportGUI::$http
protected

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

◆ $lng

ilLanguage ilMemberExportGUI::$lng
protected

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

◆ $obj_id

int ilMemberExportGUI::$obj_id
private

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

Referenced by exportExcel().

◆ $profile

Profile ilMemberExportGUI::$profile
protected

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

◆ $ref_id

int ilMemberExportGUI::$ref_id
private

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

Referenced by ilPRGMembersExportGUI\__construct().

◆ $refinery

Factory ilMemberExportGUI::$refinery
protected

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

◆ $toolbar

ilToolbarGUI ilMemberExportGUI::$toolbar
protected

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

◆ $tpl

ilGlobalTemplateInterface ilMemberExportGUI::$tpl
protected

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

◆ $type

string ilMemberExportGUI::$type
private

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

Referenced by ilPRGMembersExportGUI\exportAssignments().


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