ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilMemberExportGUI Class Reference
+ Collaboration diagram for ilMemberExportGUI:

Public Member Functions

 __construct ($a_ref_id)
 Constructor. More...
 
 executeCommand ()
 Execute Command. More...
 
 initCSV (ilPropertyFormGUI $a_form=null)
 
 initExcel (ilPropertyFormGUI $a_form=null)
 
 show ()
 Show list of export files. More...
 
 export ()
 Export Create member export file and store it in data directory. More...
 
 exportExcel ()
 
 deliverData ()
 Deliver Data. More...
 
 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 ($a_is_excel=false)
 
 handleIncoming ()
 
 initFileSystemStorage ()
 Init file object. More...
 

Private Attributes

 $ref_id
 
 $obj_id
 
 $type
 
 $ctrl
 
 $tpl
 
 $lng
 
 $fields_info
 
 $fss_export = null
 
 $exportSettings
 

Detailed Description

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

@ilCtrl_Calls ilMemberExportGUI:

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

Constructor & Destructor Documentation

◆ __construct()

ilMemberExportGUI::__construct (   $a_ref_id)

Constructor.

@access public

Parameters

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

65 {
66 global $ilCtrl,$tpl,$lng,$ilUser,$ilObjDataCache;
67
68 $this->ctrl = $ilCtrl;
69 $this->tpl = $tpl;
70 $this->lng = $lng;
71 $this->lng->loadLanguageModule('ps');
72 $this->ref_id = $a_ref_id;
73 $this->obj_id = $ilObjDataCache->lookupObjId($this->ref_id);
74 $this->type = ilObject::_lookupType($this->obj_id);
75
76 $this->fields_info = ilExportFieldsInfo::_getInstanceByType(ilObject::_lookupType($this->obj_id));
77 $this->initFileSystemStorage();
78 }
static _getInstanceByType($a_type)
Get Singleton Instance.
initFileSystemStorage()
Init file object.
static _lookupType($a_id, $a_reference=false)
lookup object type
global $ilCtrl
Definition: ilias.php:18
$ilUser
Definition: imgupload.php:18

References $ilCtrl, $ilUser, $lng, $tpl, ilExportFieldsInfo\_getInstanceByType(), ilObject\_lookupType(), and initFileSystemStorage().

+ Here is the call graph for this function:

Member Function Documentation

◆ confirmDeleteExportFile()

ilMemberExportGUI::confirmDeleteExportFile ( )

Confirm deletion of export files.

@access public

Parameters

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

400 {
401 if (!count($_POST['id'])) {
402 ilUtil::sendFailure($this->lng->txt('ps_select_one'), true);
403 $this->ctrl->redirect($this, 'show');
404 }
405
406 include_once('./Services/Utilities/classes/class.ilConfirmationGUI.php');
407 $confirmation_gui = new ilConfirmationGUI();
408 $confirmation_gui->setFormAction($this->ctrl->getFormAction($this));
409 $confirmation_gui->setHeaderText($this->lng->txt('info_delete_sure') /* .' '.$this->lng->txt('ps_delete_export_files') */);
410 $confirmation_gui->setCancel($this->lng->txt('cancel'), 'show');
411 $confirmation_gui->setConfirm($this->lng->txt('delete'), 'deleteExportFile');
412
413 $counter = 0;
414 foreach ($this->fss_export->getMemberExportFiles() as $file) {
415 if (!in_array(md5($file['name']), $_POST['id'])) {
416 continue;
417 }
418
419 $confirmation_gui->addItem(
420 "id[]",
421 md5($file['name']),
422 strtoupper($file['type']) . ' - ' .
424 );
425 }
426
427 $this->tpl->setContent($confirmation_gui->getHTML());
428 }
$_POST["username"]
const IL_CAL_UNIX
Confirmation screen class.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date @access public.
@classDescription Date and time handling
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$counter
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file

References $_POST, $counter, $file, ilDatePresentation\formatDate(), IL_CAL_UNIX, and ilUtil\sendFailure().

+ Here is the call graph for this function:

◆ deleteExportFile()

ilMemberExportGUI::deleteExportFile ( )

Delete member export files.

@access public

Parameters

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

438 {
439 if (!count($_POST['id'])) {
440 $this->ctrl->redirect($this, 'show');
441 }
442
443 $counter = 0;
444 foreach ($this->fss_export->getMemberExportFiles() as $file) {
445 if (!in_array(md5($file['name']), $_POST['id'])) {
446 continue;
447 }
448
449 $ret = $this->fss_export->deleteMemberExportFile($file['timest'] . '_participant_export_' .
450 $file['type'] . '_' . $this->obj_id . '.' . $file['type']);
451
452 //try xlsx if return is false and type is xls
453 if ($file['type'] == "xls" && !$ret) {
454 $this->fss_export->deleteMemberExportFile($file['timest'] . '_participant_export_' .
455 $file['type'] . '_' . $this->obj_id . '.' . "xlsx");
456 }
457 }
458
459 ilUtil::sendSuccess($this->lng->txt('ps_files_deleted'), true);
460 $this->ctrl->redirect($this, 'show');
461 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$ret
Definition: parser.php:6

References $_POST, $counter, $file, $ret, and ilUtil\sendSuccess().

+ Here is the call graph for this function:

◆ deliverData()

ilMemberExportGUI::deliverData ( )

Deliver Data.

@access public

Parameters

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

311 {
312 foreach ($this->fss_export->getMemberExportFiles() as $file) {
313 if ($file['name'] == $_SESSION['member_export_filename']) {
314 $content = $this->fss_export->getMemberExportFile($_SESSION['member_export_filename']);
315 ilUtil::deliverData($content, date('Y_m_d_H-i', $file['timest']) .
316 '_member_export_' .
317 $this->obj_id .
318 '.csv', 'text/csv');
319 }
320 }
321 }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$_SESSION["AccountId"]
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.

References $_SESSION, $file, date, and ilUtil\deliverData().

+ Here is the call graph for this function:

◆ downloadExportFile()

ilMemberExportGUI::downloadExportFile ( )

Download export file.

@access public

Parameters

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

344 {
345 $hash = trim($_GET['fl']);
346 if (!$hash) {
347 $this->ctrl->redirect($this, 'show');
348 }
349
350 foreach ($this->fss_export->getMemberExportFiles() as $file) {
351 if (md5($file['name']) == $hash) {
352 $contents = $this->fss_export->getMemberExportFile($file['timest'] . '_participant_export_' .
353 $file['type'] . '_' . $this->obj_id . '.' . $file['type']);
354
355 // newer export files could be .xlsx
356 if ($file['type'] == 'xls' && !$contents) {
357 $contents = $this->fss_export->getMemberExportFile($file['timest'] . '_participant_export_' .
358 $file['type'] . '_' . $this->obj_id . '.xlsx');
359 $file['type'] = 'xlsx';
360 }
361
362 switch ($file['type']) {
363 case 'xlsx':
365 $contents,
366 date('Y_m_d_H-i' . $file['timest']) . '_member_export_' . $this->obj_id . '.xlsx',
367 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
368 );
369
370 // no break
371 case 'xls':
373 $contents,
374 date('Y_m_d_H-i' . $file['timest']) . '_member_export_' . $this->obj_id . '.xls',
375 'application/vnd.ms-excel'
376 );
377
378 // no break
379 default:
380 case 'csv':
381 ilUtil::deliverData($contents, date('Y_m_d_H-i' . $file['timest']) .
382 '_member_export_' .
383 $this->obj_id .
384 '.csv', 'text/csv');
385 break;
386 }
387 return true;
388 }
389 }
390 }
$_GET["client_id"]

References $_GET, $contents, $file, date, and ilUtil\deliverData().

+ Here is the call graph for this function:

◆ executeCommand()

ilMemberExportGUI::executeCommand ( )

Execute Command.

@access public

Parameters

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

