ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 421 of file class.ilMemberExportGUI.php.

422 {
423 if(!count($_POST['id']))
424 {
425 ilUtil::sendFailure($this->lng->txt('ps_select_one'), true);
426 $this->ctrl->redirect($this, 'show');
427 }
428
429 include_once('./Services/Utilities/classes/class.ilConfirmationGUI.php');
430 $confirmation_gui = new ilConfirmationGUI();
431 $confirmation_gui->setFormAction($this->ctrl->getFormAction($this));
432 $confirmation_gui->setHeaderText($this->lng->txt('info_delete_sure') /* .' '.$this->lng->txt('ps_delete_export_files') */);
433 $confirmation_gui->setCancel($this->lng->txt('cancel'), 'show');
434 $confirmation_gui->setConfirm($this->lng->txt('delete'), 'deleteExportFile');
435
436 $counter = 0;
437 foreach($this->fss_export->getMemberExportFiles() as $file)
438 {
439 if(!in_array(md5($file['name']), $_POST['id']))
440 {
441 continue;
442 }
443
444 $confirmation_gui->addItem("id[]", md5($file['name']),
445 strtoupper($file['type']).' - '.
447 }
448
449 $this->tpl->setContent($confirmation_gui->getHTML());
450 }
$_POST["username"]
const IL_CAL_UNIX
Confirmation screen class.
static formatDate(ilDateTime $date)
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 459 of file class.ilMemberExportGUI.php.

460 {
461 if(!count($_POST['id']))
462 {
463 $this->ctrl->redirect($this, 'show');
464 }
465
466 $counter = 0;
467 foreach($this->fss_export->getMemberExportFiles() as $file)
468 {
469 if(!in_array(md5($file['name']), $_POST['id']))
470 {
471 continue;
472 }
473
474 $ret = $this->fss_export->deleteMemberExportFile($file['timest'].'_participant_export_'.
475 $file['type'].'_'.$this->obj_id.'.'.$file['type']);
476
477 //try xlsx if return is false and type is xls
478 if($file['type'] == "xls" && !$ret)
479 {
480 $this->fss_export->deleteMemberExportFile($file['timest'].'_participant_export_'.
481 $file['type'].'_'.$this->obj_id.'.'."xlsx");
482 }
483 }
484
485 ilUtil::sendSuccess($this->lng->txt('ps_files_deleted'), true);
486 $this->ctrl->redirect($this, 'show');
487 }
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 327 of file class.ilMemberExportGUI.php.

328 {
329 foreach($this->fss_export->getMemberExportFiles() as $file)
330 {
331 if($file['name'] == $_SESSION['member_export_filename'])
332 {
333 $content = $this->fss_export->getMemberExportFile($_SESSION['member_export_filename']);
334 ilUtil::deliverData($content,date('Y_m_d_H-i',$file['timest']).
335 '_member_export_'.
336 $this->obj_id.
337 '.csv','text/csv');
338 }
339 }
340 }
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 362 of file class.ilMemberExportGUI.php.

363 {
364 $hash = trim($_GET['fl']);
365 if(!$hash)
366 {
367 $this->ctrl->redirect($this, 'show');
368 }
369
370 foreach($this->fss_export->getMemberExportFiles() as $file)
371 {
372 if(md5($file['name']) == $hash)
373 {
374 $contents = $this->fss_export->getMemberExportFile($file['timest'].'_participant_export_'.
375 $file['type'].'_'.$this->obj_id.'.'.$file['type']);
376
377 // newer export files could be .xlsx
378 if($file['type'] == 'xls' && !$contents)
379 {
380 $contents = $this->fss_export->getMemberExportFile($file['timest'].'_participant_export_'.
381 $file['type'].'_'.$this->obj_id.'.xlsx');
382 $file['type'] = 'xlsx';
383 }
384
385 switch($file['type'])
386 {
387 case 'xlsx':
389 $contents,
390 date('Y_m_d_H-i'.$file['timest']).'_member_export_'.$this->obj_id.'.xlsx',
391 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
392 );
393
394 case 'xls':
396 $contents,
397 date('Y_m_d_H-i'.$file['timest']).'_member_export_'.$this->obj_id.'.xls',
398 'application/vnd.ms-excel'
399 );
400
401 default:
402 case 'csv':
403 ilUtil::deliverData($contents,date('Y_m_d_H-i'.$file['timest']).
404 '_member_export_'.
405 $this->obj_id.
406 '.csv','text/csv');
407 break;
408 }
409 return true;
410 }
411 }
412 }
$_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 include_once('Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
92 if(!ilPrivacySettings::_getInstance()->checkExportAccess($this->ref_id))
93 {
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 {
103 default:
104 if(!$cmd)
105 {
106 $cmd = 'show';
107 }
108 $this->$cmd();
109 break;
110 }
111 }
static _getInstance()
Get instance of ilPrivacySettings.
$cmd
Definition: sahs_server.php:35

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

293 {
294 $this->handleIncoming();
295
296 $this->export = new ilMemberExport($this->ref_id);
297 $this->export->create();
298
299 $filename = time().'_participant_export_csv_'.$this->obj_id.'.csv';
300 $this->fss_export->addMemberExportFile($this->export->getCSVString(),$filename);
301
302 $this->ctrl->redirect($this, 'show');
303 }
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 305 of file class.ilMemberExportGUI.php.

306 {
307 $this->handleIncoming();
308
309 $filename = time().'_participant_export_xls_'.$this->obj_id;
310 $this->fss_export->initMemberExportDirectory();
311 $filepath = $this->fss_export->getMemberExportDirectory().DIRECTORY_SEPARATOR.$filename;
312
313 $this->export = new ilMemberExport($this->ref_id,ilMemberExport::EXPORT_EXCEL);
314 $this->export->setFilename($filepath);
315 $this->export->create();
316
317 $this->ctrl->redirect($this, 'show');
318 }

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

269 {
270 $settings = array();
271 $incoming = $_POST['export_members'];
272 if(is_array($incoming))
273 {
274 foreach($incoming as $id)
275 {
276 $settings[$id] = true;
277 }
278 }
279
280 // Save (form) settings
281 $this->exportSettings = new ilUserFormSettings('memexp');
282 $this->exportSettings->set($settings);
283 $this->exportSettings->store();
284 }

References $_POST.

Referenced by export(), and exportExcel().

+ Here is the caller graph for this function:

◆ initCSV()

ilMemberExportGUI::initCSV ( ilPropertyFormGUI  $a_form = null)

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

233 {
234 if(!$a_form)
235 {
236 $a_form = $this->initSettingsForm();
237 }
238 $this->tpl->setContent($a_form->getHTML());
239 }
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 241 of file class.ilMemberExportGUI.php.

242 {
243 if(!$a_form)
244 {
245 $a_form = $this->initSettingsForm(true);
246 }
247 $this->tpl->setContent($a_form->getHTML());
248 }

References initSettingsForm().

+ Here is the call graph for this function:

◆ initFileSystemStorage()

ilMemberExportGUI::initFileSystemStorage ( )
protected

Init file object.

Returns

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

495 {
496 if($this->type == 'crs')
497 {
498 $this->fss_export = new ilFSStorageCourse($this->obj_id);
499 }
500 if($this->type == 'grp')
501 {
502 $this->fss_export = new ilFSStorageGroup($this->obj_id);
503 }
504 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ initSettingsForm()

ilMemberExportGUI::initSettingsForm (   $a_is_excel = false)
protected

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

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

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

257 {
258 global $ilToolbar;
259
260 $ilToolbar->addButton($this->lng->txt('ps_perform_export'),
261 $this->ctrl->getLinkTarget($this, "initCSV"));
262 $ilToolbar->addButton($this->lng->txt('ps_export_excel'),
263 $this->ctrl->getLinkTarget($this, "initExcel"));
264
265 $this->showFileList();
266 }
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 348 of file class.ilMemberExportGUI.php.

349 {
350 include_once 'Services/Membership/classes/Export/class.ilMemberExportFileTableGUI.php';
351 $tbl = new ilMemberExportFileTableGUI($this, 'show', $this->fss_export);
352 $this->tpl->setContent($tbl->getHTML());
353 }
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: