3 declare(strict_types=1);
56 $this->
http = $DIC->http();
59 $this->
ctrl = $DIC->ctrl();
60 $this->tpl = $DIC->ui()->mainTemplate();
61 $this->
toolbar = $DIC->toolbar();
62 $this->
lng = $DIC->language();
63 $this->
lng->loadLanguageModule(
'ps');
64 $this->ref_id = $a_ref_id;
75 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'permission_denied'),
true);
76 $this->
ctrl->returnToParent($this);
79 $next_class = $this->
ctrl->getNextClass($this);
80 $cmd = $this->
ctrl->getCmd();
82 switch ($next_class) {
98 $form->setFormAction($this->
ctrl->getFormAction($this));
99 $form->setTitle($this->
lng->txt(
'ps_export_settings'));
102 $form->addCommandButton(
'exportExcel', $this->
lng->txt(
'ps_export_excel'));
104 $form->addCommandButton(
'export', $this->
lng->txt(
'ps_perform_export'));
106 $form->addCommandButton(
'show', $this->
lng->txt(
'cancel'));
111 if ($this->type ===
'crs') {
116 $roles->addOption(
new ilCheckboxOption($this->
lng->txt(
'ps_export_wait'),
'waiting_list'));
117 $form->addItem($roles);
118 $current_roles = array();
119 foreach (array(
'admin',
'tutor',
'member',
'subscribers',
'waiting_list') as $role) {
120 if ($this->exportSettings->enabled($role)) {
121 $current_roles[] = $role;
124 $roles->setValue($current_roles);
127 $current_udata = array();
129 $form->addItem($udata);
132 $this->fields_info->sortExportFields();
133 foreach ($this->fields_info->getFieldsInfo() as $field => $exportable) {
138 if ($this->exportSettings->enabled($field)) {
139 $current_udata[] = $field;
145 $field =
'udf_' . $field_id;
147 if ($this->exportSettings->enabled($field)) {
148 $current_udata[] = $field;
152 $udata->setValue($current_udata);
156 if (count($cdf_fields)) {
158 $form->addItem($cdf);
160 $current_cdf = array();
161 foreach ($cdf_fields as $field_obj) {
162 $field =
'cdf_' . $field_obj->getId();
164 if ($this->exportSettings->enabled($field)) {
165 $current_cdf[] = $field;
169 $cdf->setValue($current_cdf);
174 $this->
lng->loadLanguageModule(
'dateplaner');
176 $chours->
setValue(
'consultation_hour');
177 $chours->setChecked($this->exportSettings->enabled(
'consultation_hour'));
178 $form->addItem($chours);
182 $grp_membr->
setValue(
'group_memberships');
183 $grp_membr->setChecked($this->exportSettings->enabled(
'group_memberships'));
184 $form->addItem($grp_membr);
193 $this->tpl->setContent($a_form->getHTML());
201 $this->tpl->setContent($a_form->getHTML());
207 $this->
lng->txt(
'ps_perform_export'),
208 $this->
ctrl->getLinkTarget($this,
"initCSV")
211 $this->
lng->txt(
'ps_export_excel'),
212 $this->
ctrl->getLinkTarget($this,
"initExcel")
222 if ($this->
http->wrapper()->post()->has(
'export_members')) {
223 $incoming = $this->
http->wrapper()->post()->retrieve(
225 $this->
refinery->kindlyTo()->dictOf(
226 $this->
refinery->kindlyTo()->string()
230 if (count($incoming)) {
231 foreach ($incoming as
$id) {
239 $this->exportSettings->store();
252 $filename = time() .
'_participant_export_csv_' . $this->obj_id .
'.csv';
253 $this->fss_export->addMemberExportFile($this->
export->getCSVString(),
$filename);
254 $this->
ctrl->redirect($this,
'show');
262 $this->fss_export->initMemberExportDirectory();
263 $filepath = $this->fss_export->getMemberExportDirectory() . DIRECTORY_SEPARATOR .
$filename;
266 $this->
export->setFilename($filepath);
269 $this->
ctrl->redirect($this,
'show');
274 foreach ($this->fss_export->getMemberExportFiles() as $file) {
275 $member_export_filename = (string)
ilSession::get(
'member_export_filename');
276 if ($file[
'name'] === $member_export_filename) {
277 $content = $this->fss_export->getMemberExportFile($member_export_filename);
280 date(
'Y_m_d_H-i', $file[
'timest']) .
296 $this->tpl->setContent($tbl->getHTML());
305 if ($this->
http->wrapper()->query()->has(
'fl')) {
306 $fl = $this->
http->wrapper()->query()->retrieve(
308 $this->
refinery->kindlyTo()->string()
314 $this->
ctrl->redirect($this,
'show');
317 foreach ($this->fss_export->getMemberExportFiles() as $file) {
318 if (md5($file[
'name']) === $hash) {
319 $contents = $this->fss_export->getMemberExportFile($file[
'timest'] .
'_participant_export_' .
320 $file[
'type'] .
'_' . $this->obj_id .
'.' . $file[
'type']);
323 if ($file[
'type'] ===
'xls' && !$contents) {
324 $contents = $this->fss_export->getMemberExportFile($file[
'timest'] .
'_participant_export_' .
325 $file[
'type'] .
'_' . $this->obj_id .
'.xlsx');
326 $file[
'type'] =
'xlsx';
329 switch ($file[
'type']) {
333 date(
'Y_m_d_H-i' . $file[
'timest']) .
'_member_export_' . $this->obj_id .
'.xlsx',
334 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' 341 date(
'Y_m_d_H-i' . $file[
'timest']) .
'_member_export_' . $this->obj_id .
'.xls',
342 'application/vnd.ms-excel' 350 date(
'Y_m_d_H-i' . $file[
'timest']) .
368 if ($this->
http->wrapper()->post()->has(
'id')) {
369 $ids = $this->
http->wrapper()->post()->retrieve(
371 $this->
refinery->kindlyTo()->listOf(
372 $this->
refinery->kindlyTo()->string()
385 if (!count($file_ids)) {
386 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'ps_select_one'),
true);
387 $this->
ctrl->redirect($this,
'show');
390 $confirmation_gui->setFormAction($this->
ctrl->getFormAction($this));
391 $confirmation_gui->setHeaderText($this->
lng->txt(
'info_delete_sure') );
392 $confirmation_gui->setCancel($this->
lng->txt(
'cancel'),
'show');
393 $confirmation_gui->setConfirm($this->
lng->txt(
'delete'),
'deleteExportFile');
394 foreach ($this->fss_export->getMemberExportFiles() as $file) {
395 if (!in_array(md5($file[
'name']), $file_ids)) {
398 $confirmation_gui->addItem(
401 strtoupper($file[
'type']) .
' - ' .
405 $this->tpl->setContent($confirmation_gui->getHTML());
414 if (!count($file_ids)) {
415 $this->
ctrl->redirect($this,
'show');
417 foreach ($this->fss_export->getMemberExportFiles() as $file) {
418 if (!in_array(md5($file[
'name']), $file_ids)) {
422 $path = $file[
'timest'] .
'_participant_export_' .
423 $file[
'type'] .
'_' . $this->obj_id .
'.' . $file[
'type'];
424 if ($this->fss_export->hasMemberExportFile(
$path)) {
425 $this->fss_export->deleteMemberExportFile(
$path);
429 if ($file[
'type'] !==
"xls") {
433 $path = $file[
'timest'] .
'_participant_export_xls_' . $this->obj_id .
'.xlsx';
434 if ($this->fss_export->hasMemberExportFile(
$path)) {
435 $this->fss_export->deleteMemberExportFile(
$path);
439 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'ps_files_deleted'),
true);
440 $this->
ctrl->redirect($this,
'show');
445 if ($this->type ===
'crs') {
448 if ($this->type ===
'grp') {
Interface GlobalHttpState.
static get(string $a_var)
Class for generation of member export files.
ilFileSystemAbstractionStorage $fss_export
downloadExportFile()
Download export file.
__construct(int $a_ref_id)
Constructor public.
deleteExportFile()
Delete member export files.
showFileList()
Show file list of available export files.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static hasObjectBookingEntries(int $a_obj_id, int $a_usr_id)
Check if object has assigned consultation hour appointments.
export()
Export, create member export file and store it in data directory.
initExcel(ilPropertyFormGUI $a_form=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilUserFormSettings $exportSettings
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
static deliverData(string $a_data, string $a_filename, string $mime="application/octet-stream")
static _getFields(int $a_container_id, $a_sort=self::IL_CDF_SORT_NAME)
Get all fields of a container.
static _lookupObjId(int $ref_id)
ilExportFieldsInfo $fields_info
static http()
Fetches the global http state from ILIAS.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
initSettingsForm(bool $a_is_excel=false)
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
confirmDeleteExportFile()
Confirm deletion of export files.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getInstanceByType(string $a_type)
Get Singleton Instance.
initCSV(ilPropertyFormGUI $a_form=null)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
static _lookupType(int $id, bool $reference=false)
ilGlobalTemplateInterface $tpl
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...