88 {
89 global $ilAccess,$rbacsystem;
90
91
92 include_once('Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
93 if (!ilPrivacySettings::_getInstance()->checkExportAccess($this->ref_id)) {
94 ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
95 $this->ctrl->returnToParent($this);
96 }
97
98 $next_class = $this->ctrl->getNextClass($this);
99 $cmd = $this->ctrl->getCmd();
100
101 switch ($next_class) {
102 default:
103 if (!$cmd) {
104 $cmd = 'show';
105 }
106 $this->$cmd();
107 break;
108 }
109 }
static _getInstance()
Get instance of ilPrivacySettings.

References ilPrivacySettings\_getInstance(), and ilUtil\sendFailure().

+ Here is the call graph for this function:

◆ export()

ilMemberExportGUI::export ( )

Export Create member export file and store it in data directory.

@access public

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

276 {
277 $this->handleIncoming();
278
279 $this->export = new ilMemberExport($this->ref_id);
280 $this->export->create();
281
282 $filename = time() . '_participant_export_csv_' . $this->obj_id . '.csv';
283 $this->fss_export->addMemberExportFile($this->export->getCSVString(), $filename);
284
285 $this->ctrl->redirect($this, 'show');
286 }
export()
Export Create member export file and store it in data directory.
Class for generation of member export files.

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

289 {
290 $this->handleIncoming();
291
292 $filename = time() . '_participant_export_xls_' . $this->obj_id;
293 $this->fss_export->initMemberExportDirectory();
294 $filepath = $this->fss_export->getMemberExportDirectory() . DIRECTORY_SEPARATOR . $filename;
295
296 $this->export = new ilMemberExport($this->ref_id, ilMemberExport::EXPORT_EXCEL);
297 $this->export->setFilename($filepath);
298 $this->export->create();
299
300 $this->ctrl->redirect($this, 'show');
301 }

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

+ Here is the call graph for this function:

◆ handleIncoming()

ilMemberExportGUI::handleIncoming ( )
protected

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

254 {
255 $settings = array();
256 $incoming = $_POST['export_members'];
257 if (is_array($incoming)) {
258 foreach ($incoming as $id) {
259 $settings[$id] = true;
260 }
261 }
262
263 // Save (form) settings
264 $this->exportSettings = new ilUserFormSettings('memexp');
265 $this->exportSettings->set($settings);
266 $this->exportSettings->store();
267 }
if(!array_key_exists('StateId', $_REQUEST)) $id

References $_POST, and $id.

Referenced by export(), and exportExcel().

+ Here is the caller graph for this function:

◆ initCSV()

ilMemberExportGUI::initCSV ( ilPropertyFormGUI  $a_form = null)

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

216 {
217 if (!$a_form) {
218 $a_form = $this->initSettingsForm();
219 }
220 $this->tpl->setContent($a_form->getHTML());
221 }
initSettingsForm($a_is_excel=false)

References initSettingsForm().

+ Here is the call graph for this function:

◆ initExcel()

ilMemberExportGUI::initExcel ( ilPropertyFormGUI  $a_form = null)

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

224 {
225 if (!$a_form) {
226 $a_form = $this->initSettingsForm(true);
227 }
228 $this->tpl->setContent($a_form->getHTML());
229 }

References initSettingsForm().

+ Here is the call graph for this function:

◆ initFileSystemStorage()

ilMemberExportGUI::initFileSystemStorage ( )
protected

Init file object.

Returns

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

469 {
470 if ($this->type == 'crs') {
471 $this->fss_export = new ilFSStorageCourse($this->obj_id);
472 }
473 if ($this->type == 'grp') {
474 $this->fss_export = new ilFSStorageGroup($this->obj_id);
475 }
476 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ initSettingsForm()

ilMemberExportGUI::initSettingsForm (   $a_is_excel = false)
protected

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

117 {
118 // Check user selection
119 $this->exportSettings = new ilUserFormSettings('memexp');
120
121 include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
122 $form = new ilPropertyFormGUI();
123 $form->setFormAction($this->ctrl->getFormAction($this));
124 $form->setTitle($this->lng->txt('ps_export_settings'));
125
126 if ((bool) $a_is_excel) {
127 $form->addCommandButton('exportExcel', $this->lng->txt('ps_export_excel'));
128 } else {
129 $form->addCommandButton('export', $this->lng->txt('ps_perform_export'));
130 }
131 $form->addCommandButton('show', $this->lng->txt('cancel'));
132
133 // roles
134 $roles = new ilCheckboxGroupInputGUI($this->lng->txt('ps_user_selection'), 'export_members');
135 $roles->addOption(new ilCheckboxOption($this->lng->txt('ps_export_admin'), 'admin'));
136 if ($this->type == 'crs') {
137 $roles->addOption(new ilCheckboxOption($this->lng->txt('ps_export_tutor'), 'tutor'));
138 }
139 $roles->addOption(new ilCheckboxOption($this->lng->txt('ps_export_member'), 'member'));
140 $roles->addOption(new ilCheckboxOption($this->lng->txt('ps_export_sub'), 'subscribers'));
141 $roles->addOption(new ilCheckboxOption($this->lng->txt('ps_export_wait'), 'waiting_list'));
142 $form->addItem($roles);
143
144 $current_roles = array();
145 foreach (array('admin', 'tutor', 'member', 'subscribers', 'waiting_list') as $role) {
146 if ($this->exportSettings->enabled($role)) {
147 $current_roles[] = $role;
148 }
149 }
150 $roles->setValue($current_roles);
151
152 // user data
153 $current_udata = array();
154 $udata = new ilCheckboxGroupInputGUI($this->lng->txt('ps_export_user_data'), 'export_members');
155 $form->addItem($udata);
156
157 // standard fields
158 $this->fields_info->sortExportFields();
159 foreach ($this->fields_info->getFieldsInfo() as $field => $exportable) {
160 if (!$exportable) {
161 continue;
162 }
163 $udata->addOption(new ilCheckboxOption($this->lng->txt($field), $field));
164 if ($this->exportSettings->enabled($field)) {
165 $current_udata[] = $field;
166 }
167 }
168
169 // udf
170 foreach (ilUserDefinedFields::_getInstance()->getExportableFields($this->obj_id) as $field_id => $udf_data) {
171 $field = 'udf_' . $field_id;
172 $udata->addOption(new ilCheckboxOption($udf_data['field_name'], $field));
173 if ($this->exportSettings->enabled($field)) {
174 $current_udata[] = $field;
175 }
176 }
177
178 $udata->setValue($current_udata);
179
180 // course custom data
181 $cdf_fields = ilCourseDefinedFieldDefinition::_getFields($this->obj_id);
182 if (count($cdf_fields)) {
183 $cdf = new ilCheckboxGroupInputGUI($this->lng->txt('ps_' . $this->type . '_user_fields'), 'export_members');
184 $form->addItem($cdf);
185
186 $current_cdf = array();
187 foreach ($cdf_fields as $field_obj) {
188 $field = 'cdf_' . $field_obj->getId();
189 $cdf->addOption(new ilCheckboxOption($field_obj->getName(), $field));
190 if ($this->exportSettings->enabled($field)) {
191 $current_cdf[] = $field;
192 }
193 }
194
195 $cdf->setValue($current_cdf);
196 }
197
198 // consultation hours
199 include_once './Services/Booking/classes/class.ilBookingEntry.php';
200 if (ilBookingEntry::hasObjectBookingEntries($this->obj_id, $GLOBALS['ilUser']->getId())) {
201 $this->lng->loadLanguageModule('dateplaner');
202 $chours = new ilCheckboxInputGUI($this->lng->txt('cal_ch_field_ch'), 'export_members[]');
203 $chours->setValue('consultation_hour');
204 $chours->setChecked($this->exportSettings->enabled('consultation_hour'));
205 $form->addItem($chours);
206 }
207
208 $grp_membr = new ilCheckboxInputGUI($this->lng->txt('crs_members_groups'), 'export_members[]');
209 $grp_membr->setValue('group_memberships');
210 $grp_membr->setChecked($this->exportSettings->enabled('group_memberships'));
211 $form->addItem($grp_membr);
212 return $form;
213 }
static hasObjectBookingEntries($a_obj_id, $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($a_container_id, $a_sort=IL_CDF_SORT_NAME)
Get all fields of a container.
This class represents a property form user interface.
static _getInstance()
Get instance.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
if(isset($_POST['submit'])) $form

References $form, $GLOBALS, ilCourseDefinedFieldDefinition\_getFields(), ilUserDefinedFields\_getInstance(), and ilBookingEntry\hasObjectBookingEntries().

Referenced by initCSV(), and initExcel().

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

◆ show()

ilMemberExportGUI::show ( )

Show list of export files.

@access public

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

238 {
239 global $ilToolbar;
240
241 $ilToolbar->addButton(
242 $this->lng->txt('ps_perform_export'),
243 $this->ctrl->getLinkTarget($this, "initCSV")
244 );
245 $ilToolbar->addButton(
246 $this->lng->txt('ps_export_excel'),
247 $this->ctrl->getLinkTarget($this, "initExcel")
248 );
249
250 $this->showFileList();
251 }
showFileList()
Show file list of available export files.

References showFileList().

+ Here is the call graph for this function:

◆ showFileList()

ilMemberExportGUI::showFileList ( )

Show file list of available export files.

@access public

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

330 {
331 include_once 'Services/Membership/classes/Export/class.ilMemberExportFileTableGUI.php';
332 $tbl = new ilMemberExportFileTableGUI($this, 'show', $this->fss_export);
333 $this->tpl->setContent($tbl->getHTML());
334 }
Table presentation of membership export files.
$tbl
Definition: example_048.php:81

References $tbl.

Referenced by show().

+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilMemberExportGUI::$ctrl
private

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

◆ $exportSettings

ilMemberExportGUI::$exportSettings
private

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

◆ $fields_info

ilMemberExportGUI::$fields_info
private

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

◆ $fss_export

ilMemberExportGUI::$fss_export = null
private

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

◆ $lng

ilMemberExportGUI::$lng
private

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

Referenced by __construct().

◆ $obj_id

ilMemberExportGUI::$obj_id
private

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

Referenced by exportExcel().

◆ $ref_id

ilMemberExportGUI::$ref_id
private

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

◆ $tpl

ilMemberExportGUI::$tpl
private

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

Referenced by __construct().

◆ $type

ilMemberExportGUI::$type
private

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


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