ILIAS  release_8 Revision v8.24
class.ilMemberExportSettingsGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
5
27{
28 protected const TYPE_PRINT_VIEW_SETTINGS = 'print_view';
29 protected const TYPE_EXPORT_SETTINGS = 'member_export';
30 protected const TYPE_PRINT_VIEW_MEMBERS = 'prv_members';
31
32 private string $parent_type = '';
33 private int $parent_obj_id = 0;
34 private \ILIAS\HTTP\Services $http;
35 private \ILIAS\Refinery\Factory $refinery;
36
39 protected ilLanguage $lng;
41
45 public function __construct(string $a_parent_type, int $a_parent_obj_id = 0)
46 {
47 global $DIC;
48
49 $this->parent_type = $a_parent_type;
50 $this->parent_obj_id = $a_parent_obj_id;
51
52 $this->tpl = $DIC->ui()->mainTemplate();
53 $this->ctrl = $DIC->ctrl();
54 $this->lng = $DIC->language();
55 $this->lng->loadLanguageModule('crs');
56 $this->lng->loadLanguageModule('mem');
57 $this->rbacsystem = $DIC->rbac()->system();
58 $this->http = $DIC->http();
59 $this->refinery = $DIC->refinery();
60 }
61
62 private function getLang(): ilLanguage
63 {
64 return $this->lng;
65 }
66
67 public function executeCommand(): void
68 {
69 $next_class = $this->ctrl->getNextClass($this);
70 $cmd = $this->ctrl->getCmd('printViewSettings');
71
72 switch ($next_class) {
73 default:
74 $this->$cmd();
75 break;
76 }
77 }
78
79 protected function printViewSettings(?ilPropertyFormGUI $form = null): void
80 {
81 if (!$form instanceof ilPropertyFormGUI) {
82 $form = $this->initForm(self::TYPE_PRINT_VIEW_SETTINGS);
83 }
84 $this->tpl->setContent($form->getHTML());
85 }
86
87 protected function initForm(string $a_type): ilPropertyFormGUI
88 {
89 $form = new ilPropertyFormGUI();
90 $form->setFormAction($this->ctrl->getFormAction($this));
91 $form->setTitle($this->getLang()->txt('mem_' . $a_type . '_form'));
92
93 // profile fields
94 $fields['name'] = $this->lng->txt('name');
95 $fields['login'] = $this->lng->txt('login');
96 $fields['email'] = $this->lng->txt('email');
97
98 $field_info = ilExportFieldsInfo::_getInstanceByType($this->parent_type);
99 $field_info->sortExportFields();
100
101 foreach ($field_info->getExportableFields() as $field) {
102 switch ($field) {
103 case 'username':
104 case 'firstname':
105 case 'lastname':
106 case 'email':
107 continue 2;
108 }
109
110 // Check if default enabled
111 $fields[$field] = $this->lng->txt($field);
112 }
113
114 // udf
116 $exportable = array();
117 if ($this->parent_type === 'crs') {
118 $exportable = $udf->getCourseExportableFields();
119 } elseif ($this->parent_type === 'grp') {
120 $exportable = $udf->getGroupExportableFields();
121 }
122 foreach ($exportable as $field_id => $udf_data) {
123 $fields['udf_' . $field_id] = $udf_data['field_name'];
124 }
125
126 $ufields = new ilCheckboxGroupInputGUI($this->lng->txt('user_detail'), 'preset');
127 foreach ($fields as $id => $name) {
128 $ufields->addOption(new ilCheckboxOption($name, $id));
129 }
130 $form->addItem($ufields);
131
133 if ($this->parent_type === 'crs') {
134 if ($privacy->enabledCourseAccessTimes()) {
135 $ufields->addOption(new ilCheckboxOption($this->lng->txt('last_access'), 'access'));
136 }
137 }
138 if ($this->parent_type === 'grp') {
139 if ($privacy->enabledGroupAccessTimes()) {
140 $ufields->addOption(new ilCheckboxOption($this->lng->txt('last_access'), 'access'));
141 }
142 }
143 $ufields->addOption(new ilCheckboxOption($this->lng->txt('crs_status'), 'status'));
144 $ufields->addOption(new ilCheckboxOption($this->lng->txt('crs_passed'), 'passed'));
145
146 $blank = new ilTextInputGUI($this->lng->txt('event_blank_columns'), 'blank');
147 $blank->setMulti(true);
148 $form->addItem($blank);
149
150 $roles = new ilCheckboxGroupInputGUI($this->lng->txt('event_user_selection'), 'selection_of_users');
151
152 $roles->addOption(new ilCheckboxOption($this->lng->txt('event_tbl_admin'), 'role_adm'));
153 if ($this->parent_type === 'crs') {
154 $roles->addOption(new ilCheckboxOption($this->lng->txt('event_tbl_tutor'), 'role_tut'));
155 }
156 $roles->addOption(new ilCheckboxOption($this->lng->txt('event_tbl_member'), 'role_mem'));
157
158 if (!$this->parent_obj_id) {
159 $subscriber = new ilCheckboxOption($this->lng->txt('event_user_selection_include_requests'), 'subscr');
160 $roles->addOption($subscriber);
161
162 $waiting_list = new ilCheckboxOption($this->lng->txt('event_user_selection_include_waiting_list'), 'wlist');
163 $roles->addOption($waiting_list);
164 }
165 $form->addItem($roles);
166
167 switch ($a_type) {
169
170 $ref_id = 0;
171 if ($this->http->wrapper()->query()->has('ref_id')) {
172 $ref_id = $this->http->wrapper()->query()->retrieve(
173 'ref_id',
174 $this->refinery->kindlyTo()->int()
175 );
176 }
177
178 if ($this->rbacsystem->checkAccess('write', $ref_id)) {
179 $form->addCommandButton('savePrintViewSettings', $this->getLang()->txt('save'));
180 }
181 break;
182 }
183
184 $identifier = $this->parent_type . 's_pview';
185 if ($this->parent_obj_id) {
186 $identifier_for_object = $identifier . '_' . $this->parent_obj_id;
187 } else {
188 $identifier_for_object = $identifier . '_0';
189 }
190
191 $settings = new ilUserFormSettings($identifier_for_object, -1);
192 if (!$settings->hasStoredEntry()) {
193 // use default settings
194 $settings = new ilUserFormSettings($identifier, -1);
195 }
196 $settings->exportToForm($form);
197
198 return $form;
199 }
200
204 protected function savePrintViewSettings(): void
205 {
206 $form = $this->initForm(self::TYPE_PRINT_VIEW_SETTINGS);
207 if ($form->checkInput()) {
208 $form->setValuesByPost();
209
212
213 $identifier = $this->parent_type . 's_pview';
214 if ($this->parent_obj_id) {
215 $identifier .= '_' . $this->parent_obj_id;
216 }
217
218 $settings = new ilUserFormSettings($identifier, -1);
219 $settings->importFromForm($form);
220 $settings->store();
221
222 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
223 $this->ctrl->redirect($this, 'printViewSettings');
224 }
225 }
226}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
language handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
savePrintViewSettings()
Save print view settings.
__construct(string $a_parent_type, int $a_parent_obj_id=0)
Constructor.
printViewSettings(?ilPropertyFormGUI $form=null)
This class represents a property form user interface.
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
This class represents a text property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static deleteAllForPrefix(string $a_prefix)
Delete all entries for prefix.
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:67
if($format !==null) $name
Definition: metadata.php:247
static http()
Fetches the global http state from ILIAS.
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200