Skip to content

Commit

Permalink
0032955: Pre8: Creation of weblink fails "Argument #1 ($a_value) must…
Browse files Browse the repository at this point in the history
… be of type int, string given"
  • Loading branch information
smeyer-ilias committed Jun 23, 2022
1 parent 06eaf53 commit 78fca55
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 38 deletions.
16 changes: 5 additions & 11 deletions Modules/WebResource/classes/class.ilObjLinkResourceAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,20 @@ public static function _getCommands() : array
);
}

/**
* @inheritDoc
*/
public static function _checkGoto(string $target) : bool
{
global $DIC;

$ilAccess = $DIC['ilAccess'];
$ilAccess = $DIC->access();

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

if ($t_arr[0] != "webr" || ((int) $t_arr[1]) <= 0) {
if ($type !== 'webr' || $ref_id <= 0) {
return false;
}

if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
$ilAccess->checkAccess("visible", "", $t_arr[1])) {
return true;
}
return false;
return $ilAccess->checkAccess('read', '', $ref_id) || $ilAccess->checkAccess('visible', '', $ref_id);
}

/**
Expand Down
24 changes: 12 additions & 12 deletions Modules/WebResource/classes/class.ilObjLinkResourceGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -745,28 +745,28 @@ protected function updateLinks() : void
$link_id
);
$links->setLinkId($link_id);
$links->setTitle(ilUtil::stripSlashes($data['title']));
$links->setDescription(ilUtil::stripSlashes($data['desc']));
$links->setTitle(ilUtil::stripSlashes($data['title'] ?? ''));
$links->setDescription(ilUtil::stripSlashes($data['desc'] ?? ''));
$links->setTarget(
str_replace('"', '', ilUtil::stripSlashes($data['tar']))
str_replace('"', '', ilUtil::stripSlashes($data['tar'] ?? ''))
);
$links->setActiveStatus((bool) $data['act']);
$links->setDisableCheckStatus((bool) $data['che']);
$links->setActiveStatus((bool) ($data['act'] ?? false));
$links->setDisableCheckStatus((bool) ($data['che'] ?? false));
$links->setLastCheckDate($orig['last_check']);
$links->setValidStatus((bool) $data['vali']);
$links->setInternal(ilLinkInputGUI::isInternalLink($data['tar']));
$links->setValidStatus((bool) ($data['vali'] ?? false));
$links->setInternal(ilLinkInputGUI::isInternalLink($data['tar'] ?? ''));
$links->update();

if (strlen($data['nam'] ?? '') && $data['val'] ?? '') {
$param = new ilParameterAppender($this->object->getId());
$param->setName(ilUtil::stripSlashes($data['nam']));
$param->setValue((int) $data['val']);
$param->setName(ilUtil::stripSlashes($data['nam'] ?? ''));
$param->setValue((int) ($data['val'] ?? 0));
$param->add($link_id);
}
if (!ilLinkResourceList::checkListStatus($this->object->getId())) {
$this->object->setTitle(ilUtil::stripSlashes($data['title']));
$this->object->setTitle(ilUtil::stripSlashes($data['title'] ?? ''));
$this->object->setDescription(
ilUtil::stripSlashes($data['desc'])
ilUtil::stripSlashes($data['desc'] ?? '')
);
$this->object->update();
}
Expand Down Expand Up @@ -843,7 +843,7 @@ protected function checkLinkInput(

$this->dynamic = new ilParameterAppender($a_webr_id);
$this->dynamic->setName($this->form->getInput('nam'));
$this->dynamic->setValue($this->form->getInput('val'));
$this->dynamic->setValue((int) $this->form->getInput('val'));
if (!$this->dynamic->validate()) {
switch ($this->dynamic->getErrorCode()) {
case ilParameterAppender::LINKS_ERR_NO_NAME:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,12 @@ protected function fillRow(array $a_set) : void
$this->tpl->setVariable('VAL_INTERNAL_ID', $parts[1]);

$parts = ilLinkInputGUI::getTranslatedValue($a_set['target']);

$this->tpl->setVariable(
'TXT_TRIGGER_INFO',
$parts['type'] . ' "' .
$parts['name'] . '"'
);
if ($parts !== []) {
$this->tpl->setVariable(
'TXT_TRIGGER_INFO',
$parts['type'] . ' "' . $parts['name'] . '"'
);
}
}

$this->tpl->parseCurrentBlock();
Expand Down Expand Up @@ -309,12 +309,12 @@ protected function fillRow(array $a_set) : void
'TXT_DYN_VALUE',
$this->lng->txt('links_value')
);
$this->tpl->setVariable('VAL_DYN_NAME', $a_set['name']);
$this->tpl->setVariable('VAL_DYN_NAME', $a_set['name'] ?? '');
$this->tpl->setVariable('DYN_ID', $a_set['id']);
$this->tpl->setVariable(
'SEL_DYN_VAL',
ilLegacyFormElementsUtil::formSelect(
$a_set['value'] ?: 0,
$a_set['value'] ?? 0,
'links[' . $a_set['id'] . '][val]',
ilParameterAppender::_getOptionSelect(),
false,
Expand Down
15 changes: 8 additions & 7 deletions Services/Form/classes/class.ilLinkInputGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -516,34 +516,35 @@ public static function getTranslatedValue(string $a_value) : array
$lng = $DIC->language();

$value = explode("|", $a_value);

if ($value === false || $value === []) {
return [];
}
switch ($value[0]) {
case "media":
$type = $lng->txt("obj_mob");
$name = ilObject::_lookupTitle($value[1]);
$name = ilObject::_lookupTitle((int) $value[1]);
break;

case "page":
$type = $lng->txt("obj_pg");
$name = ilLMPageObject::_lookupTitle($value[1]);
$name = ilLMPageObject::_lookupTitle((int) $value[1]);
break;

case "chap":
$type = $lng->txt("obj_st");
$name = ilStructureObject::_lookupTitle($value[1]);
$name = ilStructureObject::_lookupTitle((int) $value[1]);
break;

case "term":
$type = $lng->txt("term");
$name = ilGlossaryTerm::_lookGlossaryTerm($value[1]);
$name = ilGlossaryTerm::_lookGlossaryTerm((int) $value[1]);
break;

default:
$type = $lng->txt("obj_" . $value[0]);
$name = ilObject::_lookupTitle(ilObject::_lookupObjId($value[1]));
$name = ilObject::_lookupTitle(ilObject::_lookupObjId((int) $value[1]));
break;
}

return array("type" => $type, "name" => $name);
}

Expand Down

0 comments on commit 78fca55

Please sign in to comment.