mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 06:05:56 +00:00
ENHANCEMENT Removed automatic redirection to admin URLs in ContentController, too counter-intuitive and hard to implement consistently, while still allowing linkage of pages without CMS around them.
This commit is contained in:
parent
e13537e0a7
commit
eecb401952
@ -121,12 +121,6 @@ class ContentController extends Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redirect to admin UI if user is logged in
|
|
||||||
if($this->URLSegment != 'Security' && Permission::check('CMS_ACCESS_CMSMain') && !$this->request->getVar('cms-preview-disabled')) {
|
|
||||||
$cmsController = singleton('CMSPageEditController');
|
|
||||||
return Director::redirect(Controller::join_links($cmsController->Link('show'), $this->dataRecord->ID, '?cms-preview-expanded=1'));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use theme from the site config
|
// Use theme from the site config
|
||||||
if(($config = SiteConfig::current_site_config()) && $config->Theme) {
|
if(($config = SiteConfig::current_site_config()) && $config->Theme) {
|
||||||
SSViewer::set_theme($config->Theme);
|
SSViewer::set_theme($config->Theme);
|
||||||
@ -344,9 +338,7 @@ class ContentController extends Controller {
|
|||||||
if(Director::isDev() || Permission::check('CMS_ACCESS_CMSMain') || Permission::check('VIEW_DRAFT_CONTENT')) {
|
if(Director::isDev() || Permission::check('CMS_ACCESS_CMSMain') || Permission::check('VIEW_DRAFT_CONTENT')) {
|
||||||
if($this->dataRecord) {
|
if($this->dataRecord) {
|
||||||
Requirements::css(CMS_DIR . '/css/SilverStripeNavigator.css');
|
Requirements::css(CMS_DIR . '/css/SilverStripeNavigator.css');
|
||||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/behaviour/behaviour.js');
|
|
||||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery/jquery.js');
|
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery/jquery.js');
|
||||||
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-livequery/jquery.livequery.js');
|
|
||||||
Requirements::javascript(CMS_DIR . '/javascript/SilverStripeNavigator.js');
|
Requirements::javascript(CMS_DIR . '/javascript/SilverStripeNavigator.js');
|
||||||
|
|
||||||
$return = $nav = SilverStripeNavigator::get_for_record($this->dataRecord);
|
$return = $nav = SilverStripeNavigator::get_for_record($this->dataRecord);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* @package cms
|
* @package cms
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
*/
|
*/
|
||||||
class ContentControllerPermissionTest extends FunctionalTest {
|
class ContentControllerPermissionsTest extends FunctionalTest {
|
||||||
|
|
||||||
protected $usesDatabase = true;
|
protected $usesDatabase = true;
|
||||||
|
|
||||||
@ -29,9 +29,7 @@ class ContentControllerPermissionTest extends FunctionalTest {
|
|||||||
$this->logInWithPermission('CMS_ACCESS_CMSMain');
|
$this->logInWithPermission('CMS_ACCESS_CMSMain');
|
||||||
|
|
||||||
$response = $this->get('/testpage/?stage=Stage');
|
$response = $this->get('/testpage/?stage=Stage');
|
||||||
$this->assertEquals($response->getStatusCode(), 302, 'Redirects to page view in CMS when logged in for draft stage');
|
$this->assertEquals($response->getStatusCode(), 200, 'Doesnt redirect to login, but shows page for authenticated user');
|
||||||
$this->assertNotContains('Security/login', $response->getHeader('Location'));
|
|
||||||
$this->assertContains('admin/page/edit/show/' . $page->ID, $response->getHeader('Location'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ class SilverStripeNavigatorTest extends SapphireTest {
|
|||||||
|
|
||||||
$items = $navigator->getItems();
|
$items = $navigator->getItems();
|
||||||
$classes = array_map('get_class', $items->toArray());
|
$classes = array_map('get_class', $items->toArray());
|
||||||
$this->assertContains('SilverStripeNavigatorItem_LiveLink', $classes,
|
$this->assertContains('SilverStripeNavigatorItem_StageLink', $classes,
|
||||||
'Adds default classes'
|
'Adds default classes'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -62,9 +62,7 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
|||||||
$this->assertEquals($response->getStatusCode(), '404');
|
$this->assertEquals($response->getStatusCode(), '404');
|
||||||
|
|
||||||
$response = $this->get($page->URLSegment . '?stage=Stage');
|
$response = $this->get($page->URLSegment . '?stage=Stage');
|
||||||
$this->assertEquals($response->getStatusCode(), '302');
|
$this->assertEquals($response->getStatusCode(), '200');
|
||||||
$this->assertNotContains('Security/login', $response->getHeader('Location'));
|
|
||||||
$this->assertContains('admin/page/edit/show/' . $page->ID, $response->getHeader('Location'));
|
|
||||||
|
|
||||||
$response = $this->get($page->URLSegment . '?stage=');
|
$response = $this->get($page->URLSegment . '?stage=');
|
||||||
$this->assertEquals($response->getStatusCode(), '404');
|
$this->assertEquals($response->getStatusCode(), '404');
|
||||||
@ -333,10 +331,9 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
|||||||
$response = $this->get($childPage->RelativeLink());
|
$response = $this->get($childPage->RelativeLink());
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$response->getStatusCode(),
|
$response->getStatusCode(),
|
||||||
302,
|
200,
|
||||||
'Authenticated members can view a page marked as "Viewable by these groups" if theyre in the listed groups by inherited permission'
|
'Authenticated members can view a page marked as "Viewable by these groups" if theyre in the listed groups by inherited permission'
|
||||||
);
|
);
|
||||||
$this->assertContains('admin/page/edit/show/' . $childPage->ID, $response->getHeader('Location'));
|
|
||||||
$this->session()->inst_set('loggedInAs', null);
|
$this->session()->inst_set('loggedInAs', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user