ILIAS  release_8 Revision v8.24
class.ilObjSearchSettingsGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
23
30{
32 protected Factory $refinery;
33 protected UIServices $ui;
35 protected ilObjUser $user;
36
37 protected bool $read_only = true;
38
39 public function __construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output = true)
40 {
41 global $DIC;
42
43 $this->http = $DIC->http();
44 $this->refinery = $DIC->refinery();
45 $this->ui = $DIC->ui();
46 $this->src_logger = $DIC->logger()->src();
47 $this->user = $DIC->user();
48
49 $this->type = "seas";
50 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
51 $this->lng->loadLanguageModule('search');
52 }
53
54 public function executeCommand(): void
55 {
56 $next_class = $this->ctrl->getNextClass($this);
57 $cmd = $this->ctrl->getCmd();
58 $this->prepareOutput();
59
60 switch ($next_class) {
61 case 'ilpermissiongui':
62 $this->tabs_gui->activateTab('perm_settings');
63 $perm_gui = new ilPermissionGUI($this);
64 $ret = $this->ctrl->forwardCommand($perm_gui);
65 return;
66
67 case 'ilobjsearchsettingsformgui':
68 $this->tabs_gui->activateTab('settings');
69 $settings_gui = new ilObjSearchSettingsFormGUI(
70 $this->http,
71 $this->ctrl,
72 $this->lng,
73 $this->ui,
75 $this->settings,
76 $this->src_logger
77 )
78 );
79 $ret = $this->ctrl->forwardCommand($settings_gui);
80 return;
81
82 case 'ilobjsearchlucenesettingsformgui':
83 $this->tabs_gui->activateTab('lucene_settings_tab');
84 $luc_settings_gui = new ilObjSearchLuceneSettingsFormGUI(
85 $this->http,
86 $this->ctrl,
87 $this->lng,
88 $this->ui,
89 $this->refinery,
90 $this->user,
92 $this->settings,
93 $this->src_logger
94 )
95 );
96 $ret = $this->ctrl->forwardCommand($luc_settings_gui);
97 return;
98 }
99
100 switch ($cmd) {
101 case '':
102 case 'view':
103 case 'settings':
104 $this->redirectToSettings();
105 break;
106
107 case 'luceneSettings':
109 break;
110
111 case 'advancedLuceneSettings':
113 break;
114
115 default:
116 $cmd .= "Object";
117 $this->$cmd();
118 }
119 }
120
121 protected function redirectToSettings(): void
122 {
123 if (!$this->rbac_system->checkAccess('visible,read', $this->object->getRefId())) {
124 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
125 }
126
127 $this->tabs_gui->setTabActive('settings');
128
129 if (!$this->rbac_system->checkAccess('write', $this->object->getRefId())) {
130 $this->ctrl->redirectByClass(
131 [get_class($this),'ilobjsearchsettingsformgui'],
132 'readOnly'
133 );
134 }
135
136 $this->ctrl->redirectByClass(
137 [get_class($this),'ilobjsearchsettingsformgui'],
138 'edit'
139 );
140 }
141
142 protected function redirectToLuceneSettings(): void
143 {
144 if (!$this->rbac_system->checkAccess('visible,read', $this->object->getRefId())) {
145 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
146 }
147
148 $this->tabs_gui->setTabActive('lucene_settings_tab');
149
150 if (!$this->rbac_system->checkAccess('write', $this->object->getRefId())) {
151 $this->ctrl->redirectByClass(
152 [get_class($this),'ilobjsearchlucenesettingsformgui'],
153 'readOnly'
154 );
155 }
156
157 $this->ctrl->redirectByClass(
158 [get_class($this),'ilobjsearchlucenesettingsformgui'],
159 'edit'
160 );
161 }
162
163 public function getAdminTabs(): void
164 {
165 $this->getTabs();
166 }
167
168 protected function getTabs(): void
169 {
170 if ($this->rbac_system->checkAccess("visible,read", $this->object->getRefId())) {
171 $this->tabs_gui->addTab(
172 'settings',
173 $this->lng->txt('settings'),
174 $this->ctrl->getLinkTarget($this, 'settings')
175 );
176 }
177
178 if ($this->rbac_system->checkAccess('read', $this->object->getRefId())) {
179 $this->tabs_gui->addTab(
180 'lucene_advanced_settings',
181 $this->lng->txt('lucene_advanced_settings'),
182 $this->ctrl->getLinkTarget($this, 'advancedLuceneSettings')
183 );
184 }
185
186 if ($this->rbac_system->checkAccess('read', $this->object->getRefId())) {
187 $this->tabs_gui->addTab(
188 'lucene_settings_tab',
189 $this->lng->txt('lucene_settings_tab'),
190 $this->ctrl->getLinkTarget($this, 'luceneSettings')
191 );
192 }
193
194 if ($this->rbac_system->checkAccess('edit_permission', $this->object->getRefId())) {
195 $this->tabs_gui->addTab(
196 'perm_settings',
197 $this->lng->txt('perm_settings'),
198 $this->ctrl->getLinkTargetByClass(
199 [get_class($this),'ilpermissiongui'],
200 'perm'
201 ),
202 );
203 }
204 }
205
206 protected function advancedLuceneSettingsObject(): void
207 {
208 $this->tabs_gui->setTabActive('lucene_advanced_settings');
209
210 $table = new ilLuceneAdvancedSearchActivationTableGUI($this, 'advancedLuceneSettings');
211 $table->setTitle($this->lng->txt('lucene_advanced_settings_table'));
213
214 $this->tpl->setContent($table->getHTML());
215 }
216
217 protected function saveAdvancedLuceneSettingsObject(): void
218 {
219 if (!$this->access->checkAccess('write', '', $this->object->getRefId())) {
220 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
221 $this->ctrl->redirect($this, 'settings');
222 }
223
224 $enabled_md_ids = new SplFixedArray(0);
225 if ($this->http->wrapper()->post()->has('fid')) {
226 $enabled_md_ids = $this->http->wrapper()->post()->retrieve(
227 'fid',
228 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->string())
229 );
230 }
231
233 foreach (ilLuceneAdvancedSearchFields::getFields() as $field => $translation) {
234 $settings->setActive($field, in_array($field, (array) $enabled_md_ids));
235 }
236 $settings->save();
237 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
238 $this->ctrl->redirect($this, 'advancedLuceneSettings');
239 }
240}
Provides fluid interface to RBAC services.
Definition: UIServices.php:24
Builds data types.
Definition: Factory.php:21
error(string $a_errmsg)
Component logger with individual log levels by component id.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getFields()
Return an array of all meta data fields.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output=true)
getAdminTabs()
administration tabs show only permissions and trash folder
getTabs()
@abstract overwrite in derived GUI class of your object type
User class.
Class ilObjectGUI Basic methods of all Output classes.
ilSetting $settings
prepareOutput(bool $show_sub_objects=true)
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
global $DIC
Definition: feed.php:28
Interface GlobalHttpState.
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc