Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function getObjId(): int
*/
public function executeCommand(): void
{
if (!$this->checkAccess()) {
if (!ilObjDataCollectionAccess::hasAccessTo($this->getRefId(), $this->table_id, $this->tableview_id)) {
$this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
return;
}
Expand Down Expand Up @@ -553,19 +553,6 @@ protected function createSwitchers(): void

}

protected function checkAccess(): bool
{
if (null === $this->table_id || null === $this->tableview_id) {
return false;
}

return ilObjDataCollectionAccess::hasAccessTo(
$this->parent_obj->getRefId(),
$this->table_id,
$this->tableview_id
);
}

public function getTableId(): int
{
return $this->table_id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static function _checkGoto(string $target): bool
$ilAccess = $DIC['ilAccess'];

$t_arr = explode("_", $target);
$ref_id = (int) $t_arr[1];
$ref_id = (int) ($t_arr[1] ?? 0);

if ($t_arr[0] != "dcl" || $ref_id <= 0) {
return false;
Expand Down
197 changes: 107 additions & 90 deletions Modules/DataCollection/classes/class.ilObjDataCollectionGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class ilObjDataCollectionGUI extends ilObject2GUI
protected ILIAS\HTTP\Services $http;
protected ilTabsGUI $tabs;
protected int $table_id;
protected int $tableview_id;

public function __construct(int $a_id = 0, int $a_id_type = self::REPOSITORY_NODE_ID, int $a_parent_node_id = 0)
{
Expand All @@ -66,7 +67,7 @@ public function __construct(int $a_id = 0, int $a_id_type = self::REPOSITORY_NOD
$this->lng->loadLanguageModule('obj');
$this->lng->loadLanguageModule('cntr');

$this->setTableId($this->getRefId());
$this->setTableData();

if (!$this->ctrl->isAsynch()) {
$this->addJavaScript();
Expand All @@ -75,18 +76,56 @@ public function __construct(int $a_id = 0, int $a_id_type = self::REPOSITORY_NOD
$this->ctrl->saveParameter($this, 'table_id');
}

private function setTableId(int $objectOrRefId = 0): void
private function setTableData(): void
{
if ($this->http->wrapper()->query()->has('table_id')) {
$this->table_id = $this->http->wrapper()->query()->retrieve('table_id', $this->refinery->kindlyTo()->int());
} elseif ($this->http->wrapper()->query()->has('tableview_id')) {
$this->table_id = ilDclTableView::find(
$this->http->wrapper()->query()->retrieve('tableview_id', $this->refinery->kindlyTo()->int())
)->getTableId();
} elseif ($objectOrRefId > 0) {
$tables = ilObjDataCollectionAccess::hasWriteAccess($this->ref_id) ? $this->object->getTables() : $this->object->getVisibleTables();
if ($tables !== []) {
$this->table_id = array_shift($tables)->getId();
if ($this->ref_id > 0) {
if ($this->http->wrapper()->post()->has('table_id')) {
$this->table_id = $this->http->wrapper()->post()->retrieve(
'table_id',
$this->refinery->kindlyTo()->int()
);
} elseif ($this->http->wrapper()->query()->has('table_id')) {
$this->table_id = $this->http->wrapper()->query()->retrieve(
'table_id',
$this->refinery->kindlyTo()->int()
);
}

if (!isset($this->table_id) || !in_array($this->table_id, array_keys($this->object->getTables()))) {
if (isset($this->table_id)) {
$this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_FAILURE, $this->lng->txt('table_not_found'), true);
unset($this->table_id);
}
$tables = ilObjDataCollectionAccess::hasWriteAccess($this->ref_id) ? $this->object->getTables() : $this->object->getVisibleTables();
if ($tables !== []) {
$this->table_id = array_shift($tables)->getId();
$tableview = (ilDclCache::getTableCache($this->table_id))->getFirstTableViewId();
if ($tableview !== null) {
$this->tableview_id = $tableview;
}
}
} else {
if ($this->http->wrapper()->post()->has('tableview_id')) {
$this->tableview_id = $this->http->wrapper()->post()->retrieve(
'tableview_id',
$this->refinery->kindlyTo()->int()
);
} elseif ($this->http->wrapper()->query()->has('tableview_id')) {
$this->tableview_id = $this->http->wrapper()->query()->retrieve(
'tableview_id',
$this->refinery->kindlyTo()->int()
);
}

if (!isset($this->tableview_id) || !in_array($this->tableview_id, array_keys($this->object->getTableById($this->table_id)->getTableViews()))) {
if (isset($this->tableview_id)) {
$this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_FAILURE, $this->lng->txt('tableview_not_found'), true);
}
$tableview = (ilDclCache::getTableCache($this->table_id))->getFirstTableViewId();
if ($tableview !== null) {
$this->tableview_id = $tableview;
}
}
}
}
}
Expand Down Expand Up @@ -168,18 +207,26 @@ public function executeCommand(): void
$this->addHeaderAction();
$this->prepareOutput();
$this->tabs->activateTab(self::TAB_CONTENT);
try {
$recordlist_gui = new ilDclRecordListGUI($this, $this->table_id, $this->getTableViewId());
$this->ctrl->forwardCommand($recordlist_gui);
} catch (ilDclNoTableviewException $e) {
if (!isset($this->table_id)) {
$this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_INFO, $this->lng->txt('dcl_no_table_found'));
} elseif (!isset($this->tableview_id)) {
$this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_INFO, $this->lng->txt('dcl_no_tableview_found'));
} else {
$recordlist_gui = new ilDclRecordListGUI($this, $this->table_id, $this->tableview_id);
$this->ctrl->forwardCommand($recordlist_gui);
}
break;
case strtolower(ilDclRecordEditGUI::class):
$this->prepareOutput();
$this->tabs->activateTab(self::TAB_CONTENT);
$recordedit_gui = new ilDclRecordEditGUI($this, $this->table_id, $this->getTableViewId());
$this->ctrl->forwardCommand($recordedit_gui);
if (!isset($this->table_id)) {
$this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_INFO, $this->lng->txt('dcl_no_table_found'));
} elseif (!isset($this->tableview_id)) {
$this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_INFO, $this->lng->txt('dcl_no_tableview_found'));
} else {
$recordedit_gui = new ilDclRecordEditGUI($this, $this->table_id, $this->tableview_id);
$this->ctrl->forwardCommand($recordedit_gui);
}
break;
case strtolower(ilObjFileGUI::class):
$this->prepareOutput();
Expand Down Expand Up @@ -215,32 +262,46 @@ public function executeCommand(): void
break;
case strtolower(ilDclDetailedViewGUI::class):
$this->prepareOutput();
$recordview_gui = new ilDclDetailedViewGUI($this, $this->getTableViewId());
$this->ctrl->forwardCommand($recordview_gui);
$this->tabs->setBackTarget(
$this->lng->txt('back'),
$this->ctrl->getLinkTargetByClass(
ilDclRecordListGUI::class,
ilDclRecordListGUI::CMD_LIST_RECORDS
)
);
if (!isset($this->tableview_id)) {
$this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_INFO, $this->lng->txt('dcl_no_tableview_found'));
} else {
$recordview_gui = new ilDclDetailedViewGUI($this, $this->tableview_id);
$this->ctrl->forwardCommand($recordview_gui);
$this->tabs->setBackTarget(
$this->lng->txt('back'),
$this->ctrl->getLinkTargetByClass(
ilDclRecordListGUI::class,
ilDclRecordListGUI::CMD_LIST_RECORDS
)
);
}
break;
case strtolower(ilNoteGUI::class):
$this->prepareOutput();
$recordviewGui = new ilDclDetailedViewGUI($this, $this->getTableViewId());
$this->ctrl->forwardCommand($recordviewGui);
$this->tabs->clearTargets();
$this->tabs->setBackTarget($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, ''));
if (!isset($this->tableview_id)) {
$this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_INFO, $this->lng->txt('dcl_no_tableview_found'));
} else {
$recordviewGui = new ilDclDetailedViewGUI($this, $this->tableview_id);
$this->ctrl->forwardCommand($recordviewGui);
$this->tabs->clearTargets();
$this->tabs->setBackTarget($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, ''));
}
break;
case strtolower(ilDclExportGUI::class):
$this->handleExport();
break;
case strtolower(ilDclPropertyFormGUI::class):
$recordedit_gui = new ilDclRecordEditGUI($this, $this->table_id, $this->getTableViewId());
$recordedit_gui->getRecord();
$recordedit_gui->initForm();
$form = $recordedit_gui->getForm();
$this->ctrl->forwardCommand($form);
if (!isset($this->table_id)) {
$this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_INFO, $this->lng->txt('dcl_no_table_found'));
} elseif (!isset($this->tableview_id)) {
$this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_INFO, $this->lng->txt('dcl_no_tableview_found'));
} else {
$recordedit_gui = new ilDclRecordEditGUI($this, $this->table_id, $this->tableview_id);
$recordedit_gui->getRecord();
$recordedit_gui->initForm();
$form = $recordedit_gui->getForm();
$this->ctrl->forwardCommand($form);
}
break;
default:
switch ($cmd) {
Expand Down Expand Up @@ -272,31 +333,6 @@ protected function handleExport(bool $do_default = false): void
}
}

