mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX #6291 Remove rollback action from CMSMain allowed_actions and rely on form action_rollback instead which is safer
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@115440 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
b81cae875a
commit
3e8cc481f0
@ -1948,10 +1948,22 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||
function getCMSActions() {
|
||||
$actions = new FieldSet();
|
||||
|
||||
// "readonly"/viewing version that isn't the current version of the record
|
||||
$stageOrLiveRecord = Versioned::get_one_by_stage($this->class, Versioned::current_stage(), sprintf('"SiteTree"."ID" = %d', $this->ID));
|
||||
if($stageOrLiveRecord && $stageOrLiveRecord->Version != $this->Version) {
|
||||
$actions->push(new FormAction('email', _t('CMSMain.EMAIL', 'Email')));
|
||||
$actions->push(new FormAction('rollback', _t('CMSMain.ROLLBACK', 'Roll back to this version')));
|
||||
|
||||
// getCMSActions() can be extended with updateCMSActions() on a decorator
|
||||
$this->extend('updateCMSActions', $actions);
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
if($this->isPublished() && $this->canPublish() && !$this->IsDeletedFromStage) {
|
||||
// "unpublish"
|
||||
$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');
|
||||
$actions->push($unpublish);
|
||||
}
|
||||
@ -1960,7 +1972,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||
if($this->isPublished() && $this->canEdit()) {
|
||||
// "rollback"
|
||||
$rollback = FormAction::create('rollback', _t('SiteTree.BUTTONCANCELDRAFT', 'Cancel draft changes'), 'delete');
|
||||
$rollback->describe(_t('SiteTree.BUTTONCANCELDRAFTDESC', "Delete your draft and revert to the currently published page"));
|
||||
$rollback->describe(_t('SiteTree.BUTTONCANCELDRAFTDESC', 'Delete your draft and revert to the currently published page'));
|
||||
$rollback->addExtraClass('delete');
|
||||
$actions->push($rollback);
|
||||
}
|
||||
|
@ -153,6 +153,26 @@ class SiteTreeActionsTest extends FunctionalTest {
|
||||
$this->assertContains('action_rollback',$actionsArr);
|
||||
$this->assertNotContains('action_revert',$actionsArr);
|
||||
}
|
||||
|
||||
function testActionsViewingOldVersion() {
|
||||
$p = new Page();
|
||||
$p->Content = 'test page first version';
|
||||
$p->write();
|
||||
$p->Content = 'new content';
|
||||
$p->write();
|
||||
|
||||
// Looking at the old version, the ability to rollback to that version is available
|
||||
$version = DB::query('SELECT "Version" FROM "SiteTree_versions" WHERE "Content" = \'test page first version\'')->value();
|
||||
$old = Versioned::get_version('Page', $p->ID, $version);
|
||||
$actions = $old->getCMSActions()->column('Name');
|
||||
$this->assertNotContains('action_save', $actions);
|
||||
$this->assertNotContains('action_publish', $actions);
|
||||
$this->assertNotContains('action_unpublish', $actions);
|
||||
$this->assertNotContains('action_delete', $actions);
|
||||
$this->assertContains('action_email', $actions);
|
||||
$this->assertContains('action_rollback', $actions);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class SiteTreeActionsTest_Page extends Page implements TestOnly {
|
||||
@ -163,5 +183,4 @@ class SiteTreeActionsTest_Page extends Page implements TestOnly {
|
||||
function canDelete($member = null) {
|
||||
return Permission::checkMember($member, 'SiteTreeActionsTest_Page_CANDELETE');
|
||||
}
|
||||
}
|
||||
?>
|
||||
}
|
@ -715,7 +715,7 @@ class SiteTreeTest extends SapphireTest {
|
||||
$this->assertNotContains('SiteTree', $classes, 'Page types do not include base class');
|
||||
$this->assertContains('Page', $classes, 'Page types do contain subclasses');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**#@+
|
||||
|
Loading…
Reference in New Issue
Block a user