mirror of
https://github.com/silverstripe/silverstripe-dms
synced 2024-10-22 14:05:56 +02:00
FIX Backlink for upload form redirects to document admin if no page is available
This commit is contained in:
parent
c0dee2f1e5
commit
772198a7fc
@ -187,11 +187,21 @@ class DMSDocumentAddController extends LeftAndMain
|
||||
*/
|
||||
public function Backlink()
|
||||
{
|
||||
if (!$this->getRequest()->getVar('dsid')) {
|
||||
if (!$this->getRequest()->getVar('dsid') || !$this->currentPageID()) {
|
||||
$modelAdmin = new DMSDocumentAdmin;
|
||||
$modelAdmin->init();
|
||||
return $modelAdmin->Link();
|
||||
|
||||
if ($this->getRequest()->getVar('dsid')) {
|
||||
return Controller::join_links(
|
||||
$modelAdmin->Link('DMSDocumentSet'),
|
||||
'EditForm/field/DMSDocumentSet/item',
|
||||
$this->getRequest()->getVar('dsid'),
|
||||
'edit'
|
||||
);
|
||||
}
|
||||
return $modelAdmin->Link('DMSDocumentSet');
|
||||
}
|
||||
|
||||
return Controller::join_links(
|
||||
singleton('CMSPagesController')->Link(),
|
||||
'edit/EditForm/field/Document%20Sets/item',
|
||||
|
@ -64,12 +64,20 @@ class DMSDocumentAddControllerTest extends FunctionalTest
|
||||
*/
|
||||
public function testBacklink()
|
||||
{
|
||||
// No page ID and no document set ID
|
||||
$this->assertContains('admin/documents', $this->controller->Backlink());
|
||||
|
||||
// No page ID, has document set ID
|
||||
$request = new SS_HTTPRequest('GET', '/', array('dsid' => 123));
|
||||
$this->controller->setRequest($request);
|
||||
$this->assertContains('EditForm', $this->controller->Backlink());
|
||||
$this->assertContains('123', $this->controller->Backlink());
|
||||
|
||||
// Has page ID and document set ID
|
||||
$request = new SS_HTTPRequest('GET', '/', array('dsid' => 123, 'ID' => 234));
|
||||
$this->controller->setRequest($request);
|
||||
$this->assertContains('admin/pages', $this->controller->Backlink());
|
||||
$this->assertContains('123', $this->controller->Backlink());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user