Commit 92bca2e0 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Merge branch 'B10257_Delete_links_unordered_elvill' into 'master'

Fixes #10257. Delete AS _link only worked with certain parameter order.

See merge request !290
parents 434db4af a2b1addf
Pipeline #4214 failed with stages
in 3 minutes and 32 seconds
......@@ -948,7 +948,7 @@ class Link {
* @param array $vars
* @throws \UserReportException
*/
private function checkParam(array $tokenGiven, array $vars) {
private function checkParam(array $tokenGiven, array &$vars) {
$countLinkAnchor = 0;
$countLinkPicture = 0;
$countSources = 0;
......@@ -988,6 +988,10 @@ class Link {
if (isset($tokenGiven[TOKEN_DOWNLOAD]) && count($vars[NAME_COLLECT_ELEMENTS]) == 0 && $countSources == 0) {
throw new \UserReportException ("Missing element sources for download", ERROR_MISSING_REQUIRED_PARAMETER);
}
if (isset($tokenGiven[TOKEN_ACTION_DELETE])) {
$this->checkDeleteParam($vars);
}
}
/**
......@@ -1840,14 +1844,6 @@ EOF;
*/
private function buildActionDelete($vars, $value) {
// Minimal check for required parameter.
$vars[NAME_URL_PARAM] = $this->checkDeleteParam($vars[NAME_URL_PARAM]);
if ($vars[NAME_URL_PARAM] == '') {
$vars[NAME_RENDER] = RENDER_MODE_5;
return $vars;
}
if ($vars[NAME_URL] == '') {
$vars[NAME_URL] = API_DIR . '/' . API_DELETE_PHP;
}
......@@ -1864,35 +1860,33 @@ EOF;
/**
* Check that at least SIP_RECORD_ID is given and SIP_TABLE or SIP_FORM.
* This check is only processed for COLUMN_PAGED & COLUMN_PPAGED. Not for COLOUMN_LINK, cause it's not known there.
* This check is only processed for COLUMN_PAGED & COLUMN_PAGED. Not for COLUMN_LINK, cause it's not known there.
* In case of missing parameter, throw an exception.
*
* @param $urlParam
* @return string
* @param array $vars
* @throws \UserFormException
* @throws \UserReportException
*/
private function checkDeleteParam($urlParam) {
private function checkDeleteParam(&$vars) {
$urlParam = $vars[NAME_URL_PARAM];
// Fill array 'found' with every given token
$found = KeyValueStringParser::parse($urlParam, '=', '&');
// If there is no 'r' or 'r'=0: no delete button will be rendered
if (!isset($found[SIP_RECORD_ID]) || $found[SIP_RECORD_ID] == '' || $found[SIP_RECORD_ID] == 0) {
return '';
}
$flagRecordId = isset($found[SIP_RECORD_ID]);
$flagRecordId = isset($found[SIP_RECORD_ID]) && $found[SIP_RECORD_ID] != '' && $found[SIP_RECORD_ID] != 0;
$flagTable = isset($found[SIP_TABLE]) && $found[SIP_TABLE] != '';
$flagForm = isset($found[SIP_FORM]) && $found[SIP_FORM] != '';
if ($flagRecordId && ($flagTable || $flagForm)) {
return $urlParam;
if (!$flagRecordId) {
// If there is no 'r' or 'r'=0: no delete button will be rendered
$vars[NAME_RENDER] = RENDER_MODE_5;
} else {
if (!$flagTable && !$flagForm) {
throw new \UserReportException ("Missing some qualifier/value for column " . COLUMN_PAGED . '/' . COLUMN_PPAGED . ": " .
SIP_RECORD_ID . ", " . SIP_FORM . " or " . SIP_TABLE, ERROR_MISSING_REQUIRED_DELETE_QUALIFIER);
}
}
throw new \UserReportException ("Missing some qualifier/value for column " . COLUMN_PAGED . '/' . COLUMN_PPAGED . ": " .
SIP_RECORD_ID . ", " . SIP_FORM . " or " . SIP_TABLE, ERROR_MISSING_REQUIRED_DELETE_QUALIFIER);
}
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment