Commit 9dda4788 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Merge branch 'B7848pagedBetterHandling' into 'master'

B7848 extraColumName 'paged' - easier handling in case 'r=0' or empty 'U:...' - fixes #7848

See merge request !123
parents e3cce23e 3fe7f1fc
Pipeline #1505 passed with stage
in 1 minute and 55 seconds
...@@ -1601,14 +1601,19 @@ EOF; ...@@ -1601,14 +1601,19 @@ EOF;
private function buildActionDelete($vars, $value) { private function buildActionDelete($vars, $value) {
// Minimal check for required parameter. // Minimal check for required parameter.
$this->checkDeleteParam($vars[NAME_URL_PARAM]); $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] == '') { if ($vars[NAME_URL] == '') {
$vars[NAME_URL] = API_DIR . '/' . API_DELETE_PHP; $vars[NAME_URL] = API_DIR . '/' . API_DELETE_PHP;
} }
if (!isset($vars[NAME_LINK_CLASS])) { if (!isset($vars[NAME_LINK_CLASS])) {
// no_class: By default a button will be rendered. NAME_URL typically implies class external. That does not match. // no_class: By default a button will be rendered.
$vars[NAME_LINK_CLASS_DEFAULT] = NO_CLASS; $vars[NAME_LINK_CLASS_DEFAULT] = NO_CLASS;
} }
...@@ -1623,21 +1628,26 @@ EOF; ...@@ -1623,21 +1628,26 @@ EOF;
* In case of missing parameter, throw an exception. * In case of missing parameter, throw an exception.
* *
* @param $urlParam * @param $urlParam
* * @return string
* @throws UserFormException * @throws UserFormException
* @throws UserReportException in case parameter is missing. * @throws UserReportException
*/ */
private function checkDeleteParam($urlParam) { private function checkDeleteParam($urlParam) {
// Fill array 'found' with every given token // Fill array 'found' with every given token
$found = KeyValueStringParser::parse($urlParam, '=', '&'); $found = KeyValueStringParser::parse($urlParam, '=', '&');
$flagRecordId = isset($found[SIP_RECORD_ID]) && $found[SIP_RECORD_ID] != '' && $found[SIP_RECORD_ID] > 0; // 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]);
$flagTable = isset($found[SIP_TABLE]) && $found[SIP_TABLE] != ''; $flagTable = isset($found[SIP_TABLE]) && $found[SIP_TABLE] != '';
$flagForm = isset($found[SIP_FORM]) && $found[SIP_FORM] != ''; $flagForm = isset($found[SIP_FORM]) && $found[SIP_FORM] != '';
if ($flagRecordId && ($flagTable || $flagForm)) { if ($flagRecordId && ($flagTable || $flagForm)) {
return; return $urlParam;
} }
throw new UserReportException ("Missing some qualifier/value for column " . COLUMN_PAGED . '/' . COLUMN_PPAGED . ": " . throw new UserReportException ("Missing some qualifier/value for column " . COLUMN_PAGED . '/' . COLUMN_PPAGED . ": " .
......
...@@ -1466,12 +1466,12 @@ EOF; ...@@ -1466,12 +1466,12 @@ EOF;
* @throws UserFormException * @throws UserFormException
* @throws UserReportException * @throws UserReportException
*/ */
public function testDeleteException1() { // public function testDeleteException1() {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true); // $link = new Link($this->sip, DB_INDEX_DEFAULT, true);
//
// Missing recordId // // Missing recordId
$link->renderLink('U:form=Person&r=|x'); // $link->renderLink('U:form=Person&r=|x');
} // }
/** /**
......
...@@ -872,46 +872,19 @@ EOF; ...@@ -872,46 +872,19 @@ EOF;
$result = $this->report->process("10.sql = SELECT 'table=Person&r=123|click me||Move to trash?:success:yes:no:10:0' AS _Paged FROM Person ORDER BY id LIMIT 1"); $result = $this->report->process("10.sql = SELECT 'table=Person&r=123|click me||Move to trash?:success:yes:no:10:0' AS _Paged FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="' . API_DIR . '/' . API_DELETE_PHP . '?s=badcaffee1234" class="btn btn-default" title="Delete" ' . $js . ' ><span class="glyphicon glyphicon-trash" ></span> click me</a>', $result); $this->assertEquals('<a href="' . API_DIR . '/' . API_DELETE_PHP . '?s=badcaffee1234" class="btn btn-default" title="Delete" ' . $js . ' ><span class="glyphicon glyphicon-trash" ></span> click me</a>', $result);
}
/** // Empty string is ok
* Missing r, missing form or table $result = $this->report->process("10.sql = SELECT '' AS _Paged FROM Person ORDER BY id LIMIT 1");
* $this->assertEquals('', $result);
* @expectedException \qfq\UserReportException
* // r=0 is ok
* @throws CodeException $result = $this->report->process("10.sql = SELECT 'table=Person&r=0' AS _Paged FROM Person ORDER BY id LIMIT 1");
* @throws DbException $this->assertEquals('', $result);
* @throws DownloadException
* @throws UserFormException
* @throws UserReportException
* @throws \PhpOffice\PhpSpreadsheet\Exception
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/
public function testMissingPagedParameterException1() {
$this->report->process("10.sql = SELECT '' AS _Paged FROM Person ORDER BY id LIMIT 1");
}
/**
* Missing r, given table
*
* @expectedException \qfq\UserReportException
*
* @throws CodeException
* @throws DbException
* @throws DownloadException
* @throws UserFormException
* @throws UserReportException
* @throws \PhpOffice\PhpSpreadsheet\Exception
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/
public function testMissingPagedParameterException2() {
$this->report->process("10.sql = SELECT 'table=Person' AS _Paged FROM Person ORDER BY id LIMIT 1");
} }
/** /**
* Missing r, given form * Missing missing form or table
* *
* @expectedException \qfq\UserReportException * @expectedException \qfq\UserReportException
* *
...@@ -924,10 +897,11 @@ EOF; ...@@ -924,10 +897,11 @@ EOF;
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception * @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/ */
public function testMissingPagedParameterException3() { public function testMissingPagedParameterException1() {
$this->report->process("10.sql = SELECT 'form=Person' AS _Paged FROM Person ORDER BY id LIMIT 1"); $this->report->process("10.sql = SELECT 'something&r=1' AS _Paged FROM Person ORDER BY id LIMIT 1");
} }
/** /**
* missing form, missing table * missing form, missing table
* *
...@@ -946,24 +920,6 @@ EOF; ...@@ -946,24 +920,6 @@ EOF;
$this->report->process("10.sql = SELECT 'r=123' AS _Paged FROM Person ORDER BY id LIMIT 1"); $this->report->process("10.sql = SELECT 'r=123' AS _Paged FROM Person ORDER BY id LIMIT 1");
} }
/**
* missing r, given table
*
* @expectedException \qfq\UserReportException
*
* @throws CodeException
* @throws DbException
* @throws DownloadException
* @throws UserFormException
* @throws UserReportException
* @throws \PhpOffice\PhpSpreadsheet\Exception
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/
public function testMissingPagedParameterException5() {
$this->report->process("10.sql = SELECT 'table=Person&r' AS _Paged FROM Person ORDER BY id LIMIT 1");
}
/** /**
* @expectedException \qfq\UserReportException * @expectedException \qfq\UserReportException
* *
......
Markdown is supported
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