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