19declare(strict_types=1);
59 $this->
http = $DIC->http();
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;
79 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'permission_denied'),
true);
80 $this->
ctrl->returnToParent($this);
83 $next_class = $this->
ctrl->getNextClass($this);
84 $cmd = $this->
ctrl->getCmd();
86 switch ($next_class) {
102 $form->setFormAction($this->
ctrl->getFormAction($this));
103 $form->setTitle($this->
lng->txt(
'ps_export_settings'));
106 $form->addCommandButton(
'exportExcel', $this->
lng->txt(
'ps_export_excel'));
108 $form->addCommandButton(
'export', $this->
lng->txt(
'ps_perform_export'));
110 $form->addCommandButton(
'show', $this->
lng->txt(
'cancel'));
115 if ($this->type ===
'crs') {
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;
128 $roles->setValue($current_roles);
131 $current_udata = array();
133 $form->addItem($udata);
136 $this->fields_info->sortExportFields();
137 foreach ($this->fields_info->getFieldsInfo() as $field => $exportable) {
142 if ($this->exportSettings->enabled($field)) {
143 $current_udata[] = $field;
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;
156 $udata->setValue($current_udata);
160 if (count($cdf_fields)) {
162 $form->addItem($cdf);
164 $current_cdf = array();
165 foreach ($cdf_fields as $field_obj) {
166 $field =
'cdf_' . $field_obj->getId();
168 if ($this->exportSettings->enabled($field)) {
169 $current_cdf[] = $field;
173 $cdf->setValue($current_cdf);
178 $this->
lng->loadLanguageModule(
'dateplaner');
180 $chours->setValue(
'consultation_hour');
181 $chours->setChecked($this->exportSettings->enabled(
'consultation_hour'));
182 $form->addItem($chours);
186 $grp_membr->setValue(
'group_memberships');
187 $grp_membr->setChecked($this->exportSettings->enabled(
'group_memberships'));
188 $form->addItem($grp_membr);
197 $this->tpl->setContent($a_form->getHTML());
205 $this->tpl->setContent($a_form->getHTML());
211 $this->
lng->txt(
'ps_perform_export'),
212 $this->ctrl->getLinkTarget($this,
"initCSV")
215 $this->
lng->txt(
'ps_export_excel'),
216 $this->ctrl->getLinkTarget($this,
"initExcel")
226 if ($this->
http->wrapper()->post()->has(
'export_members')) {
227 $incoming = $this->
http->wrapper()->post()->retrieve(
229 $this->
refinery->kindlyTo()->dictOf(
230 $this->refinery->kindlyTo()->string()
234 if (count($incoming)) {
235 foreach ($incoming as
$id) {
236 $settings[
$id] =
true;
242 $this->exportSettings->set($settings);
243 $this->exportSettings->store();
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');
266 $this->fss_export->initMemberExportDirectory();
267 $filepath = $this->fss_export->getMemberExportDirectory() . DIRECTORY_SEPARATOR .
$filename;
270 $this->
export->setFilename($filepath);
273 $this->
ctrl->redirect($this,
'show');
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);
284 date(
'Y_m_d_H-i', $file[
'timest']) .
300 $this->tpl->setContent($tbl->getHTML());
309 if ($this->
http->wrapper()->query()->has(
'fl')) {
310 $fl = $this->
http->wrapper()->query()->retrieve(
312 $this->
refinery->kindlyTo()->string()
318 $this->
ctrl->redirect($this,
'show');
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']);
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';
333 switch ($file[
'type']) {
337 date(
'Y_m_d_H-i' . $file[
'timest']) .
'_member_export_' . $this->obj_id .
'.xlsx',
338 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
345 date(
'Y_m_d_H-i' . $file[
'timest']) .
'_member_export_' . $this->obj_id .
'.xls',
346 'application/vnd.ms-excel'
354 date(
'Y_m_d_H-i' . $file[
'timest']) .
372 if ($this->
http->wrapper()->post()->has(
'id')) {
373 $ids = $this->
http->wrapper()->post()->retrieve(
375 $this->
refinery->kindlyTo()->listOf(
376 $this->refinery->kindlyTo()->string()
389 if (!count($file_ids)) {
390 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'ps_select_one'),
true);
391 $this->
ctrl->redirect($this,
'show');
394 $confirmation_gui->setFormAction($this->
ctrl->getFormAction($this));
395 $confirmation_gui->setHeaderText($this->
lng->txt(
'info_delete_sure') );
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)) {
402 $confirmation_gui->addItem(
405 strtoupper($file[
'type']) .
' - ' .
409 $this->tpl->setContent($confirmation_gui->getHTML());
418 if (!count($file_ids)) {
419 $this->
ctrl->redirect($this,
'show');
421 foreach ($this->fss_export->getMemberExportFiles() as $file) {
422 if (!in_array(md5($file[
'name']), $file_ids)) {
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);
433 if ($file[
'type'] !==
"xls") {
437 $path = $file[
'timest'] .
'_participant_export_xls_' . $this->obj_id .
'.xlsx';
438 if ($this->fss_export->hasMemberExportFile(
$path)) {
439 $this->fss_export->deleteMemberExportFile(
$path);
443 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'ps_files_deleted'),
true);
444 $this->
ctrl->redirect($this,
'show');
449 if ($this->type ===
'crs') {
452 if ($this->type ===
'grp') {
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
static hasObjectBookingEntries(int $a_obj_id, int $a_usr_id)
Check if object has assigned consultation hour appointments.
This class represents an option in a checkbox group.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getFields(int $a_container_id, $a_sort=self::IL_CDF_SORT_NAME)
Get all fields of a container.
Class ilCtrl provides processing control methods.
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
static _getInstanceByType(string $a_type)
Get Singleton Instance.
Table presentation of membership export files.
downloadExportFile()
Download export file.
ilGlobalTemplateInterface $tpl
initSettingsForm(bool $a_is_excel=false)
ilFileSystemAbstractionStorage $fss_export
deleteExportFile()
Delete member export files.
ilUserFormSettings $exportSettings
export()
Export, create member export file and store it in data directory.
__construct(int $a_ref_id)
Constructor @access public.
showFileList()
Show file list of available export files.
ilExportFieldsInfo $fields_info
confirmDeleteExportFile()
Confirm deletion of export files.
initExcel(?ilPropertyFormGUI $a_form=null)
initCSV(?ilPropertyFormGUI $a_form=null)
Class for generation of member export files.
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)
static get(string $a_var)
static deliverData(string $a_data, string $a_filename, string $mime="application/octet-stream")
Interface GlobalHttpState.
static http()
Fetches the global http state from ILIAS.