mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
Merge branch 'cms-preview-history'
This commit is contained in:
commit
c6a75449a4
@ -358,7 +358,7 @@ JS
|
|||||||
return $record->ID;
|
return $record->ID;
|
||||||
} else if($this->isAjax()) {
|
} else if($this->isAjax()) {
|
||||||
$form = $this->getEditForm($record->ID);
|
$form = $this->getEditForm($record->ID);
|
||||||
return $form->formHtmlContent();
|
return $form->forTemplate();
|
||||||
} else {
|
} else {
|
||||||
return $this->redirect(Controller::join_links($this->Link('show'), $record->ID));
|
return $this->redirect(Controller::join_links($this->Link('show'), $record->ID));
|
||||||
}
|
}
|
||||||
|
@ -345,7 +345,7 @@ JS;
|
|||||||
|
|
||||||
$this->response->addHeader('X-Status', _t('LeftAndMain.SAVEDUP'));
|
$this->response->addHeader('X-Status', _t('LeftAndMain.SAVEDUP'));
|
||||||
|
|
||||||
return $form->formHtmlContent();
|
return $form->forTemplate();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get a database record to be managed by the CMS
|
* Get a database record to be managed by the CMS
|
||||||
@ -438,14 +438,6 @@ JS;
|
|||||||
$actions = $record->getCMSActions();
|
$actions = $record->getCMSActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a default or custom validator.
|
|
||||||
// @todo Currently the default Validator.js implementation
|
|
||||||
// adds javascript to the document body, meaning it won't
|
|
||||||
// be included properly if the associated fields are loaded
|
|
||||||
// through ajax. This means only serverside validation
|
|
||||||
// will kick in for pages+validation loaded through ajax.
|
|
||||||
// This will be solved by using less obtrusive javascript validation
|
|
||||||
// in the future, see http://open.silverstripe.com/ticket/2915 and http://open.silverstripe.com/ticket/3386
|
|
||||||
if($record->hasMethod('getCMSValidator')) {
|
if($record->hasMethod('getCMSValidator')) {
|
||||||
$validator = $record->getCMSValidator();
|
$validator = $record->getCMSValidator();
|
||||||
} else {
|
} else {
|
||||||
@ -464,7 +456,7 @@ JS;
|
|||||||
$form->addExtraClass('cms-edit-form');
|
$form->addExtraClass('cms-edit-form');
|
||||||
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
|
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
|
||||||
// TODO Can't merge $FormAttributes in template at the moment
|
// TODO Can't merge $FormAttributes in template at the moment
|
||||||
$form->addExtraClass('cms-content center ss-tabset');
|
$form->addExtraClass('cms-content center ss-tabset ' . $this->BaseCSSClasses());
|
||||||
if($form->Fields()->hasTabset()) $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
|
if($form->Fields()->hasTabset()) $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
|
||||||
|
|
||||||
if(!$record->canEdit() || $record->IsDeletedFromStage) {
|
if(!$record->canEdit() || $record->IsDeletedFromStage) {
|
||||||
@ -505,6 +497,19 @@ JS;
|
|||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function currentPageID() {
|
||||||
|
$id = parent::currentPageID();
|
||||||
|
|
||||||
|
// Fall back to homepage record
|
||||||
|
if(!$id) {
|
||||||
|
$homepageSegment = RootURLController::get_homepage_link();
|
||||||
|
$homepageRecord = DataObject::get_one('SiteTree', sprintf('"URLSegment" = \'%s\'', $homepageSegment));
|
||||||
|
if($homepageRecord) $id = $homepageRecord->ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $id;
|
||||||
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------//
|
//------------------------------------------------------------------------------------------//
|
||||||
// Data saving handlers
|
// Data saving handlers
|
||||||
@ -578,7 +583,7 @@ JS;
|
|||||||
$form = $this->getEditForm($record->ID);
|
$form = $this->getEditForm($record->ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $form->formHtmlContent();
|
return $form->forTemplate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -615,7 +620,7 @@ JS;
|
|||||||
return $record->ID;
|
return $record->ID;
|
||||||
} else if(Director::is_ajax()) {
|
} else if(Director::is_ajax()) {
|
||||||
$form = $this->getEditForm($record->ID);
|
$form = $this->getEditForm($record->ID);
|
||||||
return $form->formHtmlContent();
|
return $form->forTemplate();
|
||||||
} else {
|
} else {
|
||||||
return $this->redirect(Controller::join_links($this->Link('show'), $record->ID));
|
return $this->redirect(Controller::join_links($this->Link('show'), $record->ID));
|
||||||
}
|
}
|
||||||
@ -757,7 +762,7 @@ JS;
|
|||||||
|
|
||||||
$form = $this->getEditForm($record->ID);
|
$form = $this->getEditForm($record->ID);
|
||||||
|
|
||||||
return $form->formHtmlContent();
|
return $form->forTemplate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -791,7 +796,7 @@ JS;
|
|||||||
'Live',
|
'Live',
|
||||||
"\"SiteTree_Live\".\"ID\" = $recordID"
|
"\"SiteTree_Live\".\"ID\" = $recordID"
|
||||||
);
|
);
|
||||||
return ($liveRecord) ? $form->formHtmlContent() : "";
|
return ($liveRecord) ? $form->forTemplate() : "";
|
||||||
} else {
|
} else {
|
||||||
$this->redirectBack();
|
$this->redirectBack();
|
||||||
}
|
}
|
||||||
@ -988,7 +993,7 @@ JS;
|
|||||||
|
|
||||||
$form = $this->getEditForm($record->ID);
|
$form = $this->getEditForm($record->ID);
|
||||||
|
|
||||||
return $form->formHtmlContent();
|
return $form->forTemplate();
|
||||||
}
|
}
|
||||||
|
|
||||||
function publish($data, $form) {
|
function publish($data, $form) {
|
||||||
@ -1013,7 +1018,7 @@ JS;
|
|||||||
// Reload form, data and actions might have changed
|
// Reload form, data and actions might have changed
|
||||||
$form = $this->getEditForm($record->ID);
|
$form = $this->getEditForm($record->ID);
|
||||||
|
|
||||||
return $form->formHtmlContent();
|
return $form->forTemplate();
|
||||||
}
|
}
|
||||||
|
|
||||||
function performRollback($id, $version) {
|
function performRollback($id, $version) {
|
||||||
@ -1187,7 +1192,7 @@ JS;
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($this->isAjax()) {
|
if($this->isAjax()) {
|
||||||
return $form->formHtmlContent();
|
return $form->forTemplate();
|
||||||
} else {
|
} else {
|
||||||
$templateData = $this->customise(array(
|
$templateData = $this->customise(array(
|
||||||
"EditForm" => $form
|
"EditForm" => $form
|
||||||
@ -1426,7 +1431,7 @@ JS;
|
|||||||
// Reload form, data and actions might have changed
|
// Reload form, data and actions might have changed
|
||||||
$form = $this->getEditForm($restoredPage->ID);
|
$form = $this->getEditForm($restoredPage->ID);
|
||||||
|
|
||||||
return $form->formHtmlContent();
|
return $form->forTemplate();
|
||||||
}
|
}
|
||||||
|
|
||||||
function duplicate($request) {
|
function duplicate($request) {
|
||||||
@ -1450,7 +1455,7 @@ JS;
|
|||||||
// Reload form, data and actions might have changed
|
// Reload form, data and actions might have changed
|
||||||
$form = $this->getEditForm($newPage->ID);
|
$form = $this->getEditForm($newPage->ID);
|
||||||
|
|
||||||
return $form->formHtmlContent();
|
return $form->forTemplate();
|
||||||
} else {
|
} else {
|
||||||
user_error("CMSMain::duplicate() Bad ID: '$id'", E_USER_WARNING);
|
user_error("CMSMain::duplicate() Bad ID: '$id'", E_USER_WARNING);
|
||||||
}
|
}
|
||||||
@ -1471,7 +1476,7 @@ JS;
|
|||||||
// Reload form, data and actions might have changed
|
// Reload form, data and actions might have changed
|
||||||
$form = $this->getEditForm($newPage->ID);
|
$form = $this->getEditForm($newPage->ID);
|
||||||
|
|
||||||
return $form->formHtmlContent();
|
return $form->forTemplate();
|
||||||
} else {
|
} else {
|
||||||
user_error("CMSMain::duplicate() Bad ID: '$id'", E_USER_WARNING);
|
user_error("CMSMain::duplicate() Bad ID: '$id'", E_USER_WARNING);
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,21 @@ class CMSPagesController extends CMSMain {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function show($request) {
|
function show($request) {
|
||||||
$c = new CMSPageEditController();
|
if($request->param('ID')) {
|
||||||
return $this->redirect(Controller::join_links($c->Link('show'), $request->param('ID')));
|
$c = new CMSPageEditController();
|
||||||
|
return $this->redirect(Controller::join_links($c->Link('show'), $request->param('ID')));
|
||||||
|
} else {
|
||||||
|
return parent::show($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Link($action = null) {
|
||||||
|
// Special case: All show links should redirect to the page edit interface instead (mostly from tree nodes)
|
||||||
|
if(preg_match('/^show/', $action)) {
|
||||||
|
return singleton('CMSPageEditController')->Link($action);
|
||||||
|
} else {
|
||||||
|
return parent::Link($action);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
13
code/controller/CMSSettingsController.php
Normal file
13
code/controller/CMSSettingsController.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
class CMSSettingsController extends CMSMain {
|
||||||
|
|
||||||
|
static $url_segment = 'settings';
|
||||||
|
static $url_rule = '/$Action/$ID/$OtherID';
|
||||||
|
static $menu_priority = -1;
|
||||||
|
static $menu_title = 'Settings';
|
||||||
|
|
||||||
|
function getEditForm($id = null, $fields = null) {
|
||||||
|
return $this->RootForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -120,6 +120,12 @@ class ContentController extends Controller {
|
|||||||
return Security::permissionFailure($this, sprintf($message, Controller::join_links($link, "?stage=Live")));
|
return Security::permissionFailure($this, sprintf($message, Controller::join_links($link, "?stage=Live")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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) {
|
||||||
|
@ -1987,7 +1987,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
// "unpublish"
|
// "unpublish"
|
||||||
$unpublish = FormAction::create('unpublish', _t('SiteTree.BUTTONUNPUBLISH', 'Unpublish'), 'delete');
|
$unpublish = FormAction::create('unpublish', _t('SiteTree.BUTTONUNPUBLISH', 'Unpublish'), 'delete');
|
||||||
$unpublish->describe(_t('SiteTree.BUTTONUNPUBLISHDESC', 'Remove this page from the published site'));
|
$unpublish->describe(_t('SiteTree.BUTTONUNPUBLISHDESC', 'Remove this page from the published site'));
|
||||||
$unpublish->addExtraClass('delete');
|
$unpublish->addExtraClass('unpublish');
|
||||||
$unpublish->addExtraClass('ss-ui-action-destructive');
|
$unpublish->addExtraClass('ss-ui-action-destructive');
|
||||||
$actions->push($unpublish);
|
$actions->push($unpublish);
|
||||||
}
|
}
|
||||||
@ -2025,7 +2025,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
}
|
}
|
||||||
|
|
||||||
// "save"
|
// "save"
|
||||||
$actions->push(new FormAction('save',_t('CMSMain.SAVE','Save')));
|
$actions->push($saveDraftAction = new FormAction('save',_t('CMSMain.SAVE','Save Draft')));
|
||||||
|
$saveDraftAction->addExtraClass('save-draft');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2411,13 +2412,13 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
} elseif($this->IsAddedToStage) {
|
} elseif($this->IsAddedToStage) {
|
||||||
$tag = "ins title=\"" . _t('SiteTree.ADDEDTODRAFT', 'Added to draft site') . "\"";
|
$tag = "ins title=\"" . _t('SiteTree.ADDEDTODRAFT', 'Added to draft site') . "\"";
|
||||||
} elseif($this->IsModifiedOnStage) {
|
} elseif($this->IsModifiedOnStage) {
|
||||||
$tag = "span title=\"" . _t('SiteTree.MODIFIEDONDRAFT', 'Modified on draft site') . "\" class=\"modified\"";
|
$tag = "span title=\"" . _t('SiteTree.MODIFIEDONDRAFT', 'Modified on draft site') . "\" class=\"status modified\"";
|
||||||
} else {
|
} else {
|
||||||
$tag = '';
|
$tag = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$text = Convert::raw2xml(str_replace(array("\n","\r"),"",$this->MenuTitle));
|
$text = Convert::raw2xml(str_replace(array("\n","\r"),"",$this->MenuTitle));
|
||||||
return ($tag) ? "<$tag>" . $text . "</" . strtok($tag,' ') . ">" : $text;
|
return ($tag) ? "<span class=\"jstree-pageicon\"></span>"."<$tag>" . $text . "</" . strtok($tag,' ') . ">" : "<span class=\"jstree-pageicon\"></span>". $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
var currNode = $('.cms-tree')[0].firstSelected();
|
var currNode = $('.cms-tree')[0].firstSelected();
|
||||||
if(currNode) {
|
if(currNode) {
|
||||||
var url = $(currNode).find('a').attr('href');
|
var url = $(currNode).find('a').attr('href');
|
||||||
$('.cms-edit-form').loadForm(url);
|
$('.cms-content').loadForm(url);
|
||||||
}
|
}
|
||||||
$('.cms-tree')[0].setCustomURL('admin/assets/getsubtree');
|
$('.cms-tree')[0].setCustomURL('admin/assets/getsubtree');
|
||||||
$('.cms-tree')[0].reload({onSuccess: function() {
|
$('.cms-tree')[0].reload({onSuccess: function() {
|
||||||
|
@ -201,8 +201,9 @@
|
|||||||
if (e.button!=2) {
|
if (e.button!=2) {
|
||||||
var $link = $(this);
|
var $link = $(this);
|
||||||
$link.addClass('loading');
|
$link.addClass('loading');
|
||||||
jQuery('.cms-edit-form').entwine('ss').loadForm(
|
jQuery('.cms-content').entwine('ss').loadForm(
|
||||||
$(this).attr('href'),
|
$(this).attr('href'),
|
||||||
|
null,
|
||||||
function(e) {
|
function(e) {
|
||||||
$link.removeClass('loading');
|
$link.removeClass('loading');
|
||||||
}
|
}
|
||||||
@ -263,8 +264,9 @@
|
|||||||
|
|
||||||
var link = $(this).siblings('.versionlink').find('a').attr('href');
|
var link = $(this).siblings('.versionlink').find('a').attr('href');
|
||||||
td.addClass('loading');
|
td.addClass('loading');
|
||||||
jQuery('.cms-edit-form').entwine('ss').loadForm(
|
jQuery('.cms-content').entwine('ss').loadForm(
|
||||||
link,
|
link,
|
||||||
|
null,
|
||||||
function(e) {
|
function(e) {
|
||||||
td.removeClass('loading');
|
td.removeClass('loading');
|
||||||
}
|
}
|
||||||
@ -314,8 +316,9 @@
|
|||||||
data.push({name:$button.attr('name'), value: $button.val()});
|
data.push({name:$button.attr('name'), value: $button.val()});
|
||||||
|
|
||||||
if(loadEditForm) {
|
if(loadEditForm) {
|
||||||
jQuery('.cms-edit-form').entwine('ss').loadForm(
|
jQuery('.cms-content').entwine('ss').loadForm(
|
||||||
this.attr('action'),
|
this.attr('action'),
|
||||||
|
null,
|
||||||
function(e) {
|
function(e) {
|
||||||
$button.removeClass('loading');
|
$button.removeClass('loading');
|
||||||
},
|
},
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
(function($) {
|
|
||||||
$('.cms-tree').bind('select_node.jstree', function(e, data) {
|
|
||||||
var node = data.rslt.obj, url = $(node).find('a:first').attr('href');
|
|
||||||
if(url && url != '#') document.location.href = url;
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
}(jQuery));
|
|
@ -1,4 +1,4 @@
|
|||||||
<div class="cms-content center ss-tabset" data-layout="{type: 'border'}">
|
<div class="cms-content center ss-tabset $BaseCSSClasses" data-layout="{type: 'border'}">
|
||||||
|
|
||||||
<div class="cms-content-header north">
|
<div class="cms-content-header north">
|
||||||
<div>
|
<div>
|
||||||
@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="cms-content-form center">
|
<div class="cms-content-fields center">
|
||||||
<div id="cms-content-listview">
|
<div id="cms-content-listview">
|
||||||
$EditForm
|
$EditForm
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
<div class="cms-content center">
|
<div class="cms-content center $BaseCSSClasses">
|
||||||
<i>Not implemented yet</i>
|
<i>Not implemented yet</i>
|
||||||
</div>
|
</div>
|
@ -1,3 +1,3 @@
|
|||||||
<div class="cms-content center">
|
<div class="cms-content center $BaseCSSClasses">
|
||||||
<i>Not implemented yet</i>
|
<i>Not implemented yet</i>
|
||||||
</div>
|
</div>
|
@ -1,4 +1,4 @@
|
|||||||
<div class="cms-content center ss-tabset" data-layout="{type: 'border'}">
|
<div class="cms-content center ss-tabset $BaseCSSClasses" data-layout="{type: 'border'}">
|
||||||
|
|
||||||
<div class="cms-content-header north">
|
<div class="cms-content-header north">
|
||||||
<div>
|
<div>
|
||||||
@ -28,9 +28,10 @@
|
|||||||
$SearchForm
|
$SearchForm
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="cms-content-form center ui-widget-content">
|
<div class="cms-content-fields center ui-widget-content">
|
||||||
|
|
||||||
<div id="cms-content-treeview">
|
<div id="cms-content-treeview">
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div class="cms-content-constructive-actions">
|
||||||
<a class="ss-ui-button ss-ui-action-constructive cms-page-add-button" href="#cms-page-add-form"><% _t('CMSMain.AddNewButton', 'Add new') %></a>
|
<a class="ss-ui-button ss-ui-action-constructive cms-page-add-button" href="#cms-page-add-form"><% _t('CMSMain.AddNewButton', 'Add new') %></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<div class="cms-content center" data-layout="{type: 'border'}">
|
<div class="cms-content center $BaseCSSClasses" data-layout="{type: 'border'}">
|
||||||
|
|
||||||
<div class="cms-content-header north">
|
<div class="cms-content-header north">
|
||||||
<h2><% _t('REPORTS','Reports') %></h2>
|
<h2><% _t('REPORTS','Reports') %></h2>
|
||||||
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="cms-content-form center ui-widget-content">
|
<div class="cms-content-fields center ui-widget-content">
|
||||||
$EditForm
|
$EditForm
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -198,22 +198,22 @@ class CMSMainTest extends FunctionalTest {
|
|||||||
// with insufficient permissions
|
// with insufficient permissions
|
||||||
$cmsUser->logIn();
|
$cmsUser->logIn();
|
||||||
$this->get('admin/pages');
|
$this->get('admin/pages');
|
||||||
$response = $this->submitForm(
|
$response = $this->post(
|
||||||
'Form_AddForm',
|
'admin/pages/AddForm',
|
||||||
null,
|
array('ParentID' => '0', 'ClassName' => 'Page', 'Locale' => 'en_US', 'action_doAdd' => 1)
|
||||||
array('ParentID' => '0', 'ClassName' => 'Page', 'Locale' => 'en_US')
|
|
||||||
);
|
);
|
||||||
// should redirect, which is a permission error
|
// should redirect, which is a permission error
|
||||||
$this->assertEquals(403, $response->getStatusCode(), 'Add TopLevel page must fail for normal user');
|
$this->assertEquals(403, $response->getStatusCode(), 'Add TopLevel page must fail for normal user');
|
||||||
|
|
||||||
// with correct permissions
|
// with correct permissions
|
||||||
$rootEditUser->logIn();
|
$rootEditUser->logIn();
|
||||||
$this->get('admin/pages/');
|
$response = $this->get('admin/pages/');
|
||||||
$response = $this->submitForm(
|
|
||||||
'Form_AddForm',
|
$response = $this->post(
|
||||||
null,
|
'admin/pages/AddForm',
|
||||||
array('ParentID' => '0', 'ClassName' => 'Page', 'Locale' => 'en_US')
|
array('ParentID' => '0', 'ClassName' => 'Page', 'Locale' => 'en_US', 'action_doAdd' => 1)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(302, $response->getStatusCode(), 'Must be a redirect on success');
|
$this->assertEquals(302, $response->getStatusCode(), 'Must be a redirect on success');
|
||||||
$location=$response->getHeader('Location');
|
$location=$response->getHeader('Location');
|
||||||
$this->assertContains('/show/',$location, 'Must redirect to /show/ the new page');
|
$this->assertContains('/show/',$location, 'Must redirect to /show/ the new page');
|
||||||
|
@ -16,19 +16,22 @@ class ContentControllerPermissionTest extends FunctionalTest {
|
|||||||
$page->publish('Stage', 'Live');
|
$page->publish('Stage', 'Live');
|
||||||
|
|
||||||
$response = $this->get('/testpage');
|
$response = $this->get('/testpage');
|
||||||
$this->assertEquals($response->getStatusCode(), 200);
|
$this->assertEquals($response->getStatusCode(), 200, 'Doesnt require login for implicit live stage');
|
||||||
|
|
||||||
$response = $this->get('/testpage/?stage=Live');
|
$response = $this->get('/testpage/?stage=Live');
|
||||||
$this->assertEquals($response->getStatusCode(), 200);
|
$this->assertEquals($response->getStatusCode(), 200, 'Doesnt require login for explicit live stage');
|
||||||
|
|
||||||
$response = $this->get('/testpage/?stage=Stage');
|
$response = $this->get('/testpage/?stage=Stage');
|
||||||
// should redirect to login
|
// should redirect to login
|
||||||
$this->assertEquals($response->getStatusCode(), 302);
|
$this->assertEquals($response->getStatusCode(), 302, 'Redirects to login page when not logged in for draft stage');
|
||||||
|
$this->assertContains('Security/login', $response->getHeader('Location'));
|
||||||
|
|
||||||
$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(), 200);
|
$this->assertEquals($response->getStatusCode(), 302, 'Redirects to page view in CMS when logged in for draft stage');
|
||||||
|
$this->assertNotContains('Security/login', $response->getHeader('Location'));
|
||||||
|
$this->assertContains('admin/page/edit/show/' . $page->ID, $response->getHeader('Location'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
|||||||
// should be prompted for a login
|
// should be prompted for a login
|
||||||
$response = $this->get($page->URLSegment . '?stage=Stage');
|
$response = $this->get($page->URLSegment . '?stage=Stage');
|
||||||
$this->assertEquals($response->getStatusCode(), '302');
|
$this->assertEquals($response->getStatusCode(), '302');
|
||||||
|
$this->assertContains('Security/login', $response->getHeader('Location'));
|
||||||
|
|
||||||
$this->logInWithPermission('ADMIN');
|
$this->logInWithPermission('ADMIN');
|
||||||
|
|
||||||
@ -61,7 +62,9 @@ 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(), '200');
|
$this->assertEquals($response->getStatusCode(), '302');
|
||||||
|
$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');
|
||||||
@ -330,9 +333,10 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
|||||||
$response = $this->get($childPage->RelativeLink());
|
$response = $this->get($childPage->RelativeLink());
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$response->getStatusCode(),
|
$response->getStatusCode(),
|
||||||
200,
|
302,
|
||||||
'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…
Reference in New Issue
Block a user