Skip to content

Commit

Permalink
Fix perma links for data collection
Browse files Browse the repository at this point in the history
  • Loading branch information
iszmais committed Jun 13, 2024
1 parent 99c145f commit 8cf0172
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,15 @@ public function listRecords(bool $use_tableview_filter = false): void
$this->tpl->setOnScreenMessage('info', $message, true);
}

$this->tpl->setPermanentLink("dcl", $this->parent_obj->getRefId(), "_" . $this->tableview_id);
$target = '';
if ($this->http->wrapper()->query()->has('table_id')) {
$target .= $this->http->wrapper()->query()->retrieve('table_id', $this->refinery->to()->string());
}
if ($this->http->wrapper()->query()->has('tableview_id')) {
$target .= '_' . $this->http->wrapper()->query()->retrieve('tableview_id', $this->refinery->to()->string());
}

$this->tpl->setPermanentLink("dcl", $this->parent_obj->getRefId(), $target);

if ($desc = $this->table_obj->getDescription()) {
$ilSetting = new ilSetting('advanced_editing');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*********************************************************************/

declare(strict_types=1);

/**
* @ilCtrl_Calls ilDclDetailedViewGUI: ilDclDetailedViewDefinitionGUI, ilEditClipboardGUI
*/
Expand Down Expand Up @@ -221,7 +222,7 @@ public function renderRecord(bool $editComments = false): void
$tpl->setPermanentLink(
'dcl',
filter_input(INPUT_GET, 'ref_id', FILTER_VALIDATE_INT),
'_' . $this->tableview_id . '_' . $this->record_obj->getId()
$this->table->getId() . '_' . $this->tableview_id . '_' . $this->record_obj->getId()
);

// Buttons for previous/next records
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
class ilObjDataCollectionGUI extends ilObject2GUI
{
public const GET_REF_ID = "ref_id";
public const GET_TABLE_ID = "table_id";
public const GET_VIEW_ID = "tableview_id";
public const GET_RECORD_ID = "record_id";

public const TAB_EDIT_DCL = 'settings';
public const TAB_LIST_TABLES = 'dcl_tables';
Expand Down Expand Up @@ -349,25 +351,28 @@ public static function _goto(string $a_target): void
$access = $DIC->access();
$tpl = $DIC->ui()->mainTemplate();

$target_parts = explode("_", $a_target);
if (count($target_parts) === 1) {
[$ref_id] = $target_parts;
} elseif (count($target_parts) === 2) {
[$ref_id, $viewId] = $target_parts;
} else {
[$ref_id, $viewId, $recordId] = $target_parts;
}
$values = [self::GET_REF_ID, self::GET_TABLE_ID, self::GET_VIEW_ID, self::GET_RECORD_ID];
$values = array_combine($values, array_pad(explode("_", $a_target), count($values), null));

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

//load record list
if ($access->checkAccess('read', "", (int) $ref_id)) {
if ($access->checkAccess('read', "", $ref_id)) {
$ilCtrl->setParameterByClass(ilRepositoryGUI::class, self::GET_REF_ID, $ref_id);
if (isset($viewId)) {
$ilCtrl->setParameterByClass(ilRepositoryGUI::class, self::GET_VIEW_ID, $viewId);
if ($values['table_id'] !== null) {
$ilCtrl->setParameterByClass(ilObjDataCollectionGUI::class, self::GET_TABLE_ID, $values['table_id']);
if ($values['tableview_id'] !== null) {
$ilCtrl->setParameterByClass(ilObjDataCollectionGUI::class, self::GET_VIEW_ID, $values['tableview_id']);
}
if ($values['record_id'] !== null) {
$ilCtrl->setParameterByClass(ilDclDetailedViewGUI::class, self::GET_RECORD_ID, $values['record_id']);
$ilCtrl->redirectByClass([ilRepositoryGUI::class, self::class, ilDclDetailedViewGUI::class], "renderRecord");
}
}
$ilCtrl->redirectByClass(ilRepositoryGUI::class, "listRecords");
$ilCtrl->redirectByClass([ilRepositoryGUI::class, self::class, ilDclRecordListGUI::class], "listRecords");
}
//redirect to info screen
elseif ($access->checkAccess('visbile', "", (int) $ref_id)) {
elseif ($access->checkAccess('visbile', "", $ref_id)) {
ilObjectGUI::_gotoRepositoryNode((int) $a_target, "infoScreen");
}
//redirect if no permission given
Expand Down Expand Up @@ -508,7 +513,6 @@ protected function initEditForm(): ilPropertyFormGUI

final public function listRecords(): void
{
$this->ctrl->setParameterByClass(ilDclRecordListGUI::class, "tableview_id", $this->getTableViewId());
$this->ctrl->redirectByClass(ilDclRecordListGUI::class, "show");
}

Expand Down

0 comments on commit 8cf0172

Please sign in to comment.