19 declare(strict_types=1);
55 $ilCtrl = $DIC[
'ilCtrl'];
57 $ilTabs = $DIC[
'ilTabs'];
58 $locator = $DIC[
'ilLocator'];
62 $this->
ctrl = $ilCtrl;
65 $this->tabs_gui = $ilTabs;
66 $this->
help = $DIC->help();
67 $this->
http = $DIC->http();
69 $this->ui_factory = $DIC->ui()->factory();
70 $this->ui_renderer = $DIC->ui()->renderer();
71 $ref_id = $this->table->getCollectionObject()->getRefId();
72 foreach ($DIC->rbac()->review()->getParentRoleIds(
$ref_id) as $role) {
75 $DIC->rbac()->system()->checkPermission(
$ref_id, $role[
'obj_id'],
'visible')
81 $this->
ctrl->saveParameterByClass(
'ilDclTableEditGUI',
'table_id');
82 $this->
ctrl->saveParameter($this,
'tableview_id');
83 if ($this->tableview->getTitle()) {
84 $locator->addItem($this->tableview->getTitle(), $this->
ctrl->getLinkTarget($this,
'show'));
86 $this->tpl->setLocator();
91 $cmd = $this->
ctrl->getCmd(
'show');
92 $next_class = $this->
ctrl->getNextClass($this);
98 $this->tabs_gui->clearTargets();
99 $this->tabs_gui->clearSubTabs();
100 $this->tabs_gui->setBackTarget(
101 $this->
lng->txt(
'dcl_tableviews'),
102 $this->
ctrl->getLinkTarget($this->parent_obj)
104 $this->tabs_gui->setBack2Target(
105 $this->
lng->txt(
'dcl_tables'),
106 $this->
ctrl->getLinkTarget($this->parent_obj->getParentObj())
109 switch ($next_class) {
110 case 'ildcldetailedviewdefinitiongui':
111 $this->
help->setSubScreenId(
'detailed_view');
112 $this->
setTabs(
'detailed_view');
114 $ret = $this->
ctrl->forwardCommand($recordedit_gui);
116 $this->tpl->setContent($ret);
119 case 'ildclcreateviewdefinitiongui':
120 $this->
help->setSubScreenId(
'record_create');
123 $this->
ctrl->forwardCommand($creation_gui);
125 case 'ildcleditviewdefinitiongui':
126 $this->
help->setSubScreenId(
'record_edit');
129 $this->
ctrl->forwardCommand($edit_gui);
134 if ($this->tableview->getId()) {
135 $this->
ctrl->redirect($this,
'editGeneralSettings');
137 $this->
ctrl->redirect($this,
'add');
141 $this->
help->setSubScreenId(
'create');
142 $this->tpl->setContent(
143 $this->
lng->txt(
'dcl_new_view') . $this->ui_renderer->render($this->
initForm(
true))
146 case 'editGeneralSettings':
147 $this->
help->setSubScreenId(
'edit');
148 $this->
setTabs(
'general_settings');
149 $this->tpl->setContent(
150 sprintf($this->
lng->txt(
'dcl_edit_view'), $this->tableview->getTitle()) .
151 $this->ui_renderer->render($this->initForm())
154 case 'editFieldSettings':
155 $this->
help->setSubScreenId(
'overview');
156 $this->
setTabs(
'field_settings');
158 $this->tpl->setContent($this->table_gui->getHTML());
161 if ($cmd ===
'create' || $cmd ===
'update') {
162 $this->
save($cmd ===
'create');
173 $settings[
'title'] = $this->ui_factory->input()->field()->text($this->
lng->txt(
'title'))->withRequired(
true);
174 $settings[
'description'] = $this->ui_factory->input()->field()->textarea($this->
lng->txt(
'description'));
176 $settings[
'role_limitation'] = $this->ui_factory->input()->field()->optionalGroup(
178 'roles' => $this->ui_factory->input()->field()->multiSelect(
179 $this->
lng->txt(
'roles'),
181 $this->
lng->txt(
'roles_desc')
184 $this->
lng->txt(
'role_limitation')
187 $inputs[
'settings'] = $this->ui_factory->input()->field()->section($settings, $this->
lng->txt(
'general_settings'));
193 return $this->ui_factory->input()->container()->form()->standard(
194 $this->
ctrl->getFormAction($this, $create ?
'create' :
'update'),
202 foreach ($this->tableview->getRoles() as $role) {
204 if (in_array($role, array_keys($this->available_roles),
true)) {
208 $inputs[
'settings'] = $inputs[
'settings']->withValue([
209 'title' => $this->tableview->getTitle(),
210 'description' => $this->tableview->getDescription(),
211 'role_limitation' => $this->tableview->getRoleLimitation() ? [
'roles' => $roles] :
null 217 protected function setTabs(
string $active): void
219 $this->tabs_gui->addTab(
221 $this->
lng->txt(
'settings'),
222 $this->
ctrl->getLinkTarget($this,
'editGeneralSettings')
224 $this->tabs_gui->addTab(
226 $this->
lng->txt(
'dcl_create_entry_rules'),
227 $this->
ctrl->getLinkTargetByClass(
'ilDclCreateViewDefinitionGUI',
'presentation')
229 $this->tabs_gui->addTab(
231 $this->
lng->txt(
'dcl_edit_entry_rules'),
232 $this->
ctrl->getLinkTargetByClass(
'ilDclEditViewDefinitionGUI',
'presentation')
234 $this->tabs_gui->addTab(
236 $this->
lng->txt(
'dcl_list_visibility_and_filter'),
237 $this->
ctrl->getLinkTarget($this,
'editFieldSettings')
239 $this->tabs_gui->addTab(
241 $this->
lng->txt(
'dcl_detailed_view'),
242 $this->
ctrl->getLinkTargetByClass(
'ilDclDetailedViewDefinitionGUI',
'edit')
244 $this->tabs_gui->setTabActive($active);
247 public function save(
bool $create =
false): void
251 $this->tableview->setTitle(
$data[
'settings'][
'title']);
252 $this->tableview->setDescription(
$data[
'settings'][
'description']);
253 $this->tableview->setRoleLimitation(
$data[
'settings'][
'role_limitation'] !==
null);
254 $this->tableview->setRoles(
$data[
'settings'][
'role_limitation'][
'roles'] ?? []);
256 $this->tableview->setTableId($this->table->getId());
257 $this->tableview->setOrder($this->table->getNewTableviewOrder());
258 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->
lng->txt(
'dcl_msg_tableview_created'),
true);
259 $this->tableview->create();
261 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->
lng->txt(
'dcl_msg_tableview_updated'),
true);
262 $this->tableview->update();
265 $this->
ctrl->redirect($this,
'editGeneralSettings');
268 public function saveOverviewSettings():
void 273 foreach ($this->tableview->getFieldSettings() as $setting) {
275 foreach ([
"Visible",
"InFilter",
"FilterChangeable"] as $attribute) {
276 $key = $attribute .
'_' . $setting->getField();
277 if ($this->
http->wrapper()->post()->has($key)) {
278 $checkbox_value = $this->
http->wrapper()->post()->retrieve(
280 $this->
refinery->kindlyTo()->string()
282 $setting->{
'set' . $attribute}($checkbox_value ===
'on');
284 $setting->{
'set' . $attribute}(
false);
289 $key =
'filter_' . $setting->getField();
290 if ($this->
http->wrapper()->post()->has($key)) {
291 $setting->setFilterValue($this->
http->wrapper()->post()->retrieve(
293 $this->
refinery->kindlyTo()->string()
295 } elseif ($this->
http->wrapper()->post()->has($key .
'_from') && $this->
http->wrapper()->post()->has($key .
'_to')) {
296 $setting->setFilterValue([
"from" => $this->
http->wrapper()->post()->retrieve(
298 $this->
refinery->kindlyTo()->string()
300 "to" => $this->
http->wrapper()->post()->retrieve(
302 $this->
refinery->kindlyTo()->string()
306 $setting->setFilterValue(
null);
312 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'dcl_msg_tableview_updated'),
true);
313 $this->
ctrl->saveParameter($this->parent_obj,
'tableview_id');
314 $this->
ctrl->redirect($this,
'editFieldSettings');
320 $this->table_gui =
$table;
325 $this->
ctrl->setParameter($this->parent_obj,
'table_id', $this->table->getId());
326 $this->
ctrl->redirect($this->parent_obj);
332 $this->parent_obj->checkViewsLeft(1);
335 $conf->setFormAction($this->
ctrl->getFormAction($this));
336 $conf->setHeaderText($this->
lng->txt(
'dcl_tableview_confirm_delete'));
338 $conf->addItem(
'tableview_id', (
string) $this->tableview->getId(), $this->tableview->getTitle());
340 $conf->setConfirm($this->
lng->txt(
'delete'),
'delete');
341 $conf->setCancel($this->
lng->txt(
'cancel'),
'cancel');
343 $this->tpl->setContent($conf->getHTML());
346 protected function delete():
void 348 $this->tableview->delete();
349 $this->table->sortTableViews();
350 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'dcl_msg_tableview_deleted'),
true);
356 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'permission_denied'),
true);
357 $this->
ctrl->redirectByClass(
358 [ilObjDataCollectionGUI::class, ilDclRecordListGUI::class],
365 if (in_array($cmd, [
'add',
'create',
'cancel'])) {
367 $this->parent_obj->getParentObj()->getDataCollectionObject()->getRefId(),
368 $this->table->getId()
371 return ilObjDataCollectionAccess::hasAccessTo(
372 $this->parent_obj->getParentObj()->getDataCollectionObject()->getRefId(),
373 $this->table->getId(),
374 $this->tableview->getId()
382 $new_tableview->setTableId($this->table->getId());
383 $new_tableview->cloneStructure($this->tableview, []);
384 $this->table->sortTableViews();
385 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"dcl_tableview_copy"),
true);
ilDclTableViewEditGUI: ilDclDetailedViewDefinitionGUI ilDclTableViewEditGUI: ilDclCreateViewDefiniti...
ILIAS HTTP Services $http
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(ilDclTableViewGUI $parent_obj, ilDclTable $table, ilDclTableView $tableview)
ilDclTableViewGUI: ilDclTableViewEditGUI
ilDclCreateViewDefinitionGUI: ilDclTableViewEditGUI
ilDclTableViewGUI $parent_obj
ilDclEditViewDefinitionGUI: ilDclTableViewEditGUI
ilDclDetailedViewDefinitionGUI: ilPageEditorGUI, ilEditClipboardGUI, ilMediaPoolTargetSelector ilDcl...
ilDclTableViewEditFieldsTableGUI $table_gui
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static http()
Fetches the global http state from ILIAS.
ILIAS Refinery Factory $refinery
This is how the factory for UI elements looks.
initForm(bool $create=false)
static _getTranslation(string $a_role_title)
ilGlobalPageTemplate $tpl
static hasAccessToEditTable(int $ref_id, int $table_id)
ilDclTableView $tableview