ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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$

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

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

65  {
66  global $DIC;
67 
68  $ilCtrl = $DIC['ilCtrl'];
69  $tpl = $DIC['tpl'];
70  $lng = $DIC['lng'];
71  $ilUser = $DIC['ilUser'];
72  $ilObjDataCache = $DIC['ilObjDataCache'];
73 
74  $this->ctrl = $ilCtrl;
75  $this->tpl = $tpl;
76  $this->lng = $lng;
77  $this->lng->loadLanguageModule('ps');
78  $this->ref_id = $a_ref_id;
79  $this->obj_id = $ilObjDataCache->lookupObjId($this->ref_id);
80  $this->type = ilObject::_lookupType($this->obj_id);
81 
82  $this->fields_info = ilExportFieldsInfo::_getInstanceByType(ilObject::_lookupType($this->obj_id));
83  $this->initFileSystemStorage();
84  }
global $DIC
Definition: saml.php:7
global $ilCtrl
Definition: ilias.php:18
static _getInstanceByType($a_type)
Get Singleton Instance.
$ilUser
Definition: imgupload.php:18
static _lookupType($a_id, $a_reference=false)
lookup object type
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 410 of file class.ilMemberExportGUI.php.

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

411  {
412  if (!array_key_exists('id', $_POST) || !is_array($_POST['id']) || !count($_POST['id'])) {
413  ilUtil::sendFailure($this->lng->txt('ps_select_one'), true);
414  $this->ctrl->redirect($this, 'show');
415  }
416 
417  include_once('./Services/Utilities/classes/class.ilConfirmationGUI.php');
418  $confirmation_gui = new ilConfirmationGUI();
419  $confirmation_gui->setFormAction($this->ctrl->getFormAction($this));
420  $confirmation_gui->setHeaderText($this->lng->txt('info_delete_sure') /* .' '.$this->lng->txt('ps_delete_export_files') */);
421  $confirmation_gui->setCancel($this->lng->txt('cancel'), 'show');
422  $confirmation_gui->setConfirm($this->lng->txt('delete'), 'deleteExportFile');
423 
424  $counter = 0;
425  foreach ($this->fss_export->getMemberExportFiles() as $file) {
426  if (!in_array(md5($file['name']), $_POST['id'])) {
427  continue;
428  }
429 
430  $confirmation_gui->addItem(
431  "id[]",
432  md5($file['name']),
433  strtoupper($file['type']) . ' - ' .
435  );
436  }
437 
438  $this->tpl->setContent($confirmation_gui->getHTML());
439  }
const IL_CAL_UNIX
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
Date and time handling
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$_POST["username"]
Confirmation screen class.
+ Here is the call graph for this function:

◆ deleteExportFile()

ilMemberExportGUI::deleteExportFile ( )

Delete member export files.

public

Parameters

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

References $_POST, and $ret.

449  {
450  if (!count($_POST['id'])) {
451  $this->ctrl->redirect($this, 'show');
452  }
453 
454  $counter = 0;
455  foreach ($this->fss_export->getMemberExportFiles() as $file) {
456  if (!in_array(md5($file['name']), $_POST['id'])) {
457  continue;
458  }
459 
460  $ret = $this->fss_export->deleteMemberExportFile($file['timest'] . '_participant_export_' .
461  $file['type'] . '_' . $this->obj_id . '.' . $file['type']);
462 
463  //try xlsx if return is false and type is xls
464  if ($file['type'] == "xls" && !$ret) {
465  $this->fss_export->deleteMemberExportFile($file['timest'] . '_participant_export_' .
466  $file['type'] . '_' . $this->obj_id . '.' . "xlsx");
467  }
468  }
469 
470  ilUtil::sendSuccess($this->lng->txt('ps_files_deleted'), true);
471  $this->ctrl->redirect($this, 'show');
472  }
$ret
Definition: parser.php:6
$_POST["username"]

◆ deliverData()

ilMemberExportGUI::deliverData ( )

Deliver Data.

public

Parameters

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

References $_SESSION, and ilUtil\deliverData().

322  {
323  foreach ($this->fss_export->getMemberExportFiles() as $file) {
324  if ($file['name'] == $_SESSION['member_export_filename']) {
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.
$_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, and ilUtil\deliverData().

355  {
356  $hash = trim($_GET['fl']);
357  if (!$hash) {
358  $this->ctrl->redirect($this, 'show');
359  }
360 
361  foreach ($this->fss_export->getMemberExportFiles() as $file) {
362  if (md5($file['name']) == $hash) {
363  $contents = $this->fss_export->getMemberExportFile($file['timest'] . '_participant_export_' .
364  $file['type'] . '_' . $this->obj_id . '.' . $file['type']);
365 
366  // newer export files could be .xlsx
367  if ($file['type'] == 'xls' && !$contents) {
368  $contents = $this->fss_export->getMemberExportFile($file['timest'] . '_participant_export_' .
369  $file['type'] . '_' . $this->obj_id . '.xlsx');
370  $file['type'] = 'xlsx';
371  }
372 
373  switch ($file['type']) {
374  case 'xlsx':
376  $contents,
377  date('Y_m_d_H-i' . $file['timest']) . '_member_export_' . $this->obj_id . '.xlsx',
378  'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
379  );
380 
381  // no break
382  case 'xls':
384  $contents,
385  date('Y_m_d_H-i' . $file['timest']) . '_member_export_' . $this->obj_id . '.xls',
386  'application/vnd.ms-excel'
387  );
388 
389  // no break
390  default:
391  case 'csv':
392  ilUtil::deliverData($contents, date('Y_m_d_H-i' . $file['timest']) .
393  '_member_export_' .
394  $this->obj_id .
395  '.csv', 'text/csv');
396  break;
397  }
398  return true;
399  }
400  }
401  }
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
$_GET["client_id"]
+ Here is the call graph for this function:

◆ executeCommand()

ilMemberExportGUI::executeCommand ( )

Execute Command.

public

Parameters

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

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

94  {
95  global $DIC;
96 
97  $ilAccess = $DIC['ilAccess'];
98  $rbacsystem = $DIC['rbacsystem'];
99 
100 
101  include_once('Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
102  if (!ilPrivacySettings::_getInstance()->checkExportAccess($this->ref_id)) {
103  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
104  $this->ctrl->returnToParent($this);
105  }
106 
107  $next_class = $this->ctrl->getNextClass($this);
108  $cmd = $this->ctrl->getCmd();
109 
110  switch ($next_class) {
111  default:
112  if (!$cmd) {
113  $cmd = 'show';
114  }
115  $this->$cmd();
116  break;
117  }
118  }
global $DIC
Definition: saml.php:7
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 286 of file class.ilMemberExportGUI.php.

References $filename, and handleIncoming().

Referenced by exportExcel().

287  {
288  $this->handleIncoming();
289 
290  $this->export = new ilMemberExport($this->ref_id);
291  $this->export->create();
292 
293  $filename = time() . '_participant_export_csv_' . $this->obj_id . '.csv';
294  $this->fss_export->addMemberExportFile($this->export->getCSVString(), $filename);
295 
296  $this->ctrl->redirect($this, 'show');
297  }
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 299 of file class.ilMemberExportGUI.php.

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

300  {
301  $this->handleIncoming();
302 
303  $filename = time() . '_participant_export_xls_' . $this->obj_id;
304  $this->fss_export->initMemberExportDirectory();
305  $filepath = $this->fss_export->getMemberExportDirectory() . DIRECTORY_SEPARATOR . $filename;
306 
307  $this->export = new ilMemberExport($this->ref_id, ilMemberExport::EXPORT_EXCEL);
308  $this->export->setFilename($filepath);
309  $this->export->create();
310 
311  $this->ctrl->redirect($this, 'show');
312  }
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 264 of file class.ilMemberExportGUI.php.

References $_POST, and $id.

Referenced by export(), and exportExcel().

265  {
266  $settings = array();
267  $incoming = $_POST['export_members'];
268  if (is_array($incoming)) {
269  foreach ($incoming as $id) {
270  $settings[$id] = true;
271  }
272  }
273 
274  // Save (form) settings
275  $this->exportSettings = new ilUserFormSettings('memexp');
276  $this->exportSettings->set($settings);
277  $this->exportSettings->store();
278  }
if(!array_key_exists('StateId', $_REQUEST)) $id
$_POST["username"]
+ 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  $a_form = $this->initSettingsForm();
228  }
229  $this->tpl->setContent($a_form->getHTML());
230  }
initSettingsForm($a_is_excel=false)
+ Here is the call graph for this function:

◆ initExcel()

ilMemberExportGUI::initExcel ( ilPropertyFormGUI  $a_form = null)

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

References initSettingsForm().

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

◆ initFileSystemStorage()

ilMemberExportGUI::initFileSystemStorage ( )
protected

Init file object.

Returns

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

Referenced by __construct().

480  {
481  if ($this->type == 'crs') {
482  $this->fss_export = new ilFSStorageCourse($this->obj_id);
483  }
484  if ($this->type == 'grp') {
485  $this->fss_export = new ilFSStorageGroup($this->obj_id);
486  }
487  }
+ Here is the caller graph for this function:

◆ initSettingsForm()

ilMemberExportGUI::initSettingsForm (   $a_is_excel = false)
protected

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

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

Referenced by initCSV(), and initExcel().

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

References $DIC, and showFileList().

247  {
248  global $DIC;
249 
250  $ilToolbar = $DIC['ilToolbar'];
251 
252  $ilToolbar->addButton(
253  $this->lng->txt('ps_perform_export'),
254  $this->ctrl->getLinkTarget($this, "initCSV")
255  );
256  $ilToolbar->addButton(
257  $this->lng->txt('ps_export_excel'),
258  $this->ctrl->getLinkTarget($this, "initExcel")
259  );
260 
261  $this->showFileList();
262  }
showFileList()
Show file list of available export files.
global $DIC
Definition: saml.php:7
+ 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.

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