protected function getTableViewId(): int
{
$tableview_id = null;
if ($this->http->wrapper()->query()->has('tableview_id')) {
$tableview_id = $this->http->wrapper()->query()->retrieve(
'tableview_id',
$this->refinery->kindlyTo()->int()
);
}
if ($this->http->wrapper()->post()->has('tableview_id')) {
$tableview_id = $this->http->wrapper()->post()->retrieve(
'tableview_id',
$this->refinery->kindlyTo()->int()
);
}
if (!$tableview_id) {
$table_obj = ilDclCache::getTableCache($this->table_id);
$tableview_id = $table_obj->getFirstTableViewId();
}
if ($tableview_id === null) {
throw new ilDclNoTableviewException('No visible tableview configured!');
}
return $tableview_id;
}

public function infoScreen(): void
{
$this->ctrl->setCmd("showSummary");
Expand Down Expand Up @@ -341,11 +377,6 @@ protected function addLocatorItems(): void
public static function _goto(string $a_target): void
{
global $DIC;
$lng = $DIC->language();

$ctrl = $DIC->ctrl();
$access = $DIC->access();
$tpl = $DIC->ui()->mainTemplate();

$params = explode('_', $a_target);
//41821: Handles old permanent links. This is deprecated and removed for ILIAS 10
Expand All @@ -362,37 +393,23 @@ public static function _goto(string $a_target): void
$values = array_combine($values, array_pad($params, count($values), 0));

$ref_id = (int) $values[self::GET_REF_ID];

if ($access->checkAccess('read', '', $ref_id)) {
$ctrl->setParameterByClass(ilRepositoryGUI::class, self::GET_REF_ID, $ref_id);
$object = new ilObjDataCollection($ref_id);
if ($ref_id !== 0) {
$DIC->ctrl()->setParameterByClass(ilRepositoryGUI::class, self::GET_REF_ID, $ref_id);
$table_id = (int) $values[self::GET_TABLE_ID];
if ($table_id !== 0 && isset($object->getVisibleTables()[$table_id])) {
$ctrl->setParameterByClass(ilObjDataCollectionGUI::class, self::GET_TABLE_ID, $table_id);
$table = $object->getVisibleTables()[$table_id];
if ($table_id !== 0) {
$DIC->ctrl()->setParameterByClass(ilObjDataCollectionGUI::class, self::GET_TABLE_ID, $table_id);
$view_id = (int) $values[self::GET_VIEW_ID];
if ($view_id !== 0 && isset($table->getTableViews()[$view_id])) {
$ctrl->setParameterByClass(ilObjDataCollectionGUI::class, self::GET_VIEW_ID, $view_id);
if ($view_id !== 0) {
$DIC->ctrl()->setParameterByClass(ilObjDataCollectionGUI::class, self::GET_VIEW_ID, $view_id);
}

$record_id = (int) $values[self::GET_RECORD_ID];
if ($record_id !== 0 && isset($table->getRecords()[$record_id])) {
$ctrl->setParameterByClass(ilDclDetailedViewGUI::class, self::GET_RECORD_ID, $record_id);
$ctrl->redirectByClass([ilRepositoryGUI::class, self::class, ilDclDetailedViewGUI::class], 'renderRecord');
if ($record_id !== 0) {
$DIC->ctrl()->setParameterByClass(ilDclDetailedViewGUI::class, self::GET_RECORD_ID, $record_id);
$DIC->ctrl()->redirectByClass([ilRepositoryGUI::class, self::class, ilDclDetailedViewGUI::class], 'renderRecord');
}
}
$ctrl->redirectByClass([ilRepositoryGUI::class, self::class, ilDclRecordListGUI::class], 'listRecords');
} elseif ($access->checkAccess('visbile', '', $ref_id)) {
ilObjectGUI::_gotoRepositoryNode((int) $a_target, 'infoScreen');
} else {
$message = sprintf(
$lng->txt('msg_no_perm_read_item'),
ilObject::_lookupTitle(ilObject::_lookupObjId((int) $a_target))
);
$tpl->setOnScreenMessage('failure', $message, true);

ilObjectGUI::_gotoRepositoryRoot();
}
$DIC->ctrl()->redirectByClass([ilRepositoryGUI::class, self::class, ilDclRecordListGUI::class], 'listRecords');
}

protected function afterSave(ilObject $new_object): void
Expand Down
23 changes: 0 additions & 23 deletions Modules/DataCollection/exceptions/ilDclNoTableviewException.php

This file was deleted.

3 changes: 3 additions & 0 deletions lang/ilias_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -8693,6 +8693,7 @@ dcl#:#dcl_no_fields_yet#:#Es wurden noch keine Felder für diese Tabelle erstell
dcl#:#dcl_no_read_access_on_any_standard_view#:#Sie haben auf keine Standard-Tabellenansicht Lesezugriff.
dcl#:#dcl_no_search_results_found_for#:#Es wurden keine Module gefunden mit:
dcl#:#dcl_no_such_reference#:#Der folgende Wert ist in der Referenztabelle nicht vorhanden:
dcl#:#dcl_no_table_found#:#Keine sichbare Tabelle verfügbar!
dcl#:#dcl_no_tableview_found#:#Keine sichbare Tabellenansicht verfügbar!
dcl#:#dcl_not_checked#:#Nicht ausgewählt
dcl#:#dcl_not_supported_in_import#:#Dieser Feldtyp wird beim Import nicht unterstützt.
Expand Down Expand Up @@ -8821,6 +8822,8 @@ dcl#:#dcl_wrong_regex#:#Der eingegebene Text passt nicht zur Spezifikation diese
dcl#:#dcl_xls_async_export#:#als XLSX (asynchron)
dcl#:#fieldtitle_allow_chars#:#Nicht Erlaubte Zeichen: %s
dcl#:#fileupload_not_migrated#:#Die Datei wurde noch nicht migriert und kann deshalb nicht angezeigt werden. Bitte wenden Sie sich an Ihre Systemadministration.
dcl#:#table_not_found#:#Tabelle nicht gefunden!
dcl#:#tableview_not_found#:#Tabellenansicht nicht gefunden!
didactic#:#activate_exclusive_template#:#Standard ausgrauen
didactic#:#activate_exclusive_template_info#:#Die Standard-Vorlage wird überall dort ausgegraut, wo diese didaktische Vorlage aktiv ist.
didactic#:#activate_local_didactic_template#:#Gültigkeitsbereich
Expand Down
3 changes: 3 additions & 0 deletions lang/ilias_en.lang
Original file line number Diff line number Diff line change
Expand Up @@ -8693,6 +8693,7 @@ dcl#:#dcl_no_fields_yet#:#There are no fields defined for this table thus you ca
dcl#:#dcl_no_read_access_on_any_standard_view#:#You don't have read access on any standard view of a table.
dcl#:#dcl_no_search_results_found_for#:#No modules have been found for
dcl#:#dcl_no_such_reference#:#The following value is not available in the reference table:
dcl#:#dcl_no_table_found#:#No visible table found!
dcl#:#dcl_no_tableview_found#:#No visible tableview found!
dcl#:#dcl_not_checked#:#Not checked.
dcl#:#dcl_not_supported_in_import#:#This type of field is not supported in the import
Expand Down Expand Up @@ -8821,6 +8822,8 @@ dcl#:#dcl_wrong_regex#:#The text you entered does not match the specification fo
dcl#:#dcl_xls_async_export#:#as XLSX (asynchronous)
dcl#:#fieldtitle_allow_chars#:#Not allowed chars: %s
dcl#:#fileupload_not_migrated#:#File has not yet been migration and cannot be displayed. Please contact your System-Administrator.
dcl#:#table_not_found#:#Table not found!
dcl#:#tableview_not_found#:#Tableview not found!
didactic#:#activate_exclusive_template#:#Grey Out Default
didactic#:#activate_exclusive_template_info#:#The standard template won't be available wherever this template is active.
didactic#:#activate_local_didactic_template#:#Scope of Application
Expand Down