Basket: allow to download for non-primary Instance
This commit is contained in:
parent
bb0422c327
commit
ec11dea8a9
|
@ -171,7 +171,11 @@ class BasketController extends ActionController
|
|||
),
|
||||
Link::create(
|
||||
$this->translate('Download'),
|
||||
$this->url()->with('action', 'download'),
|
||||
$this->url()
|
||||
->with([
|
||||
'action' => 'download',
|
||||
'dbResourceName' => $this->getDbResourceName()
|
||||
]),
|
||||
null,
|
||||
[
|
||||
'class' => 'icon-download',
|
||||
|
|
|
@ -13,13 +13,36 @@ trait DirectorDb
|
|||
|
||||
protected function getDbResourceName()
|
||||
{
|
||||
if ($name = $this->getPreferredDbResourceName()) {
|
||||
if ($name = $this->getDbResourceNameFromRequest()) {
|
||||
return $name;
|
||||
} elseif ($name = $this->getPreferredDbResourceName()) {
|
||||
return $name;
|
||||
} else {
|
||||
return $this->getFirstDbResourceName();
|
||||
}
|
||||
}
|
||||
|
||||
protected function getDbResourceNameFromRequest()
|
||||
{
|
||||
$param = 'dbResourceName';
|
||||
// We shouldn't access _POST and _GET. However, this trait is used
|
||||
// in various places - and our Request is going to be replaced anyways.
|
||||
// So, let's not over-engineer things, this is quick & dirty:
|
||||
if (isset($_POST[$param])) {
|
||||
$name = $_POST[$param];
|
||||
} elseif (isset($_GET[$param])) {
|
||||
$name = $_GET[$param];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (in_array($name, $this->listAllowedDbResourceNames())) {
|
||||
return $name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected function getPreferredDbResourceName()
|
||||
{
|
||||
return $this->getWindowSessionValue('db_resource');
|
||||
|
|
Loading…
Reference in New Issue