ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilPRGMembersExportGUI Class Reference

export assignments of PRG More...

+ Inheritance diagram for ilPRGMembersExportGUI:
+ Collaboration diagram for ilPRGMembersExportGUI:

Public Member Functions

 __construct (protected int $ref_id, protected ilStudyProgrammeUserTable $prg_user_table, protected DataFactory $data_factory)
 
 export ()
 
 exportExcel ()
 
 deleteExportFile ()
 
 downloadExportFile ()
 
- Public Member Functions inherited from ilMemberExportGUI
 __construct (int $a_ref_id)
 Constructor public. More...
 
 executeCommand ()
 
 initCSV (?ilPropertyFormGUI $a_form=null)
 
 initExcel (?ilPropertyFormGUI $a_form=null)
 
 show ()
 
 export ()
 Export, create member export file and store it in data directory. More...
 
 exportExcel ()
 
 deliverData ()
 
 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...
 

Data Fields

const USERFORMSETTINGS_ID = 'prg_export_settings'
 
const EXPORT_FILENAME = '%s_PRGAssignment_export_%s_%s'
 

Protected Member Functions

 initSettingsForm (bool $a_is_excel=false)
 
 handleIncoming ()
 
 initFileSystemStorage ()
 
- Protected Member Functions inherited from ilMemberExportGUI
 initSettingsForm (bool $a_is_excel=false)
 
 handleIncoming ()
 
 initFileIdsFromPost ()
 
 initFileSystemStorage ()
 

Protected Attributes

ilUserFormSettings $exportSettings
 
int $obj_id
 
- Protected Attributes inherited from ilMemberExportGUI
GlobalHttpState $http
 
Factory $refinery
 
ilCtrl $ctrl
 
ilGlobalTemplateInterface $tpl
 
ilLanguage $lng
 
ilToolbarGUI $toolbar
 
ilMemberExport $export = null
 
ilExportFieldsInfo $fields_info = null
 
ilFileSystemAbstractionStorage $fss_export = null
 
ilUserFormSettings $exportSettings
 

Private Member Functions

 exportAssignments ($type)
 

Detailed Description

export assignments of PRG

Definition at line 26 of file class.ilPRGMembersExportGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilPRGMembersExportGUI::__construct ( protected int  $ref_id,
protected ilStudyProgrammeUserTable  $prg_user_table,
protected DataFactory  $data_factory 
)

Definition at line 34 of file class.ilPRGMembersExportGUI.php.

References ILIAS\GlobalScreen\Provider\__construct(), and ilObject\_lookupObjId().

38  {
39  $this->obj_id = ilObject::_lookupObjId($ref_id);
41  }
static _lookupObjId(int $ref_id)
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ deleteExportFile()

ilPRGMembersExportGUI::deleteExportFile ( )

Definition at line 169 of file class.ilPRGMembersExportGUI.php.

References ILIAS\Repository\ctrl(), ilMemberExportGUI\initFileIdsFromPost(), and ILIAS\Repository\lng().

169  : void
170  {
171  $file_ids = $this->initFileIdsFromPost();
172  if (!count($file_ids)) {
173  $this->ctrl->redirect($this, 'show');
174  }
175 
176  foreach ($this->fss_export->getMemberExportFiles() as $file) {
177  if (!in_array(md5($file['name']), $_POST['id'])) {
178  continue;
179  }
180  $this->fss_export->deleteMemberExportFile($file['name']);
181  }
182 
183  $this->tpl->setOnScreenMessage('success', $this->lng->txt('ps_files_deleted'), true);
184  $this->ctrl->redirect($this, 'show');
185  }
+ Here is the call graph for this function:

◆ downloadExportFile()

ilPRGMembersExportGUI::downloadExportFile ( )

Definition at line 187 of file class.ilPRGMembersExportGUI.php.

References ILIAS\Repository\ctrl(), ilUtil\deliverData(), ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

187  : void
188  {
189  $fl = '';
190  if ($this->http->wrapper()->query()->has('fl')) {
191  $fl = $this->http->wrapper()->query()->retrieve(
192  'fl',
193  $this->refinery->kindlyTo()->string()
194  );
195  }
196 
197  $hash = trim($fl);
198  if (!$hash) {
199  $this->ctrl->redirect($this, 'show');
200  }
201 
202  foreach ($this->fss_export->getMemberExportFiles() as $file) {
203  if (md5($file['name']) == $hash) {
204  $contents = $this->fss_export->getMemberExportFile($file['name']);
205  $fts = $file['timest'];
206  $dat = date('Y_m_d_H-i', (int)$fts);
207  $down_name = str_replace($fts, $dat, $file['name']);
208 
209  $mime = 'text/csv';
210  if ($file['type'] === 'xlsx') {
211  $mime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
212  }
213  ilUtil::deliverData($contents, $down_name, $mime);
214  }
215  }
216  }
static deliverData(string $a_data, string $a_filename, string $mime="application/octet-stream")
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:

◆ export()

ilPRGMembersExportGUI::export ( )

Definition at line 115 of file class.ilPRGMembersExportGUI.php.

References ilPRGMemberExport\EXPORT_CSV, and exportAssignments().

+ Here is the call graph for this function:

◆ exportAssignments()

ilPRGMembersExportGUI::exportAssignments (   $type)
private

Definition at line 128 of file class.ilPRGMembersExportGUI.php.

References ilMemberExportGUI\$export, $filename, ilMemberExportGUI\$type, ilMemberExport\create(), ILIAS\Repository\ctrl(), ilPRGMemberExport\EXPORT_CSV, ilMemberExport\getCSVString(), handleIncoming(), ILIAS\Repository\lng(), and ilStudyProgrammeDIC\specificDicFor().

Referenced by export(), and exportExcel().

129  {
130  $this->handleIncoming();
131  $prg_user_table = ilStudyProgrammeDIC::specificDicFor(
132  new ilObjStudyProgramme($this->obj_id, false)
133  )['ilStudyProgrammeUserTable'];
134  $prg_user_table->disablePermissionCheck(true);
135 
137  $this->ref_id,
138  $this->obj_id,
139  $prg_user_table,
140  $this->exportSettings,
141  $this->lng,
142  $this->data_factory
143  );
144 
145  $type_str = ($type === ilPRGMemberExport::EXPORT_CSV) ? 'csv' : 'xls';
146 
147  $filename = sprintf(
148  self::EXPORT_FILENAME,
149  time(),
150  $type_str,
151  $this->obj_id
152  );
153 
155  $filename .= '.csv';
156  }
157  $filepath = $this->fss_export->getMemberExportDirectory() . DIRECTORY_SEPARATOR . $filename;
158 
159 
160  $this->fss_export->initMemberExportDirectory();
161  $export->create($type, $filepath);
162 
164  $this->fss_export->addMemberExportFile($export->getCSVString(), $filename);
165  }
166  $this->ctrl->redirect($this, 'show');
167  }
static specificDicFor(ilObjStudyProgramme $prg)
export assignments of PRG
$filename
Definition: buildRTE.php:78
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportExcel()

ilPRGMembersExportGUI::exportExcel ( )

Definition at line 123 of file class.ilPRGMembersExportGUI.php.

References ilPRGMemberExport\EXPORT_EXCEL, and exportAssignments().

+ Here is the call graph for this function:

◆ handleIncoming()

ilPRGMembersExportGUI::handleIncoming ( )
protected

Definition at line 81 of file class.ilPRGMembersExportGUI.php.

References $id, ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by exportAssignments().

81  : void
82  {
83  $settings = [];
84  $incoming = [];
85  if ($this->http->wrapper()->post()->has('export_members')) {
86  $incoming = $this->http->wrapper()->post()->retrieve(
87  'export_members',
88  $this->refinery->kindlyTo()->dictOf(
89  $this->refinery->kindlyTo()->string()
90  )
91  );
92  }
93  if (count($incoming)) {
94  foreach ($incoming as $id) {
95  $settings[$id] = true;
96  }
97  }
98 
99  $this->exportSettings = new ilUserFormSettings(self::USERFORMSETTINGS_ID);
100  $this->exportSettings->set($settings);
101  $this->exportSettings->store();
102  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initFileSystemStorage()

ilPRGMembersExportGUI::initFileSystemStorage ( )
protected

Definition at line 107 of file class.ilPRGMembersExportGUI.php.

107  : void
108  {
109  $this->fss_export = new ilFSStoragePRG($this->obj_id);
110  }
store prg-files

◆ initSettingsForm()

ilPRGMembersExportGUI::initSettingsForm ( bool  $a_is_excel = false)
protected

Definition at line 46 of file class.ilPRGMembersExportGUI.php.

References ilCheckboxGroupInputGUI\addOption(), ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

47  {
48  $this->exportSettings = new ilUserFormSettings(self::USERFORMSETTINGS_ID);
49 
50  $form = new ilPropertyFormGUI();
51  $form->setFormAction($this->ctrl->getFormAction($this));
52  $form->setTitle($this->lng->txt('ps_export_settings'));
53 
54  if ((bool) $a_is_excel) {
55  $form->addCommandButton('exportExcel', $this->lng->txt('ps_export_excel'));
56  } else {
57  $form->addCommandButton('export', $this->lng->txt('ps_perform_export'));
58  }
59  $form->addCommandButton('show', $this->lng->txt('cancel'));
60 
61  $current_udata = array();
62  $udata = new ilCheckboxGroupInputGUI($this->lng->txt('ps_export_user_data'), 'export_members');
63  $form->addItem($udata);
64 
65  $columns = array_merge($this->prg_user_table->getColumns($this->obj_id, true));
66 
67  foreach ($columns as $field_info) {
68  $udata->addOption(new ilCheckboxOption($field_info[1], $field_info[0]));
69  if ($this->exportSettings->enabled($field_info[0])) {
70  $current_udata[] = $field_info[0];
71  }
72  }
73 
74  $udata->setValue($current_udata);
75  return $form;
76  }
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...
This class represents a property in a property form.
+ Here is the call graph for this function:

Field Documentation

◆ $exportSettings

ilUserFormSettings ilPRGMembersExportGUI::$exportSettings
protected

Definition at line 31 of file class.ilPRGMembersExportGUI.php.

◆ $obj_id

int ilPRGMembersExportGUI::$obj_id
protected

Definition at line 32 of file class.ilPRGMembersExportGUI.php.

◆ EXPORT_FILENAME

const ilPRGMembersExportGUI::EXPORT_FILENAME = '%s_PRGAssignment_export_%s_%s'

Definition at line 29 of file class.ilPRGMembersExportGUI.php.

◆ USERFORMSETTINGS_ID

const ilPRGMembersExportGUI::USERFORMSETTINGS_ID = 'prg_export_settings'

Definition at line 28 of file class.ilPRGMembersExportGUI.php.


The documentation for this class was generated from the following file: