ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
 

Detailed Description

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

ilMemberExportGUI:

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

Constructor & Destructor Documentation

◆ __construct()

ilMemberExportGUI::__construct (   $a_ref_id)

Constructor.

public

Parameters

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

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

61  {
62  global $ilCtrl,$tpl,$lng,$ilUser,$ilObjDataCache;
63 
64  $this->ctrl = $ilCtrl;
65  $this->tpl = $tpl;
66  $this->lng = $lng;
67  $this->lng->loadLanguageModule('ps');
68  $this->ref_id = $a_ref_id;
69  $this->obj_id = $ilObjDataCache->lookupObjId($this->ref_id);
70  $this->type = ilObject::_lookupType($this->obj_id);
71 
72  $this->fields_info = ilExportFieldsInfo::_getInstanceByType(ilObject::_lookupType($this->obj_id));
73  $this->initFileSystemStorage();
74  }
global $ilCtrl
Definition: ilias.php:18
static _getInstanceByType($a_type)
Get Singleton Instance.
static _lookupType($a_id, $a_reference=false)
lookup object type
global $ilUser
Definition: imgupload.php:15
initFileSystemStorage()
Init file object.
+ Here is the call graph for this function:

Member Function Documentation

◆ confirmDeleteExportFile()

ilMemberExportGUI::confirmDeleteExportFile ( )

Confirm deletion of export files.

public

Parameters

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

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

399  {
400  if(!count($_POST['id']))
401  {
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  {
416  if(!in_array(md5($file['name']), $_POST['id']))
417  {
418  continue;
419  }
420 
421  $confirmation_gui->addItem("id[]", md5($file['name']),
422  strtoupper($file['type']).' - '.
424  }
425 
426  $this->tpl->setContent($confirmation_gui->getHTML());
427  }
print $file
$_POST['username']
Definition: cron.php:12
const IL_CAL_UNIX
static formatDate(ilDateTime $date)
Format a date public.
Date and time handling
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Confirmation screen class.
+ Here is the call graph for this function:

◆ deleteExportFile()

ilMemberExportGUI::deleteExportFile ( )

Delete member export files.

public

Parameters

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

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

437  {
438  if(!count($_POST['id']))
439  {
440  $this->ctrl->redirect($this, 'show');
441  }
442 
443  $counter = 0;
444  foreach($this->fss_export->getMemberExportFiles() as $file)
445  {
446  if(!in_array(md5($file['name']), $_POST['id']))
447  {
448  continue;
449  }
450 
451  $this->fss_export->deleteMemberExportFile($file['timest'].'_participant_export_'.$file['type'].'_'.$this->obj_id.'.'.$file['type']);
452  }
453 
454  ilUtil::sendSuccess($this->lng->txt('ps_files_deleted'), true);
455  $this->ctrl->redirect($this, 'show');
456  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
print $file
$_POST['username']
Definition: cron.php:12
+ Here is the call graph for this function:

◆ deliverData()

ilMemberExportGUI::deliverData ( )

Deliver Data.

public

Parameters

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

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

320  {
321  foreach($this->fss_export->getMemberExportFiles() as $file)
322  {
323  if($file['name'] == $_SESSION['member_export_filename'])
324  {
325  $content = $this->fss_export->getMemberExportFile($_SESSION['member_export_filename']);
326  ilUtil::deliverData($content,date('Y_m_d_H-i',$file['timest']).
327  '_member_export_'.
328  $this->obj_id.
329  '.csv','text/csv');
330  }
331  }
332  }
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
print $file
$_SESSION["AccountId"]
+ Here is the call graph for this function:

◆ downloadExportFile()

ilMemberExportGUI::downloadExportFile ( )

Download export file.

public

Parameters

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

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

355  {
356  $hash = trim($_GET['fl']);
357  if(!$hash)
358  {
359  $this->ctrl->redirect($this, 'show');
360  }
361 
362  foreach($this->fss_export->getMemberExportFiles() as $file)
363  {
364  if(md5($file['name']) == $hash)
365  {
366  $contents = $this->fss_export->getMemberExportFile($file['timest'].'_participant_export_'.
367  $file['type'].'_'.$this->obj_id.'.'.$file['type']);
368 
369  switch($file['type'])
370  {
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  default:
379  case 'csv':
380  ilUtil::deliverData($contents,date('Y_m_d_H-i'.$file['timest']).
381  '_member_export_'.
382  $this->obj_id.
383  '.csv','text/csv');
384  break;
385  }
386  return true;
387  }
388  }
389  }
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
print $file
$_GET["client_id"]
+ Here is the call graph for this function:

◆ executeCommand()

ilMemberExportGUI::executeCommand ( )

Execute Command.

public

Parameters

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

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

84  {
85  global $ilAccess,$rbacsystem;
86 
87  include_once('Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
88  if(!ilPrivacySettings::_getInstance()->checkExportAccess($this->ref_id))
89  {
90  ilUtil::sendFailure($this->lng->txt('permission_denied'),true);
91  $this->ctrl->returnToParent($this);
92  }
93 
94  $next_class = $this->ctrl->getNextClass($this);
95  $cmd = $this->ctrl->getCmd();
96 
97  switch($next_class)
98  {
99  default:
100  if(!$cmd)
101  {
102  $cmd = 'show';
103  }
104  $this->$cmd();
105  break;
106  }
107  }
$cmd
Definition: sahs_server.php:35
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static _getInstance()
Get instance of ilPrivacySettings.
+ Here is the call graph for this function:

◆ export()

ilMemberExportGUI::export ( )

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

public

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

References $filename, and handleIncoming().

Referenced by exportExcel().

285  {
286  $this->handleIncoming();
287 
288  $this->export = new ilMemberExport($this->ref_id);
289  $this->export->create();
290 
291  $filename = time().'_participant_export_csv_'.$this->obj_id.'.csv';
292  $this->fss_export->addMemberExportFile($this->export->getCSVString(),$filename);
293 
294  $this->ctrl->redirect($this, 'show');
295  }
Class for generation of member export files.
export()
Export Create member export file and store it in data directory.
$filename
Definition: buildRTE.php:89
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportExcel()

ilMemberExportGUI::exportExcel ( )

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

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

298  {
299  $this->handleIncoming();
300 
301  $filename = time().'_participant_export_xls_'.$this->obj_id.'.xls';
302  $this->fss_export->initMemberExportDirectory();
303  $filepath = $this->fss_export->getMemberExportDirectory().DIRECTORY_SEPARATOR.$filename;
304 
305  $this->export = new ilMemberExport($this->ref_id,ilMemberExport::EXPORT_EXCEL);
306  $this->export->setFilename($filepath);
307  $this->export->create();
308 
309  $this->ctrl->redirect($this, 'show');
310  }
Class for generation of member export files.
export()
Export Create member export file and store it in data directory.
$filename
Definition: buildRTE.php:89
+ Here is the call graph for this function:

◆ handleIncoming()

ilMemberExportGUI::handleIncoming ( )
protected

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

References $_POST.

Referenced by export(), and exportExcel().

261  {
262  $settings = array();
263  $incoming = $_POST['export_members'];
264  if(is_array($incoming))
265  {
266  foreach($incoming as $id)
267  {
268  $settings[$id] = true;
269  }
270  }
271 
272  // Save (form) settings
273  $this->exportSettings = new ilUserFormSettings('memexp');
274  $this->exportSettings->set($settings);
275  $this->exportSettings->store();
276  }
$_POST['username']
Definition: cron.php:12
+ Here is the caller graph for this function:

◆ initCSV()

ilMemberExportGUI::initCSV ( ilPropertyFormGUI  $a_form = null)

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

References initSettingsForm().

225  {
226  if(!$a_form)
227  {
228  $a_form = $this->initSettingsForm();
229  }
230  $this->tpl->setContent($a_form->getHTML());
231  }
initSettingsForm($a_is_excel=false)
+ Here is the call graph for this function:

◆ initExcel()

ilMemberExportGUI::initExcel ( ilPropertyFormGUI  $a_form = null)

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

References initSettingsForm().

234  {
235  if(!$a_form)
236  {
237  $a_form = $this->initSettingsForm(true);
238  }
239  $this->tpl->setContent($a_form->getHTML());
240  }
initSettingsForm($a_is_excel=false)
+ Here is the call graph for this function:

◆ initFileSystemStorage()

ilMemberExportGUI::initFileSystemStorage ( )
protected

Init file object.

Returns

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

Referenced by __construct().

464  {
465  if($this->type == 'crs')
466  {
467  $this->fss_export = new ilFSStorageCourse($this->obj_id);
468  }
469  if($this->type == 'grp')
470  {
471  $this->fss_export = new ilFSStorageGroup($this->obj_id);
472  }
473  }
+ Here is the caller graph for this function:

◆ initSettingsForm()

ilMemberExportGUI::initSettingsForm (   $a_is_excel = false)
protected

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

References $GLOBALS, ilCourseDefinedFieldDefinition\_getFields(), ilUserDefinedFields\_getInstance(), ilCheckboxGroupInputGUI\addOption(), ilBookingEntry\hasObjectBookingEntries(), and ilCheckboxInputGUI\setValue().

Referenced by initCSV(), and initExcel().

115  {
116  // Check user selection
117  $this->exportSettings = new ilUserFormSettings('memexp');
118 
119  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
120  $form = new ilPropertyFormGUI();
121  $form->setFormAction($this->ctrl->getFormAction($this));
122  $form->setTitle($this->lng->txt('ps_export_settings'));
123 
124  if((bool)$a_is_excel)
125  {
126  $form->addCommandButton('exportExcel', $this->lng->txt('ps_export_excel'));
127  }
128  else
129  {
130  $form->addCommandButton('export', $this->lng->txt('ps_perform_export'));
131  }
132  $form->addCommandButton('show', $this->lng->txt('cancel'));
133 
134  // roles
135  $roles = new ilCheckboxGroupInputGUI($this->lng->txt('ps_user_selection'), 'export_members');
136  $roles->addOption(new ilCheckboxOption($this->lng->txt('ps_export_admin'), 'admin'));
137  if($this->type == 'crs')
138  {
139  $roles->addOption(new ilCheckboxOption($this->lng->txt('ps_export_tutor'), 'tutor'));
140  }
141  $roles->addOption(new ilCheckboxOption($this->lng->txt('ps_export_member'), 'member'));
142  $roles->addOption(new ilCheckboxOption($this->lng->txt('ps_export_sub'), 'subscribers'));
143  $roles->addOption(new ilCheckboxOption($this->lng->txt('ps_export_wait'), 'waiting_list'));
144  $form->addItem($roles);
145 
146  $current_roles = array();
147  foreach(array('admin', 'tutor', 'member', 'subscribers', 'waiting_list') as $role)
148  {
149  if($this->exportSettings->enabled($role))
150  {
151  $current_roles[] = $role;
152  }
153  }
154  $roles->setValue($current_roles);
155 
156  // user data
157  $current_udata = array();
158  $udata = new ilCheckboxGroupInputGUI($this->lng->txt('ps_export_user_data'), 'export_members');
159  $form->addItem($udata);
160 
161  // standard fields
162  $this->fields_info->sortExportFields();
163  foreach($this->fields_info->getFieldsInfo() as $field => $exportable)
164  {
165  if(!$exportable)
166  {
167  continue;
168  }
169  $udata->addOption(new ilCheckboxOption($this->lng->txt($field), $field));
170  if($this->exportSettings->enabled($field))
171  {
172  $current_udata[] = $field;
173  }
174  }
175 
176  // udf
177  foreach(ilUserDefinedFields::_getInstance()->getExportableFields($this->obj_id) as $field_id => $udf_data)
178  {
179  $field = 'udf_'.$field_id;
180  $udata->addOption(new ilCheckboxOption($udf_data['field_name'], $field));
181  if($this->exportSettings->enabled($field))
182  {
183  $current_udata[] = $field;
184  }
185  }
186 
187  $udata->setValue($current_udata);
188 
189  // course custom data
190  $cdf_fields = ilCourseDefinedFieldDefinition::_getFields($this->obj_id);
191  if(count($cdf_fields))
192  {
193  $cdf = new ilCheckboxGroupInputGUI($this->lng->txt('ps_'.$this->type.'_user_fields'), 'export_members');
194  $form->addItem($cdf);
195 
196  $current_cdf = array();
197  foreach($cdf_fields as $field_obj)
198  {
199  $field = 'cdf_'.$field_obj->getId();
200  $cdf->addOption(new ilCheckboxOption($field_obj->getName(), $field));
201  if($this->exportSettings->enabled($field))
202  {
203  $current_cdf[] = $field;
204  }
205  }
206 
207  $cdf->setValue($current_cdf);
208  }
209 
210  // consultation hours
211  include_once './Services/Booking/classes/class.ilBookingEntry.php';
212  if(ilBookingEntry::hasObjectBookingEntries($this->obj_id, $GLOBALS['ilUser']->getId()))
213  {
214  $this->lng->loadLanguageModule('dateplaner');
215  $chours = new ilCheckboxInputGUI($this->lng->txt('cal_ch_field_ch'), 'export_members[]');
216  $chours->setValue('consultation_hour');
217  $chours->setChecked($this->exportSettings->enabled('consultation_hour'));
218  $form->addItem($chours);
219  }
220 
221  return $form;
222  }
This class represents an option in a checkbox group.
static hasObjectBookingEntries($a_obj_id, $a_usr_id)
Check if object has assigned consultation hour appointments.
static _getInstance()
Get instance.
This class represents a property form user interface.
This class represents a checkbox property in a property form.
setValue($a_value)
Set Value.
This class represents a property in a property form.
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
static _getFields($a_container_id, $a_sort=IL_CDF_SORT_NAME)
Get all fields of a container.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ show()

ilMemberExportGUI::show ( )

Show list of export files.

public

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

References showFileList().

249  {
250  global $ilToolbar;
251 
252  $ilToolbar->addButton($this->lng->txt('ps_perform_export'),
253  $this->ctrl->getLinkTarget($this, "initCSV"));
254  $ilToolbar->addButton($this->lng->txt('ps_export_excel'),
255  $this->ctrl->getLinkTarget($this, "initExcel"));
256 
257  $this->showFileList();
258  }
showFileList()
Show file list of available export files.
+ Here is the call graph for this function:

◆ showFileList()

ilMemberExportGUI::showFileList ( )

Show file list of available export files.

public

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

References $tbl.

Referenced by show().

341  {
342  include_once 'Services/Membership/classes/Export/class.ilMemberExportFileTableGUI.php';
343  $tbl = new ilMemberExportFileTableGUI($this, 'show', $this->fss_export);
344  $this->tpl->setContent($tbl->getHTML());
345  }
$tbl
Definition: example_048.php:81
Table presentation of membership export files.
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilMemberExportGUI::$ctrl
private

Definition at line 46 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.

◆ $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: